-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
- Clone our Starter Project at https://github.com/Chatie/wechaty-getting-started
- Run
npm install
- Run
npm start
- Our demo example will be runned out-of-the-box
- Modify our demo example to implement your own bot logic
First, it's the author's choice: he wants to practice English by writing more.
Second, according to PEP8 from Python:
... coders from non-English speaking countries: please write ... in English, unless you are 120% sure that the code will never be read by people who don't speak your language.
It's just author's favorite.
And I'm also supporting to not use semicolons, because of:
- http://blog.izs.me/post/2353458699/an-open-letter-to-javascript-leaders-regarding
- http://inimino.org/~inimino/blog/javascript_semicolons
- https://www.youtube.com/watch?v=gsfbh17Ax9I
So I would like to suggest all my friends not to use the semicolon, which is a JS Standard Code Style.
No semicolons.
Related PR:
Even Minor Number is for Production.
Wechaty is following the Semantic Versioning 2.0 http://semver.org/ and will use the MINOR version to indicated the release is for Production or NOT.
Numbering rule:
- even numbers, such as 0.8, 0.12, is for production use.
- odd numbers, such as 0.11 or 0.13, is development releases.
According to #905 #1158, when the minor version number in SemVer is odd, it means it comes from a developing branch, and it will not be ready for Production.
even Examples: (for Production)
- 0.16.1
- 0.16.2
- 1.0.1
- 1.0.2
odd Examples: (for Development)
- 0.15.1
- 0.15.2
- 1.1.1
- 1.1.2
At the same time, we publish all the version to NPM when the code base passed the Automatic Testing by Travis CI.
We should only publish to NPM via CI/CD for the STABLE/PROD version for the master branch, which means we should limit it to the version number is even.
- https://stackoverflow.com/q/43210945/1123955
- https://docs.npmjs.com/misc/config#environment-variables
Copy from Linux Kernel Version Numbering - http://www.linfo.org/kernel_version_numbering.html :
The second number denotes the major revision of the kernel version. It was formerly the case that even numbers indicated a stable release, that is, one that was deemed fit for production use (i.e., use in a non-experimental environment), such as 1.2, 2.4 or 2.6. Likewise, odd numbers, such as 1.1 or 2.5, have historically represented development releases. They were for testing new features and device drivers until they became sufficiently stable to be included in a stable release. However, this has changed starting with the Linux 2.6.x series, and new feature development now takes place in the same revision number.
I see in the code the ability to log in via username and password, so probably I can create an account from scratch and do not need to scan the QR .... but why not?
Yes, you are right.
Some of the puppet(Wechaty Puppet, specifically) has the ability to login via username and password, as you see in the code. However, I have no plan to add an API to enable login via username and password yet, because of the following three reasons:
- some of the puppets do not have the ability to do that, for example, PuppetWechat4u, which is using the Web API;
- when you log in by scan QR Code, you can keep your session on your phone, which means you can use WeChat at the same time when your Bot is online; If you login in by username/password, then all other login sessions will be terminated, only your Bot can use WeChat.
- as you have already seen, we are using a Protocol Server to control the iPad WeChat. If you want to use username/password to log in, then you will have to send that sensitive information to a 3rd party server, which will not be comfortable for most people.
Send message to one room
const room = await wechaty.Room.find('room name')
room.say('hello room')
Send message to one contact
const contact = await wechaty.Contact.find('contact name')
contact.say('hello room')
See more example at https://github.com/Chatie/wechaty/wiki/Example
Related issues:
- #446 how to send mesage without onMessage
- #200 [new feature] Forward Message
- #89 Wechaty.send() error when send message to the room
- #41 [New Feature] send message by branding new method: say()
First, please make sure you have the file xxx.js
, if you get an error again, please check SELinux
settings for your Linux:
SELinux is setting to enforcing mode by default with CentOS/RHEL
installation. (Ubuntu
default installation had never seen this.)
SELinux is another user access control system. By setting user/role/type attribute for folder and files, it define how processes interact with files, as well as how processes interact with each other. Using getenforce
and sestatus
to check the SELinux status.
Add :Z label to allow docker to modify the selinux label: (check with ls -laZ
)
docker run -ti --rm --volume="$(pwd)":/bot:Z zixia/wechaty xxx.js
(Note: It will lost their last selinux label, that may raise another 'Permission Denied' from program which using this folder.)
Another method, disable SELinux (Not recommended) What you need to do is to run:
setenforce 0
Related documents:
Related blog:
Related issues:
- #66 Dockerize Wechaty for easy start
The default.memory-card.json
stores the bot's login information, which can be used to save bot's personal information, so the bot can auto login to Wechat after the first time.
If the default.memory-card.json
stores my bot's personal information, what if I want to start multiple bots? Are they gonna share the same file?
If you want to fire up multiple bots on one machine, you can set up the name for the memory-card, so you will have multiple memory-card.json
files, To set up the name, you need to set up the profile
for your bot, you have two options to do this:
const wechaty = new Wechaty({ name: 'your-cute-bot-name' })
WECHATY_NAME="your-cute-bot-name" ts-node bot.ts
Then you will see a file called your-cute-bot-name.memory-card.json
file in the root folder.
Getting Started
FAQ
Troubleshooting
Contributors
Wechaty Developer Program
API
Log
Tests
Badge
Projects Using Wechaty
Links
Related Technologies