Now the wechat community is hot, and as a group administrator, can not manage the community all the time

I found something very interesting by accidentwechaty


Looking at the Github homepage of this project, I was moved to tears. It only takes 6 lines of code to run a wechat robot!


Git clone, install dependencies, and run the project

Run very successful, everything is very smooth, no accident, run successful, you can scan the code to log in

But then something happened

There is no way, wechat blocked the way to log in the web page

But don’t panic, there must be another way

Wechaty-puppet-padplus was developed by wechaty. It is based on the iPad protocol

At this point, pull the new warehouse, run demo, you can run successfully


Short code to initialize our bot

// initialize const bot = new Wechaty({puppet: new PuppetPadplus({token: config.token}), name: config.name})Copy the code

And then a chain call, listen, start, done

const onScan = require("./onScan") const onRoomJoin = require("./onRoomJoin") const onMessage = require("./onMessage") Const onFriendShip = require("./onFriendShip") bot. On ("scan", onScan) // when the robot needs to scan the QR code, listen. OnRoomJoin) // Join room listener. On ("message", onMessage(bot)) // Message listener. On ("friendship", onFriendShipCopy the code

I’m just going to briefly explain these event listeners, because there’s nothing to say, it’s all documented in the API