forked from isnl/wechat-robot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
37 lines (35 loc) · 949 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
* @Author: Peanut
* @Description: 实例化 - 入口文件
* @Date: 2020-05-19 21:55:04
* @Last Modified by: Peanut.ZhangHuan
* @Last Modified time: 2022-10-19 09:17:49
*/
const { WechatyBuilder } = require("wechaty");
const onScan = require("./listeners/on-scan.js");
const onLogin = require("./listeners/on-login.js");
const onMessage = require("./listeners/on-message.js");
const onFriendship = require("./listeners/on-friendship.js");
const bot = WechatyBuilder.build({
name: "wechat-bot",
puppet: "wechaty-puppet-wechat",
puppetOptions: {
uos: true,
},
});
bot.on("login", async user => {
onLogin(user, bot);
});
bot.on("message", async msg => {
onMessage(msg, bot);
});
bot.on("scan", async (qrcode, status) => {
onScan(qrcode, status);
});
bot.on("friendship", async friendship => {
onFriendship(friendship);
});
bot
.start()
.then(() => console.log("开始登陆微信"))
.catch(e => console.error(e));