Skip to content

ligen131/Sunbot

Repository files navigation

Sunbot

Powered by Wechaty Node.js v16 TypeScript GitHub last commit License

Wechaty Contributor Program OSCS Status

A WeChat bot powered by WeChaty.

Feature and Command

All operations of Sunbot is based on command call. You just need to send simple command in the chat window of WeChat/WhatsApp to the bot, and it will reply to you automatically.

  1. ding-dong bot: Send ding to the bot in wherever room or private talk. If the bot running normally, it will reply you dong.

  2. repeater: If 4 consecutive identical text messages are detected in the current room chat, the message will be automatically repeated.

  3. (Unstable) Cats' and Dogs' photo: Send 发猫猫 or 发狗狗 to the bot and it will reply you the cats' or dogs' photo.

  4. Status page:

    After bot starts normally, it will automatically start the status page, which listens at http://localhost:4721 by default. You can change the default port in the configuration.

      "statusPage": {
        "enable": true,
        "port": 4721
      },

See Also

Sunbot js-version branch, more interesting and fun features, such as Wordle, 1A2B game and wordcloud.

Wechaty University Admission Helper, published on the official blog of wechaty https://wechaty.js.org/2022/09/27/wechaty-university-admission-helper/

Usage

  1. Rename config/config-example.json to config/config.json. Modify the configuration file according to your actual situation.

    bot.puppet is what puppet you are using. For more details, see Wechaty Puppet Providers.

    bot.puppetOptions.token is your puppet token. If your puppet don't need token, you needn't change it.

    Note: You may need to run npm install YOUR_PUPPET_HERE according to your puppet. For example, run npm install wechaty-puppet-padlocal before you get to the next step.

  2. (Optional) If you need to use some database-based plugins, you need to install mysql client and mysql server.

    The following plugins are implemented based on the database:

    repeater(optional)
    

    Modify the database settings in the configuration file. If you keep the default configuration, then you need to execute the following commands. Otherwise, modify the command according to your configuration before executing it.

    $ mysql -u root -p
    -- Enter your password for root
    -- The following command will be run in mysql client
    CREATE DATABASE `sunbot`;
    CREATE USER `sun` IDENTIFIED BY '123456';
    GRANT ALL ON `sunbot`.* TO `sun`;
    EXIT;
  3. Run

    $ npm install
    $ npm run start

By the way, you can set whether to enable each plugin in the configuration.

  "plugins": {
    "dingdong": {
      "enable": true
    },
    "repeater": {
      "enable": true
    },
    "cats": {
      "enable": true
    },
    "dogs": {
      "enable": true
    }
  }

Build

$ npm run build

The built file will generate into folder dist.

Development

Run the following command, which supports real-time compilation and operation.

$ npm run dev

Run the following command, which supports performs TypeScript code inspection with ESLint and auto-formatting code with prettier.

$ npm run check

Code formatting and inspection will be performed automatically every time you commit, and the commit will not be allowed if the inspection fails.

In order to make the commit more standardized (git-emoji-commit), please use the following command to commit:

$ npm run check && git add . && npm run commit

Dependencies

The following NPM packages are used by this project.

wechaty
wechaty-puppet-*
typescript
ts-node
express
@types/express
jsdom
@types/jsdom
mysql2
@types/mysql

LICENSE

GNU General Public License v3.0

About

A WeChat bot powered by WeChaty

Topics

Resources

License

Stars

Watchers

Forks