Huan LI edited this page Jul 25, 2018 · 52 revisions

0. What's the easiest way to start using Wechaty?

  1. Clone our Starter Project at https://github.com/Chatie/wechaty-getting-started
  2. Run npm install
  3. Run npm start
  4. Our demo example will be runned out-of-the-box
  5. Modify our demo example to implement your own bot logic

1. Why are the entire project writing in English?

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.

2. Why doesn't the entire project use the semicolon?

It's just author's favorite.

And I'm also supporting to not use semicolons, because of:

  1. http://blog.izs.me/post/2353458699/an-open-letter-to-javascript-leaders-regarding
  2. http://inimino.org/~inimino/blog/javascript_semicolons
  3. 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.

JS Standard Coding Style

No semicolons.

Related PR:

3. How to Understand the Wechaty Semantic Versioning?

Short answer:

Even Minor Number is for Production.

Long Answer:

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:

  1. even numbers, such as 0.8, 0.12, is for production use.
  2. 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.

See Also

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.

4. Why login via scanning the QRcode instead of just username and password?

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:

  1. some of the puppets do not have the ability to do that, for example, PuppetWechat4u, which is using the Web API;
  2. 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.
  3. 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.

How to send the message without onMessage?

Send message to one room

const room = await Room.find('room name')
room.say('hello room')

Send message to one contact

const contact = await 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()

Get ERROR: can not found bot file: xxx.js when using docker to start wechaty.

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 enabled by default with CentOS installation. (Ubuntu default installation had never seen this.)

We found this case in the issue: the root user has no permission to read directory, what you need to do is to run:

setenforce 0

setenforce 0 will disable SELinux for you.

Related blog:

Related issues:

  • #66 Dockerize Wechaty for easy start

I found there is a default.memory-card.json in the root directory, what does this do?

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:

1. Set the profile with an option of the constructor, like this
const bot = Wechaty.instance({ profile: 'your-cute-bot-name' })
2. Set the environment variable for WECHATY_PROFILE during the start
WECHATY_PROFILE="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.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.