-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathindex.js
51 lines (46 loc) · 998 Bytes
/
index.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
const service = require('./service')
const WHITE_LIST = [
'热搜',
'微博',
'微博热搜',
'WB',
'RS',
'WBRS',
'WEIBO',
'RESOU',
'WEIBORESOU',
]
module.exports = options => {
return async ({ data, ws, http }) => {
if (!data.message) {
return
}
let [message, ...search] = data.message.toUpperCase().trim().split(/\s+/)
if (!WHITE_LIST.includes(message)) {
return
}
search = search.join(' ')
if (data.message_type === 'group') {
ws.send('send_group_msg', {
group_id: data.group_id,
message: [
{
type: 'reply',
data: {
id: data.message_id,
},
},
...(await service.getList(search, options)),
],
})
return
}
if (data.message_type === 'private') {
ws.send('send_private_msg', {
user_id: data.user_id,
message: await service.getList(search, options),
})
return
}
}
}