node-karin 0.12.0 → 0.12.2-5.pr.206.027f2f2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1029 -0
- package/default/comment/config.json +34 -0
- package/default/comment/friendDirect.json +10 -0
- package/default/comment/groupGuild.json +11 -0
- package/default/comment/server.json +17 -0
- package/default/config/adapter.json +28 -0
- package/default/config/config.json +47 -0
- package/default/config/groups.json +47 -0
- package/default/config/groups.yaml +70 -0
- package/default/config/pm2.json +16 -0
- package/default/config/privates.json +23 -0
- package/default/config/privates.yaml +31 -0
- package/default/config/redis.json +10 -0
- package/default/config/render.json +19 -0
- package/default/view/group.yaml +73 -0
- package/dist/index.d.ts +9869 -0
- package/dist/index.js +12643 -0
- package/dist/module/art-template.cjs +11 -0
- package/dist/module/art-template.d.ts +1 -0
- package/dist/module/axios.cjs +22 -0
- package/dist/module/axios.d.ts +2 -0
- package/dist/module/chalk.cjs +22 -0
- package/dist/module/chalk.d.ts +2 -0
- package/dist/module/chokidar.cjs +22 -0
- package/dist/module/chokidar.d.ts +2 -0
- package/dist/module/commander.cjs +35 -0
- package/dist/module/commander.d.ts +3 -0
- package/dist/module/commander.js +3 -0
- package/dist/module/dotenv.cjs +22 -0
- package/dist/module/dotenv.d.ts +2 -0
- package/dist/module/dotenv.js +2 -0
- package/dist/module/express.cjs +112 -0
- package/dist/module/express.d.ts +1 -0
- package/dist/module/express.js +1 -0
- package/dist/module/level.cjs +22 -0
- package/dist/module/level.d.ts +2 -0
- package/dist/module/lodash.cjs +11 -0
- package/dist/module/lodash.d.ts +1 -0
- package/dist/module/log4js.cjs +22 -0
- package/dist/module/log4js.d.ts +2 -0
- package/dist/module/moment.cjs +11 -0
- package/dist/module/moment.d.ts +1 -0
- package/dist/module/node-schedule.cjs +22 -0
- package/dist/module/node-schedule.d.ts +2 -0
- package/dist/module/redis.cjs +22 -0
- package/dist/module/redis.d.ts +2 -0
- package/dist/module/ws.cjs +28 -0
- package/dist/module/ws.d.ts +1 -0
- package/dist/module/ws.js +1 -0
- package/dist/module/yaml.cjs +22 -0
- package/dist/module/yaml.d.ts +2 -0
- package/dist/root.d.ts +40 -0
- package/dist/root.js +44 -0
- package/package.json +142 -128
- package/LICENSE +0 -674
- package/README.md +0 -56
- package/config/defSet/App.yaml +0 -42
- package/config/defSet/config.yaml +0 -65
- package/config/defSet/group.yaml +0 -56
- package/config/defSet/pm2.yaml +0 -21
- package/config/defSet/redis.yaml +0 -18
- package/config/defSet/server.yaml +0 -42
- package/config/view/group.yaml +0 -92
- package/lib/adapter/index.d.ts +0 -2
- package/lib/adapter/index.js +0 -2
- package/lib/adapter/input/index.d.ts +0 -78
- package/lib/adapter/input/index.js +0 -205
- package/lib/adapter/onebot/11/convert.d.ts +0 -12
- package/lib/adapter/onebot/11/convert.js +0 -167
- package/lib/adapter/onebot/11/event.d.ts +0 -25
- package/lib/adapter/onebot/11/event.js +0 -442
- package/lib/adapter/onebot/11/index.d.ts +0 -508
- package/lib/adapter/onebot/11/index.js +0 -1047
- package/lib/cli/index.d.ts +0 -92
- package/lib/cli/index.js +0 -307
- package/lib/cli/init.d.ts +0 -2
- package/lib/cli/init.js +0 -22
- package/lib/cli/karin.d.ts +0 -2
- package/lib/cli/karin.js +0 -16
- package/lib/cli/pkg.d.ts +0 -4
- package/lib/cli/pkg.js +0 -14
- package/lib/cli/start.d.ts +0 -1
- package/lib/cli/start.js +0 -8
- package/lib/core/index.d.ts +0 -10
- package/lib/core/index.js +0 -10
- package/lib/core/init/config.d.ts +0 -43
- package/lib/core/init/config.js +0 -201
- package/lib/core/init/dir.d.ts +0 -4
- package/lib/core/init/dir.js +0 -7
- package/lib/core/init/init.d.ts +0 -1
- package/lib/core/init/init.js +0 -47
- package/lib/core/karin/karin.d.ts +0 -198
- package/lib/core/karin/karin.js +0 -226
- package/lib/core/listener/listener.d.ts +0 -145
- package/lib/core/listener/listener.js +0 -235
- package/lib/core/plugin/base.d.ts +0 -156
- package/lib/core/plugin/base.js +0 -131
- package/lib/core/plugin/loader.d.ts +0 -141
- package/lib/core/plugin/loader.js +0 -618
- package/lib/core/process/process.d.ts +0 -18
- package/lib/core/process/process.js +0 -96
- package/lib/core/server/server.d.ts +0 -25
- package/lib/core/server/server.js +0 -295
- package/lib/db/index.d.ts +0 -2
- package/lib/db/index.js +0 -2
- package/lib/db/level/level.d.ts +0 -19
- package/lib/db/level/level.js +0 -36
- package/lib/db/redis/redis.d.ts +0 -2
- package/lib/db/redis/redis.js +0 -135
- package/lib/db/redis/redis_level.d.ts +0 -112
- package/lib/db/redis/redis_level.js +0 -281
- package/lib/event/handler/base.d.ts +0 -42
- package/lib/event/handler/base.js +0 -200
- package/lib/event/handler/message.d.ts +0 -29
- package/lib/event/handler/message.js +0 -307
- package/lib/event/handler/notice.d.ts +0 -18
- package/lib/event/handler/notice.js +0 -214
- package/lib/event/handler/request.d.ts +0 -18
- package/lib/event/handler/request.js +0 -115
- package/lib/event/handler/review.d.ts +0 -55
- package/lib/event/handler/review.js +0 -386
- package/lib/event/index.d.ts +0 -5
- package/lib/event/index.js +0 -5
- package/lib/index.d.ts +0 -8
- package/lib/index.js +0 -8
- package/lib/modules/art-template.d.ts +0 -1
- package/lib/modules/axios.d.ts +0 -2
- package/lib/modules/chalk.d.ts +0 -2
- package/lib/modules/chokidar.d.ts +0 -2
- package/lib/modules/commander.d.ts +0 -2
- package/lib/modules/commander.js +0 -2
- package/lib/modules/express.d.ts +0 -3
- package/lib/modules/express.js +0 -3
- package/lib/modules/level.d.ts +0 -2
- package/lib/modules/lodash.d.ts +0 -1
- package/lib/modules/log4js.d.ts +0 -2
- package/lib/modules/moment.d.ts +0 -1
- package/lib/modules/node-schedule.d.ts +0 -2
- package/lib/modules/redis.d.ts +0 -2
- package/lib/modules/ws.d.ts +0 -3
- package/lib/modules/ws.js +0 -3
- package/lib/modules/yaml.d.ts +0 -2
- package/lib/modules.d.ts +0 -15
- package/lib/modules.js +0 -15
- package/lib/render/app.d.ts +0 -56
- package/lib/render/app.js +0 -120
- package/lib/render/base.d.ts +0 -30
- package/lib/render/base.js +0 -69
- package/lib/render/client.d.ts +0 -41
- package/lib/render/client.js +0 -238
- package/lib/render/http.d.ts +0 -19
- package/lib/render/http.js +0 -50
- package/lib/render/index.d.ts +0 -6
- package/lib/render/index.js +0 -6
- package/lib/render/server.d.ts +0 -25
- package/lib/render/server.js +0 -101
- package/lib/render/wormhole.d.ts +0 -1
- package/lib/render/wormhole.js +0 -156
- package/lib/types/adapter/api.d.ts +0 -399
- package/lib/types/adapter/api.js +0 -1
- package/lib/types/adapter/base.d.ts +0 -560
- package/lib/types/adapter/base.js +0 -1
- package/lib/types/config/config.d.ts +0 -379
- package/lib/types/config/config.js +0 -1
- package/lib/types/element/element.d.ts +0 -565
- package/lib/types/element/element.js +0 -1
- package/lib/types/element/qqbot.d.ts +0 -123
- package/lib/types/element/qqbot.js +0 -1
- package/lib/types/event/contact.d.ts +0 -28
- package/lib/types/event/contact.js +0 -1
- package/lib/types/event/event.d.ts +0 -305
- package/lib/types/event/event.js +0 -1
- package/lib/types/event/index.d.ts +0 -12
- package/lib/types/event/index.js +0 -7
- package/lib/types/event/message.d.ts +0 -109
- package/lib/types/event/message.js +0 -74
- package/lib/types/event/notice.d.ts +0 -513
- package/lib/types/event/notice.js +0 -52
- package/lib/types/event/reply.d.ts +0 -50
- package/lib/types/event/reply.js +0 -1
- package/lib/types/event/request.d.ts +0 -126
- package/lib/types/event/request.js +0 -52
- package/lib/types/event/sender.d.ts +0 -44
- package/lib/types/event/sender.js +0 -1
- package/lib/types/index.d.ts +0 -13
- package/lib/types/index.js +0 -13
- package/lib/types/logger/logger.d.ts +0 -110
- package/lib/types/logger/logger.js +0 -1
- package/lib/types/onebot11/api.d.ts +0 -53
- package/lib/types/onebot11/api.js +0 -1
- package/lib/types/onebot11/event.d.ts +0 -619
- package/lib/types/onebot11/event.js +0 -2
- package/lib/types/onebot11/index.d.ts +0 -6
- package/lib/types/onebot11/index.js +0 -6
- package/lib/types/onebot11/params.d.ts +0 -609
- package/lib/types/onebot11/params.js +0 -1
- package/lib/types/onebot11/response.d.ts +0 -516
- package/lib/types/onebot11/response.js +0 -1
- package/lib/types/onebot11/segment.d.ts +0 -269
- package/lib/types/onebot11/segment.js +0 -1
- package/lib/types/onebot11/sender.d.ts +0 -59
- package/lib/types/onebot11/sender.js +0 -1
- package/lib/types/plugin/app.d.ts +0 -71
- package/lib/types/plugin/app.js +0 -1
- package/lib/types/plugin/plugin.d.ts +0 -473
- package/lib/types/plugin/plugin.js +0 -1
- package/lib/types/render/render.d.ts +0 -118
- package/lib/types/render/render.js +0 -1
- package/lib/types/type/global.d.ts +0 -25
- package/lib/types/type/global.js +0 -1
- package/lib/utils/common/common.d.ts +0 -236
- package/lib/utils/common/common.js +0 -708
- package/lib/utils/config/config.d.ts +0 -193
- package/lib/utils/config/config.js +0 -328
- package/lib/utils/config/updateVersion.d.ts +0 -33
- package/lib/utils/config/updateVersion.js +0 -145
- package/lib/utils/config/yamlEditor.d.ts +0 -101
- package/lib/utils/config/yamlEditor.js +0 -330
- package/lib/utils/core/handler.d.ts +0 -18
- package/lib/utils/core/handler.js +0 -46
- package/lib/utils/core/logger.d.ts +0 -3
- package/lib/utils/core/logger.js +0 -105
- package/lib/utils/core/segment.d.ts +0 -279
- package/lib/utils/core/segment.js +0 -451
- package/lib/utils/index.d.ts +0 -13
- package/lib/utils/index.js +0 -13
- package/lib/utils/tools/button.d.ts +0 -2
- package/lib/utils/tools/button.js +0 -27
- package/lib/utils/tools/exec.d.ts +0 -20
- package/lib/utils/tools/exec.js +0 -54
- package/lib/utils/tools/ffmpeg.d.ts +0 -12
- package/lib/utils/tools/ffmpeg.js +0 -25
- package/lib/utils/tools/restart.d.ts +0 -15
- package/lib/utils/tools/restart.js +0 -39
- package/lib/utils/tools/stop.d.ts +0 -7
- package/lib/utils/tools/stop.js +0 -13
- package/lib/utils/tools/update.d.ts +0 -67
- package/lib/utils/tools/update.js +0 -151
- /package/{config → default}/view/App.yaml +0 -0
- /package/{config → default}/view/config.yaml +0 -0
- /package/{config → default}/view/pm2.yaml +0 -0
- /package/{config → default}/view/redis.yaml +0 -0
- /package/{config → default}/view/server.yaml +0 -0
- /package/{lib/modules → dist/module}/art-template.js +0 -0
- /package/{lib/modules → dist/module}/axios.js +0 -0
- /package/{lib/modules → dist/module}/chalk.js +0 -0
- /package/{lib/modules → dist/module}/chokidar.js +0 -0
- /package/{lib/modules → dist/module}/level.js +0 -0
- /package/{lib/modules → dist/module}/lodash.js +0 -0
- /package/{lib/modules → dist/module}/log4js.js +0 -0
- /package/{lib/modules → dist/module}/moment.js +0 -0
- /package/{lib/modules → dist/module}/node-schedule.js +0 -0
- /package/{lib/modules → dist/module}/redis.js +0 -0
- /package/{lib/modules → dist/module}/yaml.js +0 -0
|
@@ -1,307 +0,0 @@
|
|
|
1
|
-
import lodash from 'lodash';
|
|
2
|
-
import { review } from './review.js';
|
|
3
|
-
import { EventBaseHandler } from './base.js';
|
|
4
|
-
import { logger, config } from '../../utils/index.js';
|
|
5
|
-
import { karin, stateArr, pluginLoader } from '../../core/index.js';
|
|
6
|
-
/**
|
|
7
|
-
* 消息事件
|
|
8
|
-
*/
|
|
9
|
-
export class MessageHandler extends EventBaseHandler {
|
|
10
|
-
e;
|
|
11
|
-
constructor(e) {
|
|
12
|
-
super(e);
|
|
13
|
-
this.e = e;
|
|
14
|
-
this.init();
|
|
15
|
-
if (this.e.group_id) {
|
|
16
|
-
if (!this.getCd())
|
|
17
|
-
return;
|
|
18
|
-
if (!this.getMode())
|
|
19
|
-
return;
|
|
20
|
-
if (!this.getGroupEnable())
|
|
21
|
-
return;
|
|
22
|
-
if (!this.getUserEnable())
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
if (!this.private())
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
/** 处理消息 */
|
|
30
|
-
this.deal();
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* 先对消息事件进行初始化
|
|
34
|
-
*/
|
|
35
|
-
init() {
|
|
36
|
-
karin.emit('karin:count:recv', 1);
|
|
37
|
-
const logs = [];
|
|
38
|
-
for (const val of this.e.elements) {
|
|
39
|
-
switch (val.type) {
|
|
40
|
-
case 'text': {
|
|
41
|
-
const msg = (val.text || '').replace(/^\s*[#井#]+\s*/, '#').trim();
|
|
42
|
-
this.e.msg += msg;
|
|
43
|
-
logs.push(msg);
|
|
44
|
-
break;
|
|
45
|
-
}
|
|
46
|
-
case 'face':
|
|
47
|
-
logs.push(`[face:${val.id}]`);
|
|
48
|
-
break;
|
|
49
|
-
case 'video':
|
|
50
|
-
logs.push(`[video:${val.file}]`);
|
|
51
|
-
break;
|
|
52
|
-
case 'record':
|
|
53
|
-
this.e.record = val.file;
|
|
54
|
-
logs.push(`[record:${val.file}]`);
|
|
55
|
-
break;
|
|
56
|
-
case 'image':
|
|
57
|
-
this.e.image.push(val.file);
|
|
58
|
-
logs.push(`[image:${val.file}]`);
|
|
59
|
-
break;
|
|
60
|
-
case 'file':
|
|
61
|
-
this.e.file = val;
|
|
62
|
-
logs.push(`[file:${val.file}]`);
|
|
63
|
-
break;
|
|
64
|
-
case 'at':
|
|
65
|
-
/** atBot不计入e.at */
|
|
66
|
-
if (val.uid && val.uid === this.e.bot.account.uid) {
|
|
67
|
-
this.e.atBot = true;
|
|
68
|
-
}
|
|
69
|
-
else if (val.uin === this.e.bot.account.uin) {
|
|
70
|
-
this.e.atBot = true;
|
|
71
|
-
}
|
|
72
|
-
else if (val.uid && val.uid === 'all') {
|
|
73
|
-
this.e.atAll = true;
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
const id = (val.uid || val.uin);
|
|
77
|
-
this.e.at.push(id);
|
|
78
|
-
}
|
|
79
|
-
logs.push(`[at:${val.uid || val.uin}]`);
|
|
80
|
-
break;
|
|
81
|
-
case 'rps':
|
|
82
|
-
logs.push(`[rps:${val.id}]`);
|
|
83
|
-
break;
|
|
84
|
-
case 'dice':
|
|
85
|
-
logs.push(`[dice:${val.id}]`);
|
|
86
|
-
break;
|
|
87
|
-
case 'poke':
|
|
88
|
-
logs.push(`[poke:${val.id}]`);
|
|
89
|
-
break;
|
|
90
|
-
case 'share':
|
|
91
|
-
logs.push(`[share:${val.url}]`);
|
|
92
|
-
break;
|
|
93
|
-
case 'contact':
|
|
94
|
-
logs.push(`[contact:${val.peer}]`);
|
|
95
|
-
break;
|
|
96
|
-
case 'location':
|
|
97
|
-
logs.push(`[location:${val.lat}-${val.lon}]`);
|
|
98
|
-
break;
|
|
99
|
-
case 'music':
|
|
100
|
-
logs.push(`[music:${JSON.stringify(val)}]`);
|
|
101
|
-
break;
|
|
102
|
-
case 'reply':
|
|
103
|
-
this.e.reply_id = val.message_id;
|
|
104
|
-
logs.push(`[reply:${val.message_id}]`);
|
|
105
|
-
break;
|
|
106
|
-
case 'forward':
|
|
107
|
-
logs.push(`[forward:${val.res_id}]`);
|
|
108
|
-
break;
|
|
109
|
-
case 'xml':
|
|
110
|
-
this.e.msg += val.data;
|
|
111
|
-
logs.push(`[xml:${val.data}]`);
|
|
112
|
-
break;
|
|
113
|
-
case 'json':
|
|
114
|
-
this.e.msg += val.data;
|
|
115
|
-
logs.push(`[json:${JSON.stringify(val.data)}]`);
|
|
116
|
-
break;
|
|
117
|
-
case 'markdown': {
|
|
118
|
-
logs.push(`[markdown:${val.content}]`);
|
|
119
|
-
break;
|
|
120
|
-
}
|
|
121
|
-
case 'markdown_tpl': {
|
|
122
|
-
const params = val.params;
|
|
123
|
-
if (!params)
|
|
124
|
-
break;
|
|
125
|
-
const content = { id: val.custom_template_id };
|
|
126
|
-
for (const v of params)
|
|
127
|
-
content[v.key] = v.values[0];
|
|
128
|
-
logs.push(`[markdown_tpl:${JSON.stringify(content)}]`);
|
|
129
|
-
break;
|
|
130
|
-
}
|
|
131
|
-
case 'keyboard': {
|
|
132
|
-
logs.push(`[rows:${JSON.stringify(val.rows)}]`);
|
|
133
|
-
break;
|
|
134
|
-
}
|
|
135
|
-
case 'button':
|
|
136
|
-
logs.push(`[button:${JSON.stringify(val.data)}]`);
|
|
137
|
-
break;
|
|
138
|
-
case 'long_msg':
|
|
139
|
-
logs.push(`[long_msg:${val.id}]`);
|
|
140
|
-
break;
|
|
141
|
-
default:
|
|
142
|
-
logs.push(`[未知:${JSON.stringify(val)}]`);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
this.e.raw_message = logs.join('');
|
|
146
|
-
/** 主人 */
|
|
147
|
-
if (config.master.includes(String(this.e.user_id))) {
|
|
148
|
-
this.e.isMaster = true;
|
|
149
|
-
this.e.isAdmin = true;
|
|
150
|
-
}
|
|
151
|
-
else if (config.admin.includes(String(this.e.user_id))) {
|
|
152
|
-
/** 管理员 */
|
|
153
|
-
this.e.isAdmin = true;
|
|
154
|
-
}
|
|
155
|
-
if (this.e.contact.scene === 'friend') {
|
|
156
|
-
this.e.isPrivate = true;
|
|
157
|
-
this.e.logText = `[Private:${this.e.sender.nick || ''}(${this.e.user_id})]`;
|
|
158
|
-
logger.bot('info', this.e.self_id, `私聊:[${this.e.user_id}(${this.e.sender.nick || ''})] ${this.e.raw_message}`);
|
|
159
|
-
}
|
|
160
|
-
else if (this.e.contact.scene === 'group') {
|
|
161
|
-
this.e.isGroup = true;
|
|
162
|
-
this.e.logText = `[Group:${this.e.group_id}-${this.e.user_id}(${this.e.sender.nick || ''})]`;
|
|
163
|
-
this.GroupMsgPrint = review.GroupMsgPrint(this.e);
|
|
164
|
-
/** 前缀处理 */
|
|
165
|
-
this.e.group_id && review.alias(this.e, this.config);
|
|
166
|
-
this.GroupMsgPrint && logger.bot('info', this.e.self_id, `群消息:[${this.e.group_id}-${this.e.user_id}(${this.e.sender.nick || ''})] ${this.e.raw_message}`);
|
|
167
|
-
}
|
|
168
|
-
else if (this.e.contact.scene === 'guild') {
|
|
169
|
-
this.e.isGuild = true;
|
|
170
|
-
this.e.logText = `[Guild:${this.e.contact.peer}-${this.e.contact.sub_peer}-${this.e.user_id}(${this.e.sender.nick || ''})]`;
|
|
171
|
-
logger.bot('info', this.e.self_id, `频道消息:[${this.e.contact.peer}-${this.e.contact.sub_peer}-${this.e.user_id}(${this.e.sender.nick || ''})] ${this.e.raw_message}`);
|
|
172
|
-
}
|
|
173
|
-
else {
|
|
174
|
-
logger.bot('info', this.e.self_id, `未知消息:${JSON.stringify(this.e)}`);
|
|
175
|
-
}
|
|
176
|
-
logs.length = 0;
|
|
177
|
-
this.reply();
|
|
178
|
-
karin.emit('message', this.e);
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* 响应模式检查 返回false表示未通过
|
|
182
|
-
*/
|
|
183
|
-
getMode() {
|
|
184
|
-
if (review.mode(this.e, this.config))
|
|
185
|
-
return true;
|
|
186
|
-
logger.debug(`[消息拦截][${this.e.group_id}][${this.e.user_id}] 响应模式不匹配`);
|
|
187
|
-
return false;
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* 打印
|
|
191
|
-
*/
|
|
192
|
-
print() {
|
|
193
|
-
}
|
|
194
|
-
/**
|
|
195
|
-
* 处理消息
|
|
196
|
-
*/
|
|
197
|
-
async deal() {
|
|
198
|
-
/** 先调用中间件 */
|
|
199
|
-
for (const info of pluginLoader.use.recvMsg) {
|
|
200
|
-
try {
|
|
201
|
-
let next = false;
|
|
202
|
-
let exit = false;
|
|
203
|
-
const nextFn = () => { next = true; };
|
|
204
|
-
const exitFn = () => { exit = true; };
|
|
205
|
-
await info.fn(this.e, nextFn, exitFn);
|
|
206
|
-
if (exit) {
|
|
207
|
-
const plugin = pluginLoader.plugin.get(info.key);
|
|
208
|
-
logger.debug(`[消息中间件][${plugin.plugin}][${plugin.file}] 主动操作退出`);
|
|
209
|
-
return;
|
|
210
|
-
}
|
|
211
|
-
if (!next)
|
|
212
|
-
break;
|
|
213
|
-
}
|
|
214
|
-
catch (e) {
|
|
215
|
-
logger.error('[消息中间件] 调用失败,已跳过');
|
|
216
|
-
logger.error(e);
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
/** 上下文 */
|
|
220
|
-
if (await this.context())
|
|
221
|
-
return;
|
|
222
|
-
const app = this.e.group_id
|
|
223
|
-
? (info) => review.PluginEnable(info, this.config)
|
|
224
|
-
: () => true;
|
|
225
|
-
for (const info of pluginLoader.command) {
|
|
226
|
-
/** 判断事件 */
|
|
227
|
-
if (!this.filtEvent(info.event))
|
|
228
|
-
continue;
|
|
229
|
-
const reg = info.reg;
|
|
230
|
-
if (reg.test(this.e.msg)) {
|
|
231
|
-
/** 检查黑白名单插件 */
|
|
232
|
-
if (!app(info))
|
|
233
|
-
continue;
|
|
234
|
-
/** 判断子事件 */
|
|
235
|
-
if (!this.filtEvent(info.event))
|
|
236
|
-
continue;
|
|
237
|
-
this.e.logFnc = `[${info.name}][${info.fnname}]`;
|
|
238
|
-
const logFnc = logger.fnc(this.e.logFnc);
|
|
239
|
-
this.GroupMsgPrint && info.log(this.e.self_id, `${logFnc}${this.e.logText} ${lodash.truncate(this.e.msg, { length: 80 })}`);
|
|
240
|
-
/** 判断权限 */
|
|
241
|
-
if (!this.filterPermission(info.perm))
|
|
242
|
-
continue;
|
|
243
|
-
/** 计算插件处理时间 */
|
|
244
|
-
const start = Date.now();
|
|
245
|
-
karin.emit('karin:count:fnc', this.e.logFnc);
|
|
246
|
-
try {
|
|
247
|
-
let res;
|
|
248
|
-
if (info.type === 'function') {
|
|
249
|
-
res = await info.fn(this.e);
|
|
250
|
-
}
|
|
251
|
-
else {
|
|
252
|
-
const Fnc = info.data;
|
|
253
|
-
const app = new Fnc();
|
|
254
|
-
app.e = this.e;
|
|
255
|
-
res = await info.fn.call(app, this.e);
|
|
256
|
-
}
|
|
257
|
-
this.GroupMsgPrint && info.log(this.e.self_id, `${logFnc} ${lodash.truncate(this.e.msg, { length: 80 })} 处理完成 ${logger.green(Date.now() - start + 'ms')}`);
|
|
258
|
-
if (res === false)
|
|
259
|
-
continue;
|
|
260
|
-
return;
|
|
261
|
-
}
|
|
262
|
-
catch (error) {
|
|
263
|
-
logger.error(`${this.e.logFnc}`);
|
|
264
|
-
logger.error(error.stack || error.message || JSON.stringify(error));
|
|
265
|
-
return;
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
/**
|
|
271
|
-
* 处理上下文
|
|
272
|
-
*/
|
|
273
|
-
async context() {
|
|
274
|
-
const key = this.e.isGroup ? `${this.e.group_id}.${this.e.user_id}` : this.e.user_id;
|
|
275
|
-
const App = stateArr[key];
|
|
276
|
-
if (App) {
|
|
277
|
-
switch (App.type) {
|
|
278
|
-
case 'ctx': {
|
|
279
|
-
karin.emit(`ctx:${key}`, this.e);
|
|
280
|
-
delete stateArr[key];
|
|
281
|
-
return true;
|
|
282
|
-
}
|
|
283
|
-
case 'class': {
|
|
284
|
-
const { fnc, name } = App;
|
|
285
|
-
this.e.logFnc = `[${fnc.name}][${name}]`;
|
|
286
|
-
/** 计算插件处理时间 */
|
|
287
|
-
const start = Date.now();
|
|
288
|
-
fnc.e = this.e;
|
|
289
|
-
await fnc[name]();
|
|
290
|
-
logger.bot('mark', this.e.self_id, `${this.e.logFnc} 上下文处理完成 ${Date.now() - start}ms`);
|
|
291
|
-
return true;
|
|
292
|
-
}
|
|
293
|
-
case 'fnc': {
|
|
294
|
-
const { fnc } = App;
|
|
295
|
-
this.e.logFnc = `[${fnc.name}]`;
|
|
296
|
-
/** 计算插件处理时间 */
|
|
297
|
-
const start = Date.now();
|
|
298
|
-
await fnc(this.e);
|
|
299
|
-
logger.bot('mark', this.e.self_id, `${this.e.logFnc} 上下文处理完成 ${Date.now() - start}ms`);
|
|
300
|
-
delete stateArr[key];
|
|
301
|
-
return true;
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
return false;
|
|
306
|
-
}
|
|
307
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { EventBaseHandler } from './base.js';
|
|
2
|
-
import { KarinNoticeType } from '../../types/index.js';
|
|
3
|
-
/**
|
|
4
|
-
* 通知事件
|
|
5
|
-
*/
|
|
6
|
-
export declare class NoticeHandler extends EventBaseHandler {
|
|
7
|
-
e: KarinNoticeType;
|
|
8
|
-
constructor(e: KarinNoticeType);
|
|
9
|
-
init(): void;
|
|
10
|
-
/**
|
|
11
|
-
* 处理事件
|
|
12
|
-
*/
|
|
13
|
-
deal(): Promise<void>;
|
|
14
|
-
/**
|
|
15
|
-
* 构建原始消息
|
|
16
|
-
*/
|
|
17
|
-
raw_message(): void;
|
|
18
|
-
}
|
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
import { review } from './review.js';
|
|
2
|
-
import { EventBaseHandler } from './base.js';
|
|
3
|
-
import { logger, config } from '../../utils/index.js';
|
|
4
|
-
import { karin, pluginLoader } from '../../core/index.js';
|
|
5
|
-
/**
|
|
6
|
-
* 通知事件
|
|
7
|
-
*/
|
|
8
|
-
export class NoticeHandler extends EventBaseHandler {
|
|
9
|
-
e;
|
|
10
|
-
constructor(e) {
|
|
11
|
-
super(e);
|
|
12
|
-
this.e = e;
|
|
13
|
-
this.init();
|
|
14
|
-
if (this.e.group_id) {
|
|
15
|
-
if (!this.getCd())
|
|
16
|
-
return;
|
|
17
|
-
if (!this.getGroupEnable())
|
|
18
|
-
return;
|
|
19
|
-
if (!this.getUserEnable())
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
if (!this.private())
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
/** 处理消息 */
|
|
27
|
-
this.deal();
|
|
28
|
-
}
|
|
29
|
-
init() {
|
|
30
|
-
this.raw_message();
|
|
31
|
-
/** 主人 */
|
|
32
|
-
if (config.master.includes(String(this.e.user_id))) {
|
|
33
|
-
this.e.isMaster = true;
|
|
34
|
-
this.e.isAdmin = true;
|
|
35
|
-
}
|
|
36
|
-
else if (config.admin.includes(String(this.e.user_id))) {
|
|
37
|
-
/** 管理员 */
|
|
38
|
-
this.e.isAdmin = true;
|
|
39
|
-
}
|
|
40
|
-
if (this.e.contact.scene === 'friend') {
|
|
41
|
-
this.e.isPrivate = true;
|
|
42
|
-
this.e.logText = `[Private:${this.e.sender.nick || ''}(${this.e.user_id})]`;
|
|
43
|
-
logger.bot('info', this.e.self_id, `${logger.green('私聊通知: ')}[${this.e.user_id}(${this.e.sender.nick || ''})] ${this.e.raw_message}`);
|
|
44
|
-
}
|
|
45
|
-
else if (this.e.contact.scene === 'group') {
|
|
46
|
-
this.e.isGroup = true;
|
|
47
|
-
this.e.logText = `[Group:${this.e.group_id}-${this.e.user_id}(${this.e.sender.nick || ''})]`;
|
|
48
|
-
this.GroupMsgPrint = review.GroupMsgPrint(this.e);
|
|
49
|
-
this.GroupMsgPrint && logger.bot('info', this.e.self_id, `${logger.green('群通知: ')}[${this.e.group_id}-${this.e.user_id}(${this.e.sender.nick || ''})] ${this.e.raw_message}`);
|
|
50
|
-
}
|
|
51
|
-
else if (this.e.contact.scene === 'guild') {
|
|
52
|
-
this.e.isGuild = true;
|
|
53
|
-
this.e.logText = `[Guild:${this.e.contact.peer}-${this.e.contact.sub_peer}-${this.e.user_id}(${this.e.sender.nick || ''})]`;
|
|
54
|
-
logger.bot('info', this.e.self_id, `${logger.green('频道通知: ')}[${this.e.contact.peer}-${this.e.contact.sub_peer}-${this.e.user_id}(${this.e.sender.nick || ''})] ${this.e.raw_message}`);
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
logger.bot('info', this.e.self_id, `未知来源通知事件:${JSON.stringify(this.e)}`);
|
|
58
|
-
}
|
|
59
|
-
this.reply();
|
|
60
|
-
karin.emit('notice', this.e);
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* 处理事件
|
|
64
|
-
*/
|
|
65
|
-
async deal() {
|
|
66
|
-
for (const info of pluginLoader.accept) {
|
|
67
|
-
/** 判断事件 */
|
|
68
|
-
if (!this.filtEvent(info.event))
|
|
69
|
-
continue;
|
|
70
|
-
/** 检查黑白名单插件 */
|
|
71
|
-
if (!review.PluginEnable(info, this.config))
|
|
72
|
-
continue;
|
|
73
|
-
/** 日志方法字符串 */
|
|
74
|
-
this.e.logFnc = `[${info.name}][accept]`;
|
|
75
|
-
const logFnc = logger.fnc(this.e.logFnc + `[${this.e.event}.${this.e.sub_event}]`);
|
|
76
|
-
this.GroupMsgPrint && info.log(this.e.self_id, `${logFnc + this.e.logText} 开始处理`);
|
|
77
|
-
/** 计算插件处理时间 */
|
|
78
|
-
const start = Date.now();
|
|
79
|
-
try {
|
|
80
|
-
const res = await info.fn(this.e);
|
|
81
|
-
this.GroupMsgPrint && info.log(this.e.self_id, `${logFnc} 处理完成 ${logger.green(Date.now() - start + 'ms')}`);
|
|
82
|
-
if (res !== false)
|
|
83
|
-
break;
|
|
84
|
-
}
|
|
85
|
-
catch (error) {
|
|
86
|
-
logger.error(`${logFnc}`);
|
|
87
|
-
logger.error(error.stack || error.message || JSON.stringify(error));
|
|
88
|
-
break;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* 构建原始消息
|
|
94
|
-
*/
|
|
95
|
-
raw_message() {
|
|
96
|
-
switch (this.e.sub_event) {
|
|
97
|
-
/** 好友头像戳一戳 */
|
|
98
|
-
case "private_poke" /* NoticeSubType.PrivatePoke */: {
|
|
99
|
-
this.e.raw_message = '[好友戳一戳]: 戳了你一下';
|
|
100
|
-
break;
|
|
101
|
-
}
|
|
102
|
-
/** 好友消息撤回 */
|
|
103
|
-
case "private_recall" /* NoticeSubType.PrivateRecall */: {
|
|
104
|
-
this.e.raw_message = `[好友消息撤回]: ${this.e.content.message_id}`;
|
|
105
|
-
break;
|
|
106
|
-
}
|
|
107
|
-
/** 私聊文件上传 */
|
|
108
|
-
case "private_file_uploaded" /* NoticeSubType.PrivateFileUploaded */: {
|
|
109
|
-
const content = this.e.content;
|
|
110
|
-
const { file_url } = content;
|
|
111
|
-
this.e.raw_message = `[私聊文件上传]: ${file_url}`;
|
|
112
|
-
break;
|
|
113
|
-
}
|
|
114
|
-
/** 群头像戳一戳 */
|
|
115
|
-
case "group_poke" /* NoticeSubType.GroupPoke */: {
|
|
116
|
-
const { operator_uid, operator_uin, target_uid, target_uin } = this.e.content;
|
|
117
|
-
this.e.raw_message = `[群戳一戳]: ${operator_uid || operator_uin} 戳了戳 ${target_uid || target_uin}`;
|
|
118
|
-
break;
|
|
119
|
-
}
|
|
120
|
-
/** 群消息撤回 */
|
|
121
|
-
case "group_recall" /* NoticeSubType.GroupRecall */: {
|
|
122
|
-
const { operator_uid, operator_uin, message_id } = this.e.content;
|
|
123
|
-
this.e.raw_message = `[群消息撤回]: ${operator_uid || operator_uin} 撤回了一条消息 ${message_id}`;
|
|
124
|
-
break;
|
|
125
|
-
}
|
|
126
|
-
/** 群文件上传 */
|
|
127
|
-
case "group_file_uploaded" /* NoticeSubType.GroupFileUploaded */: {
|
|
128
|
-
const { file_url, operator_uid, operator_uin } = this.e.content;
|
|
129
|
-
this.e.raw_message = `[群文件上传]: ${operator_uid || operator_uin} 上传了 ${file_url}`;
|
|
130
|
-
break;
|
|
131
|
-
}
|
|
132
|
-
/** 群成员增加 */
|
|
133
|
-
case "group_member_increase" /* NoticeSubType.GroupMemberIncrease */: {
|
|
134
|
-
const { operator_uid, operator_uin, target_uid, target_uin, type } = this.e.content;
|
|
135
|
-
this.e.raw_message = `[群成员新增]: ${operator_uid || operator_uin} ${type === 'invite' ? '邀请' : '同意'} ${target_uid || target_uin} 加入群聊`;
|
|
136
|
-
break;
|
|
137
|
-
}
|
|
138
|
-
/** 群成员减少 */
|
|
139
|
-
case "group_member_decrease" /* NoticeSubType.GroupMemberDecrease */: {
|
|
140
|
-
switch (this.e.content.type) {
|
|
141
|
-
case 'leave': {
|
|
142
|
-
const { target_uid, target_uin } = this.e.content;
|
|
143
|
-
this.e.raw_message = `[群成员减少]: ${target_uid || target_uin} 主动退出群聊`;
|
|
144
|
-
break;
|
|
145
|
-
}
|
|
146
|
-
// 群成员被踢
|
|
147
|
-
case 'kick': {
|
|
148
|
-
const { operator_uid, operator_uin, target_uid, target_uin } = this.e.content;
|
|
149
|
-
this.e.raw_message = `[群成员减少]: ${operator_uid || operator_uin} 将 ${target_uid || target_uin} 踢出群聊`;
|
|
150
|
-
break;
|
|
151
|
-
}
|
|
152
|
-
// bot被踢
|
|
153
|
-
case 'kick_me': {
|
|
154
|
-
const { operator_uid, operator_uin } = this.e.content;
|
|
155
|
-
this.e.raw_message = `[群成员减少]: 机器人被移除群聊,操作人:${operator_uid || operator_uin}`;
|
|
156
|
-
break;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
break;
|
|
160
|
-
}
|
|
161
|
-
/** 群管理员变动 */
|
|
162
|
-
case "group_admin_changed" /* NoticeSubType.GroupAdminChanged */: {
|
|
163
|
-
const { target_uid, target_uin, is_admin } = this.e.content;
|
|
164
|
-
this.e.raw_message = `[群管理员变动]: ${target_uid || target_uin} 被${is_admin ? '设置' : '取消'}群管理员`;
|
|
165
|
-
break;
|
|
166
|
-
}
|
|
167
|
-
/** 群成员被禁言 */
|
|
168
|
-
case "group_member_ban" /* NoticeSubType.GroupMemberBan */: {
|
|
169
|
-
const { operator_uid, operator_uin, target_uid, target_uin, type } = this.e.content;
|
|
170
|
-
this.e.raw_message = `[群成员禁言]: ${operator_uid || operator_uin} ${type === 'ban' ? '禁言' : '解禁'}了 ${target_uid || target_uin}`;
|
|
171
|
-
break;
|
|
172
|
-
}
|
|
173
|
-
/** 群签到 */
|
|
174
|
-
case "group_sign_in" /* NoticeSubType.GroupSignIn */: {
|
|
175
|
-
const { target_uid, target_uin } = this.e.content;
|
|
176
|
-
this.e.raw_message = `[群签到]: ${target_uid || target_uin}`;
|
|
177
|
-
break;
|
|
178
|
-
}
|
|
179
|
-
/** 群全员禁言 */
|
|
180
|
-
case "group_whole_ban" /* NoticeSubType.GroupWholeBan */: {
|
|
181
|
-
const { operator_uid, operator_uin, is_ban } = this.e.content;
|
|
182
|
-
this.e.raw_message = `[群全员禁言]: ${operator_uid || operator_uin} ${is_ban ? '开启全员禁言' : '解除全员禁言'}`;
|
|
183
|
-
break;
|
|
184
|
-
}
|
|
185
|
-
/** 群名片改变 */
|
|
186
|
-
case "group_card_changed" /* NoticeSubType.GroupCardChanged */: {
|
|
187
|
-
const { operator_uid, operator_uin, target_uid, target_uin, new_card } = this.e.content;
|
|
188
|
-
this.e.raw_message = `[群名片改变]: ${operator_uid || operator_uin} 修改了 ${target_uid || target_uin} 的名片为 ${new_card}`;
|
|
189
|
-
break;
|
|
190
|
-
}
|
|
191
|
-
/** 群成员专属头衔改变 */
|
|
192
|
-
case "group_member_unique_title_changed" /* NoticeSubType.GroupMemberUniqueTitleChanged */: {
|
|
193
|
-
const { target_uid, target_uin, title } = this.e.content;
|
|
194
|
-
this.e.raw_message = `[群头衔更改]: ${target_uid || target_uin} 的专属头衔改变为 ${title}`;
|
|
195
|
-
break;
|
|
196
|
-
}
|
|
197
|
-
/** 群精华消息改变 */
|
|
198
|
-
case "group_essence_changed" /* NoticeSubType.GroupEssenceChanged */: {
|
|
199
|
-
const { operator_uid, operator_uin, target_uid, target_uin, message_id, is_set } = this.e.content;
|
|
200
|
-
this.e.raw_message = `[群精华消息]: ${operator_uid || operator_uin} ${is_set ? `将${target_uid || target_uin}的消息${message_id}设置为精华消息` : `取消了${target_uid || target_uin}精华消息 ${message_id}`}`;
|
|
201
|
-
break;
|
|
202
|
-
}
|
|
203
|
-
/** 群表情回应 */
|
|
204
|
-
case "group_message_reaction" /* NoticeSubType.GroupMessageReaction */: {
|
|
205
|
-
const { message_id, face_id } = this.e.content;
|
|
206
|
-
this.e.raw_message = `[群表情回应]: ${this.e.user_id} 给消息 ${message_id} 回应了一个${face_id}的表情`;
|
|
207
|
-
break;
|
|
208
|
-
}
|
|
209
|
-
default: {
|
|
210
|
-
this.e.raw_message = `[未知事件]: ${JSON.stringify(this.e)}`;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { EventBaseHandler } from './base.js';
|
|
2
|
-
import { KarinRequestType } from '../../types/index.js';
|
|
3
|
-
/**
|
|
4
|
-
* 请求事件
|
|
5
|
-
*/
|
|
6
|
-
export declare class RequestHandler extends EventBaseHandler {
|
|
7
|
-
e: KarinRequestType;
|
|
8
|
-
constructor(e: KarinRequestType);
|
|
9
|
-
init(): void;
|
|
10
|
-
/**
|
|
11
|
-
* 处理事件
|
|
12
|
-
*/
|
|
13
|
-
deal(): Promise<void>;
|
|
14
|
-
/**
|
|
15
|
-
* 构建原始消息
|
|
16
|
-
*/
|
|
17
|
-
raw_message(): void;
|
|
18
|
-
}
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { review } from './review.js';
|
|
2
|
-
import { EventBaseHandler } from './base.js';
|
|
3
|
-
import { karin, pluginLoader } from '../../core/index.js';
|
|
4
|
-
import { logger, config } from '../../utils/index.js';
|
|
5
|
-
/**
|
|
6
|
-
* 请求事件
|
|
7
|
-
*/
|
|
8
|
-
export class RequestHandler extends EventBaseHandler {
|
|
9
|
-
e;
|
|
10
|
-
constructor(e) {
|
|
11
|
-
super(e);
|
|
12
|
-
this.e = e;
|
|
13
|
-
this.init();
|
|
14
|
-
if (this.e.group_id) {
|
|
15
|
-
if (!this.getCd())
|
|
16
|
-
return;
|
|
17
|
-
if (!this.getGroupEnable())
|
|
18
|
-
return;
|
|
19
|
-
if (!this.getUserEnable())
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
if (!this.private())
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
/** 处理消息 */
|
|
27
|
-
this.deal();
|
|
28
|
-
}
|
|
29
|
-
init() {
|
|
30
|
-
this.raw_message();
|
|
31
|
-
/** 主人 */
|
|
32
|
-
if (config.master.includes(String(this.e.user_id))) {
|
|
33
|
-
this.e.isMaster = true;
|
|
34
|
-
this.e.isAdmin = true;
|
|
35
|
-
}
|
|
36
|
-
else if (config.admin.includes(String(this.e.user_id))) {
|
|
37
|
-
/** 管理员 */
|
|
38
|
-
this.e.isAdmin = true;
|
|
39
|
-
}
|
|
40
|
-
if (this.e.contact.scene === 'friend') {
|
|
41
|
-
this.e.isPrivate = true;
|
|
42
|
-
this.e.logText = `[Private:${this.e.sender.nick || ''}(${this.e.user_id})]`;
|
|
43
|
-
logger.bot('info', this.e.self_id, `${logger.green('私聊请求: ')}[${this.e.user_id}(${this.e.sender.nick || ''})] ${this.e.raw_message}`);
|
|
44
|
-
}
|
|
45
|
-
else if (this.e.contact.scene === 'group') {
|
|
46
|
-
this.e.isGroup = true;
|
|
47
|
-
this.e.logText = `[Group:${this.e.group_id}-${this.e.user_id}(${this.e.sender.nick || ''})]`;
|
|
48
|
-
this.GroupMsgPrint = review.GroupMsgPrint(this.e);
|
|
49
|
-
this.GroupMsgPrint && logger.bot('info', this.e.self_id, `${logger.green('群请求: ')}[${this.e.group_id}-${this.e.user_id}(${this.e.sender.nick || ''})] ${this.e.raw_message}`);
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
logger.bot('info', this.e.self_id, `未知来源请求事件:${JSON.stringify(this.e)}`);
|
|
53
|
-
}
|
|
54
|
-
this.reply();
|
|
55
|
-
karin.emit('request', this.e);
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* 处理事件
|
|
59
|
-
*/
|
|
60
|
-
async deal() {
|
|
61
|
-
for (const info of pluginLoader.accept) {
|
|
62
|
-
/** 判断事件 */
|
|
63
|
-
if (!this.filtEvent(info.event))
|
|
64
|
-
continue;
|
|
65
|
-
/** 检查黑白名单插件 */
|
|
66
|
-
if (!review.PluginEnable(info, this.config))
|
|
67
|
-
continue;
|
|
68
|
-
/** 日志方法字符串 */
|
|
69
|
-
this.e.logFnc = `[${info.name}][accept]`;
|
|
70
|
-
const logFnc = logger.fnc(this.e.logFnc + `[${this.e.event}.${this.e.sub_event}]`);
|
|
71
|
-
this.GroupMsgPrint && info.log(this.e.self_id, `${logFnc + this.e.logText} 开始处理`);
|
|
72
|
-
/** 计算插件处理时间 */
|
|
73
|
-
const start = Date.now();
|
|
74
|
-
try {
|
|
75
|
-
const res = await info.fn(this.e);
|
|
76
|
-
this.GroupMsgPrint && info.log(this.e.self_id, `${logFnc} 处理完成 ${logger.green(Date.now() - start + 'ms')}`);
|
|
77
|
-
if (res !== false)
|
|
78
|
-
break;
|
|
79
|
-
}
|
|
80
|
-
catch (error) {
|
|
81
|
-
logger.error(`${logFnc}`);
|
|
82
|
-
logger.error(error.stack || error.message || JSON.stringify(error));
|
|
83
|
-
break;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* 构建原始消息
|
|
89
|
-
*/
|
|
90
|
-
raw_message() {
|
|
91
|
-
switch (this.e.sub_event) {
|
|
92
|
-
/** 好友申请 */
|
|
93
|
-
case "private_apply" /* RequestSubType.PrivateApply */: {
|
|
94
|
-
const { applier_uid, applier_uin, message } = this.e.content;
|
|
95
|
-
this.e.raw_message = `[好友申请]: ${applier_uid || applier_uin} 申请理由: ${message}`;
|
|
96
|
-
break;
|
|
97
|
-
}
|
|
98
|
-
/** 群申请 */
|
|
99
|
-
case "group_apply" /* RequestSubType.GroupApply */: {
|
|
100
|
-
const { group_id, applier_uid, applier_uin, inviter_uid, inviter_uin, reason } = this.e.content;
|
|
101
|
-
this.e.raw_message = `[群申请]: ${group_id} 申请人: ${applier_uid || applier_uin} 邀请人: ${inviter_uid || inviter_uin} 理由: ${reason}`;
|
|
102
|
-
break;
|
|
103
|
-
}
|
|
104
|
-
/** 邀请入群 */
|
|
105
|
-
case "invited_group" /* RequestSubType.InvitedGroup */: {
|
|
106
|
-
const { group_id, inviter_uid, inviter_uin } = this.e.content;
|
|
107
|
-
this.e.raw_message = `[邀请入群]: ${group_id} 邀请人: ${inviter_uid || inviter_uin}`;
|
|
108
|
-
break;
|
|
109
|
-
}
|
|
110
|
-
default: {
|
|
111
|
-
this.e.raw_message = `[未知事件]: ${JSON.stringify(this.e)}`;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|