Code Monkey home page Code Monkey logo

wechaty's Introduction

Wechaty

WECHATY

Connecting ChatBots.

Wechaty is a Bot Framework for Wechat Personal Account which can help you create a bot in 6 lines of javascript, with cross-platform support include Linux, Windows, Darwin(OSX/Mac) and Docker.

node TypeScript Repo Size

:octocat: https://github.com/chatie/wechaty
🪲 https://github.com/chatie/wechaty/issues
📖 https://github.com/chatie/wechaty/wiki
🐳 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:VoiceOfDeveloper

The World's Shortest ChatBot Code: 6 lines of JavaScript

const { Wechaty } = require('wechaty') // import { Wechaty } from 'wechaty'

Wechaty.instance() // Singleton
.on('scan', (url, code) => console.log(`Scan QR Code to login: ${code}\n${url}`))
.on('login',       user => console.log(`User ${user} logined`))
.on('message',  message => console.log(`Message: ${message}`))
.start()

Notice: Wechaty requires Node.js version >= 8.5

This bot can log all messages to the console.

You can find more examples from Wiki and Example Directory.

GETTING STARTED

A Great Live Coding Tutorial

The above 15 minute video tutorial is a good start point if you are new to Wechaty.

Source code in the video can be found at: Wechaty Starter Repository

Run

Let's say, you have saved the above six line javascript example to mybot.js.

We have two options to run wechaty:

  1. Docker
  2. NPM

Notice: The published versions have always passed the CI tests. We highly recommend running wechaty with the versions installed by docker or npm instead of the latest master branch unless you are prepared to deal with the broken code problems.

Docker

Docker Pulls Docker Stars Docker Layers

The best practice to use Wechaty is running with docker, because it's not only the most easy way to get started, but also protects you from the troubles of dependency problems.

Wechaty Docker supports both JavaScript and TypeScript. To use TypeScript just write in TypeScript and save with extension name .ts.

Get to know more about Wechaty Docker at Wiki:Docker.

  1. Run JavaScript
$ docker run -ti --rm --volume="$(pwd)":/bot zixia/wechaty mybot.js # for JavaScript
  1. Run TypeScript
$ docker run -ti --rm --volume="$(pwd)":/bot zixia/wechaty mybot.ts # for TypeScript

NPM

NPM Version Downloads Greenkeeper badge

$ npm init
$ npm install wechaty

$ cat > mybot.js <<'_EOF_'
const { Wechaty } = require('wechaty')
const bot = Wechaty.instance()
console.log(bot.version())
_EOF_

$ node mybot.js

Get to know more about NPM at Wiki:NPM

TEST

Linux/Mac Build Status Windows Build status Docker CircleCI

Coverage Status Known Vulnerabilities

Wechaty is fully tested by unit tests and integration tests, with Continious Integration & Continious Deliver(CI/CD) support, which is powered by TravisCI, CircleCI and Appveyor CI.

To test Wechaty, run:

npm test

Get to know more about the tests from Wiki:Test

DOCUMATAION

In order to sync the doc with the lastest code, we are using jsdoc to describe the API, and use jsdoc-to-markdown to generate markdown format documents to the docs directory.

See: Official API Reference

RELEASE NOTES

POWERED BY WECHATY

Powered by Wechaty

Wechaty Badge

Get embed html/markdown code from Wiki:PoweredByWechaty

Projects Using Wechaty

  1. 一个用CNN深度神剧网络给图片评分的wechaty项目
  2. Relay between Telegram and WeChat
  3. A chat bot managing the HaoShiYou wechat groups run by volunteers of haoshiyou.org
  4. An interactive chat bot to manage a TODO list
  5. Forward WeChat messages to telegram

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

See Also

CONTRIBUTING

Issue Stats Issue Stats Join the chat at https://gitter.im/zixia/wechaty

Howto contribute

Contributions in any form are highly encouraged and welcome! Be it new or improved presets, optimized streaming code or just some cleanup. So start forking!

Contributors List

https://github.com/Chatie/wechaty/wiki/Contributors

Code Contributions

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.

When fixing bugs, you can directly submit a pull request.

Make sure to add tests for your features and bugfixes and update the documentation (see below) before submitting your code!

Documentation Contributions

You can directly submit pull requests for documentation changes.

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.

Wechaty Developers' Home

Scan now, because other Wechaty developers want to talk with you too! (secret code: wechaty)

Future Improvements

Wechaty is far from perfect. The following things should be addressed in the future:

  • PuppetWine - Use DLL Inject to hook Windows Wechat Application, run from wine inside docker.
  • PuppetAndroid - Use Xposed to Hook Android Pad version of Wechat App, run from android emulator inside docker.

AUTHOR

Huan LI <[email protected]>

profile for zixia on Stack Exchange, a network of free, community-driven Q&A sites

My Story

My daily life/work depends on too much chat on wechat.

  • I almost have 14,000 wechat friends in May 2014, before wechat restricts a total number of friends to 5,000.
  • I almost have 400 wechat rooms, and most of them have more than 400 members.

Can you imagine that? I'm 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 I want to follow up(especially in a noisy room). ;-)

At last, It's built for my personal study purpose of Automatically Testing.

COPYRIGHT & LICENSE

  • Code & Docs © 2016-2017 Huan LI <[email protected]>
  • Code released under the Apache-2.0 License
  • Docs released under Creative Commons

wechaty's People

Contributors

huan avatar greenkeeper[bot] avatar lijiarui avatar jaslin avatar mukaiu avatar greenkeeperio-bot avatar xinbenlv avatar christianzzz avatar hczhcz avatar suntong avatar imerse avatar hiwanz avatar flyingblazer avatar xjchengo avatar gitter-badger avatar htoooth avatar zhenyong avatar tingyinhelen avatar gcaufy avatar lpmi-13 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.