-
Notifications
You must be signed in to change notification settings - Fork 1
/
script.js
57 lines (50 loc) · 1.41 KB
/
script.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// JavaScript source code
/**
* Wechaty - WeChat Bot SDK for Personal Account, Powered by TypeScript, Docker, and 💖
* - https://github.com/chatie/wechaty
*/
const {
Wechaty,
ScanStatus,
log,
} = require('wechaty')
import { PuppetLark } from './puppet-lark'
let puppet = new PuppetLark({
larkServer: {
host: "https://8b3e657df21c.ngrok.io",
port: 80
}
})
function onLogin(user) {
log.info('StarterBot', '%s login', user)
}
function onLogout(user) {
log.info('StarterBot', '%s logout', user)
}
async function onMessage(msg) {
log.info('StarterBot', msg.toString())
}
const bot = new Wechaty({
name: 'ding-dong-bot',
/**
* Specify a puppet for a specific protocol (Web/Pad/Mac/Windows, etc).
*
* You can use the following providers:
* - wechaty-puppet-hostie
* - wechaty-puppet-puppeteer
* - wechaty-puppet-padplus
* - wechaty-puppet-macpro
* - etc.
*
* Learn more about Wechaty Puppet Providers at:
* https://github.com/wechaty/wechaty-puppet/wiki/Directory
*/
puppet: puppet,
// Set as above, or set using environment variable WECHATY_PUPPET
})
bot.on('login', onLogin)
bot.on('logout', onLogout)
bot.on('message', onMessage)
bot.start()
.then(() => log.info('StarterBot', 'Starter Bot Started.'))
.catch(e => log.error('StarterBot', e))