forked from fishcg/acfun-live-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
44 lines (39 loc) · 1.28 KB
/
server.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
const { timingTask } = require('./lib/Utils')
const bot = require('./component/QQBot')
const liveBot = require('./tasks/liveBot')
// QQ 消息类型
const QQ_MESSAGE_TYPE_PRIVATE = 'private'
const QQ_MESSAGE_TYPE_GROUP = 'group'
// 监听 QQ 信息
bot.on('message', async context => {
if (context.message_type === QQ_MESSAGE_TYPE_GROUP && bot.isAtMe(context)) {
// 对群消息中 @bot 的消息进行处理
let groupQQ = context.group_id
let replay = await getGroupReplay(context)
if (!replay) {
return
}
bot('send_group_msg', {
group_id: groupQQ,
message: replay,
})
} else if (context.message_type === QQ_MESSAGE_TYPE_PRIVATE && context.message === '233') {
// 对群消息中 @bot 的消息进行处理
// NOTICE: 目前仅进行 DEBUG,输入“233”时回应“success”
console.log('test msg: ' + context.message)
let message = `success`
bot('send_msg', {
...context,
message: message,
})
}
})
async function getGroupReplay(context) {
// NOTICE: 目前仅对直播消息进行回复
return await liveBot.getReplay(context)
}
// 每 30 秒检测是否开播
console.log('qqbot live status check is start')
timingTask(liveBot.liveStatusCheck, 30)
bot.listen(5701)
console.log('qqbot listen in 5701')