WECHATY
CONNECTING CHATBOTS
Wechaty is a Bot SDK for Wechat Individual Account which can help you create a bot in 6 lines of javascript, with cross-platform support including Linux, Windows, Darwin(OSX/Mac) and Docker.
:octocat: https://github.com/chatie/wechaty
:beetle: https://github.com/chatie/wechaty/issues
:book: https://github.com/chatie/wechaty/wiki
:whale: https://hub.docker.com/r/zixia/wechaty
VOICE OF THE DEVELOPER
"Wechaty is a great solution, I believe there would be much more users recognize it." link
-- @Gcaufy, Tencent Engineer, Author of WePY
"太好用,好用的想哭"
-- @xinbenlv, Google Engineer, Founder of HaoShiYou.org
"最好的微信开发库" link
-- @Jarvis, Baidu Engineer
"Wechaty让运营人员更多的时间思考如何进行活动策划、留存用户,商业变现" link
-- @lijiarui, CEO of BotOrange.
"If you know js ... try Chatie/wechaty, it's easy to use."
-- @Urinx Uri Lee, Author of WeixinBot(Python)
See more at Wiki:Voice Of Developer
The World's Shortest ChatBot Code: 6 lines of JavaScript
const { Wechaty } = require('wechaty')
Wechaty.instance()
.on('scan', (qrcode, status) => console.log(`Scan QR Code to login: ${status}\nhttps://api.qrserver.com/v1/create-qr-code/?data=${encodeURIComponent(qrcode)}`))
.on('login', user => console.log(`User ${user} logined`))
.on('message', message => console.log(`Message: ${message}`))
.start()
Notice: Wechaty requires Node.js version >= 10
This bot can log all messages to the console after login by scan.
You can find more examples from Wiki and Example Directory.
REQUIREMENTS
- Node.js 10 or above
- Global Network Connection
GETTING STARTED
We have a Wechaty starter repository for beginners with the simplest setting. It will be just work out-of-the-box after you clone
& npm install
& npm start
.
If you are new to Wechaty and want to try it the first time, we'd like to strong recommend you starting from this repository, and using it as your starter template for your project.
Otherwise, please saved the above The World's Shortest ChatBot Code: 6 lines of JavaScript example to a file named mybot.js
before you can use either NPM or Docker to run it.
1. NPM
npm init
npm install wechaty
# create your first mybot.js file, you can copy/paste from the above "The World's Shortest ChatBot Code: 6 lines of JavaScript"
# then:
node mybot.js
2. Docker
Wechaty Docker supports both JavaScript and TypeScript. To use TypeScript just write in TypeScript and save with extension name .ts
, no need to compile because we use ts-node
to run it.
2.1. Run JavaScript
# for JavaScript
docker run -ti --rm --volume="$(pwd)":/bot zixia/wechaty mybot.js
2.2. Run TypeScript
# for TypeScript
docker run -ti --rm --volume="$(pwd)":/bot zixia/wechaty mybot.ts
Learn more about Wechaty Docker at Wiki:Docker.
3. Switch Protocol(Puppet)
Wechaty is very powerful that it can run with different protocols. You can specify the protocol by set the environment variable WECHATY_PUPPET
to different puppet provider.
Currently we support the following puppet providers:
Protocol | Puppet Provider | Environment Variable |
---|
Web | PuppetPuppeteer | export WECHATY_PUPPET=wechaty-puppet-puppeteer |
iPad | PuppetPadchat | export WECHATY_PUPPET=wechaty-puppet-padchat |
Mock | PuppetMock | export WECHATY_PUPPET=wechaty-puppet-mock |
Web | PuppetWechat4u | export WECHATY_PUPPET=wechaty-puppet-wechat4u |
Learn more about Wechaty Puppet from the Puppet Wiki:
- Puppet Directory: https://github.com/Chatie/wechaty-puppet/wiki/Directory
- Puppet Compatibility: https://github.com/Chatie/wechaty-puppet/wiki/Compatibility
API
Read the Full Documentation at Wechaty Official API Reference
1 Class Wechaty
Main bot class.
A Bot
is a Wechaty instance that control a specific wechaty-puppet.
2 Class Contact
All wechat contacts(friends/non-friends) will be encapsulated as a Contact.
2.1 Class ContactSelf
Class ContactSelf
is extended from Contact
.
2.2 Class Friendship
Send, receive friend request, and friend confirmation events.
3 Class Message
All wechat messages will be encapsulated as a Message.
4 Class Room
All wechat rooms(groups) will be encapsulated as a Room.
4.1 Class RoomInvitation
Accept room invitation
TEST
Wechaty is fully automatically tested by unit and integration tests, with Continious Integration & Continious Deliver(CI/CD) support powered by CI like Travis, Shippable and Appveyor.
To test Wechaty, run:
npm test
Get to know more about the tests from Wiki:Tests
RELEASE NOTES
Views Since Feb 15, 2019
POWERED BY WECHATY
Wechaty Badge
[![Powered by Wechaty](https://img.shields.io/badge/Powered%20By-Wechaty-blue.svg)](https://github.com/chatie/wechaty)
Get more embed html/markdown code from Wiki:PoweredByWechaty
Projects Using Wechaty
- 一个用CNN深度神剧网络给图片评分的wechaty项目
- Relay between Telegram and WeChat
- A chat bot managing the HaoShiYou wechat groups run by volunteers of haoshiyou.org
- An interactive chat bot to manage a TODO list
- Forward WeChat messages to telegram
Pull Request is welcome to add yours!
Learn more about Projects Using Wechaty at Wiki:PoweredByWechaty
FIND A GOOD SERVER
The best practice for running Wechaty Docker/NPM is using a VPS(Virtual Private Server) outside of China, which can save you hours of time because npm install
and docker pull
will run smoothly without any problem.
The following VPS providers are used by the Wechaty team, and they worked perfectly in production. You can use the following link to get one in minutes. Also, doing this can support Wechaty because you are referred by us.
Location | Price | Ram | Payment | Provider |
---|
Singapore | $5 | 512MB | Paypal | DigitalOcean |
Japan | $5 | 1GB | Paypal | Linode |
Korea | $10 | 1GB | Alipay, Paypal | Netdedi |
Singapore | $3.5 | 512MB | Alipay, Wechat | Vultr |
SEE ALSO
CONTRIBUTING
How to contribute
Why contribute?
As an open source product, Chatie thrives from contributions of community members. Whatever your skill set is, there is a lot you can do to help us make Chatie better!
So start forking!
Not sure where to start?
It's a myth that writing code is the only way to contribute to open source. Chatie community is open to new ideas and there are so many different ways to make valuable contributions. We have some ideas of how you can get started!
1. Contribute Code
- Check out GitHub issues with the tags
good first issue
, pull request welcome
or help wanted
- Write code examples for documentation
- Report a bug and work on resolving it
- Collaborate with others on building new features
Tips:
If you want to add new features or change the API, please submit an issue first to make sure no one else is already working on the same thing and discuss the implementation and API details with maintainers and users by creating an issue. When everything is settled down, you can submit a pull request.
Make sure to add tests for your features and bugfixes and update the documentation (see below) before submitting your code!
2. Contribute Support
- Fix typos in documentation
- Translate documentation to your local language
- Write tutorials and blog posts, see more: https://github.com/chatie/blog
- Answer questions on the Wechaty Developers Home or Github issues
- Organize Chatie meetups or user groups in your area
Contact rui@chatie.io to learn more
Contributors List
https://github.com/Chatie/wechaty/wiki/Contributors
Join Us
Wechaty is used in many ChatBot projects by hundreds of developers. If you want to talk with other developers, just scan the following QR Code in WeChat with secret code wechaty, join our Wechaty Developers' Home.
Scan now, because other Wechaty developers want to talk with you too! (secret code: wechaty)
AUTHOR
- Huan LI (李卓桓) <zixia@zixia.net>
- Grace @lijiarui
The Story
In 2017 ...
Huan's daily life/work depends on too much chat on wechat.
- Almost 14,000 wechat friends in May 2014, before wechat restricts a total number of friends to 5,000.
- Almost 400 wechat rooms, and most of them have more than 400 members.
Can you imagine that? He was dying...
So a tireless bot working for me 24x7 on wechat, monitoring/filtering the most important message is badly needed. For example, it highlights discussion which contains the KEYWORDS which he want to follow up(especially in a noisy room). ;-)
At last, It's built for huan's personal study purpose of Automatically Testing.
COPYRIGHT & LICENSE
- Code & Docs © 2016-2018 Huan LI <zixia@zixia.net>
- Code released under the Apache-2.0 License
- Docs released under Creative Commons