The monster demo
This demo is a one-stop demo that includes everything useful for people to get an easier start. Because it is much simpler to remove an module from it, rather than figuring out how to put all these jigsaw puzzles together.
The following are the list of useful features incorporated into this demo:
- All even handling in separated code, instead of everything in a big file
- Can read from a config file
- Can do rooms/messages matching using regexp that are defined in the config file
- Can do hot reload, when the
.jsscripts/files are updated
- Hot reload/import even handling code, without restarting the program
- Hot reload/import configuration files as well
- Auto-save all media files, i.e., incorporates
media-file-bot.tsinto this getting started demo
- Emoji cleansing -- to simplify emoji from
<img class="qqemoji qqemoji13" text="[呲牙]_web" src="https://wx.qq.com/zh_CN/htmledition/v2/images/spacer.gif" />to merely
- Add error handling in
on-message.jsto catch errors instead of failing the program
- Graceful exit on
SIGINT/SIGTERMetc, i.e., to write key info into file, on receiving killing signals (e.g.,
SIGINT (2), SIGTERM(3)), before termination, so as to do a "graceful shutdown".
All in all, it will be a turn key solution for getting started with wechaty customization seriously, a true blue-print solution for people to get started using wechaty.
docker run -t -i --rm --name wechaty --mount type=bind,source="$(pwd)",target=/bot zixia/wechaty index.js
Hot import Wechaty listenser functions after change the source code without restart the program
This directory is an example of how to use
feature introduced in this commit.
The hot-import is based on an npm package hot-import
About Pure ES6 instead of Typescript
When I code customization code for wechaty, I write everything in pure ES6 instead of Typescript, and there are strong reasons for that. For details, check out my blog entry,