-
Notifications
You must be signed in to change notification settings - Fork 41
/
index.js
42 lines (36 loc) · 857 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
const service = require('./service')
const pattern = /^(JJ|基金)\s+/i
module.exports = options => {
return async ({ data, ws, http }) => {
if (!data.message) {
return
}
let message = data.message.trim()
if (!pattern.test(message)) {
return
}
message = message.replace(pattern, '').trim()
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.getFund(message))
]
})
return
}
if (data.message_type === 'private') {
ws.send('send_private_msg', {
user_id: data.user_id,
message: await service.getFund(message)
})
return
}
}
}