node-karin 0.10.0 → 0.10.2

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.
Files changed (129) hide show
  1. package/config/defSet/group.yaml +40 -2
  2. package/lib/adapter/onebot/11/index.js +1 -1
  3. package/lib/cli/init.js +1 -1
  4. package/lib/cli/karin.js +1 -1
  5. package/lib/core/index.d.ts +9 -9
  6. package/lib/core/index.js +9 -9
  7. package/lib/core/init/dir.js +7 -0
  8. package/lib/core/init/init.js +46 -0
  9. package/lib/core/{karin.d.ts → karin/karin.d.ts} +1 -1
  10. package/lib/core/karin/karin.js +194 -0
  11. package/lib/core/{listener.d.ts → listener/listener.d.ts} +1 -1
  12. package/lib/core/listener/listener.js +213 -0
  13. package/lib/core/{plugin.app.d.ts → plugin/app.d.ts} +1 -1
  14. package/lib/core/plugin/app.js +19 -0
  15. package/lib/core/{plugin.d.ts → plugin/base.d.ts} +1 -1
  16. package/lib/core/plugin/base.js +140 -0
  17. package/lib/core/{plugin.loader.d.ts → plugin/loader.d.ts} +3 -3
  18. package/lib/core/plugin/loader.js +579 -0
  19. package/lib/core/process/process.js +100 -0
  20. package/lib/core/server/server.js +283 -0
  21. package/lib/db/index.d.ts +2 -2
  22. package/lib/db/index.js +2 -2
  23. package/lib/db/level/level.js +36 -0
  24. package/lib/db/redis/redis.js +135 -0
  25. package/lib/db/redis/redis_level.js +287 -0
  26. package/lib/event/{event.handler.d.ts → handler/base.d.ts} +2 -2
  27. package/lib/event/handler/base.js +173 -0
  28. package/lib/event/{message.handler.d.ts → handler/message.d.ts} +3 -3
  29. package/lib/event/handler/message.js +270 -0
  30. package/lib/event/{notice.handler.d.ts → handler/notice.d.ts} +3 -3
  31. package/lib/event/handler/notice.js +212 -0
  32. package/lib/event/{request.handler.d.ts → handler/request.d.ts} +3 -3
  33. package/lib/event/handler/request.js +118 -0
  34. package/lib/event/{review.handler.d.ts → handler/review.d.ts} +3 -3
  35. package/lib/event/handler/review.js +391 -0
  36. package/lib/event/index.d.ts +5 -5
  37. package/lib/event/index.js +5 -5
  38. package/lib/render/base.d.ts +1 -1
  39. package/lib/render/client.d.ts +1 -1
  40. package/lib/render/client.js +2 -12
  41. package/lib/render/client_even.d.ts +1 -1
  42. package/lib/render/client_even.js +2 -12
  43. package/lib/render/http.d.ts +1 -1
  44. package/lib/render/http.js +1 -1
  45. package/lib/render/server.js +1 -1
  46. package/lib/types/adapter/{adapter.d.ts → base.d.ts} +2 -2
  47. package/lib/types/config/config.js +1 -0
  48. package/lib/types/element/element.js +1 -0
  49. package/lib/types/event/message.d.ts +1 -1
  50. package/lib/types/event/reply.d.ts +1 -1
  51. package/lib/types/index.d.ts +6 -6
  52. package/lib/types/index.js +6 -6
  53. package/lib/types/logger/logger.js +1 -0
  54. package/lib/types/{plugin.d.ts → plugin/plugin.d.ts} +3 -3
  55. package/lib/types/plugin/plugin.js +1 -0
  56. package/lib/types/render/render.js +1 -0
  57. package/lib/utils/{common.d.ts → common/common.d.ts} +1 -1
  58. package/lib/utils/common/common.js +591 -0
  59. package/lib/utils/{config.d.ts → config/config.d.ts} +37 -19
  60. package/lib/utils/config/config.js +328 -0
  61. package/lib/utils/config/updateVersion.js +145 -0
  62. package/lib/utils/config/yamlEditor.js +292 -0
  63. package/lib/utils/{handler.d.ts → core/handler.d.ts} +1 -1
  64. package/lib/utils/core/handler.js +115 -0
  65. package/lib/utils/core/init.js +213 -0
  66. package/lib/utils/core/logger.js +105 -0
  67. package/lib/utils/{segment.d.ts → core/segment.d.ts} +1 -1
  68. package/lib/utils/core/segment.js +441 -0
  69. package/lib/utils/index.d.ts +11 -11
  70. package/lib/utils/index.js +11 -11
  71. package/lib/utils/{button.d.ts → tools/button.d.ts} +1 -1
  72. package/lib/utils/tools/button.js +38 -0
  73. package/lib/utils/tools/exec.js +37 -0
  74. package/lib/utils/tools/ffmpeg.js +25 -0
  75. package/lib/utils/tools/update.js +139 -0
  76. package/package.json +1 -1
  77. package/lib/core/dir.js +0 -7
  78. package/lib/core/init.js +0 -42
  79. package/lib/core/karin.js +0 -194
  80. package/lib/core/listener.js +0 -217
  81. package/lib/core/plugin.app.js +0 -19
  82. package/lib/core/plugin.js +0 -145
  83. package/lib/core/plugin.loader.js +0 -561
  84. package/lib/core/process.js +0 -98
  85. package/lib/core/server.js +0 -269
  86. package/lib/db/level.js +0 -37
  87. package/lib/db/redis.js +0 -134
  88. package/lib/db/redis_level.js +0 -293
  89. package/lib/event/event.handler.js +0 -167
  90. package/lib/event/message.handler.js +0 -254
  91. package/lib/event/notice.handler.js +0 -204
  92. package/lib/event/request.handler.js +0 -110
  93. package/lib/event/review.handler.js +0 -387
  94. package/lib/types/config.js +0 -1
  95. package/lib/types/element.js +0 -1
  96. package/lib/types/logger.js +0 -1
  97. package/lib/types/plugin.js +0 -1
  98. package/lib/types/render.js +0 -1
  99. package/lib/utils/button.js +0 -34
  100. package/lib/utils/common.js +0 -572
  101. package/lib/utils/config.js +0 -318
  102. package/lib/utils/exec.js +0 -36
  103. package/lib/utils/ffmpeg.js +0 -25
  104. package/lib/utils/handler.js +0 -109
  105. package/lib/utils/init.js +0 -208
  106. package/lib/utils/logger.js +0 -104
  107. package/lib/utils/segment.js +0 -470
  108. package/lib/utils/update.js +0 -135
  109. package/lib/utils/updateVersion.js +0 -145
  110. package/lib/utils/yamlEditor.js +0 -279
  111. /package/lib/core/{dir.d.ts → init/dir.d.ts} +0 -0
  112. /package/lib/core/{init.d.ts → init/init.d.ts} +0 -0
  113. /package/lib/core/{process.d.ts → process/process.d.ts} +0 -0
  114. /package/lib/core/{server.d.ts → server/server.d.ts} +0 -0
  115. /package/lib/db/{level.d.ts → level/level.d.ts} +0 -0
  116. /package/lib/db/{redis.d.ts → redis/redis.d.ts} +0 -0
  117. /package/lib/db/{redis_level.d.ts → redis/redis_level.d.ts} +0 -0
  118. /package/lib/types/adapter/{adapter.js → base.js} +0 -0
  119. /package/lib/types/{config.d.ts → config/config.d.ts} +0 -0
  120. /package/lib/types/{element.d.ts → element/element.d.ts} +0 -0
  121. /package/lib/types/{logger.d.ts → logger/logger.d.ts} +0 -0
  122. /package/lib/types/{render.d.ts → render/render.d.ts} +0 -0
  123. /package/lib/utils/{updateVersion.d.ts → config/updateVersion.d.ts} +0 -0
  124. /package/lib/utils/{yamlEditor.d.ts → config/yamlEditor.d.ts} +0 -0
  125. /package/lib/utils/{init.d.ts → core/init.d.ts} +0 -0
  126. /package/lib/utils/{logger.d.ts → core/logger.d.ts} +0 -0
  127. /package/lib/utils/{exec.d.ts → tools/exec.d.ts} +0 -0
  128. /package/lib/utils/{ffmpeg.d.ts → tools/ffmpeg.d.ts} +0 -0
  129. /package/lib/utils/{update.d.ts → tools/update.d.ts} +0 -0
@@ -0,0 +1,287 @@
1
+ import { Level } from 'level';
2
+ export default class RedisLevel {
3
+ #level;
4
+ #expireMap;
5
+ id;
6
+ constructor() {
7
+ const path = process.cwd() + '/data/db/RedisLevel';
8
+ this.#level = new Level(path, { valueEncoding: 'json' });
9
+ /**
10
+ * @type {'RedisLevel'} 唯一标识符 用于区分不同的数据库
11
+ */
12
+ this.id = 'RedisLevel';
13
+ /**
14
+ * 过期时间映射表
15
+ * @type {Map<string, number>} 键: 值 (过期时间)
16
+ */
17
+ this.#expireMap = new Map();
18
+ /**
19
+ * 开启过期时间处理
20
+ */
21
+ this.#expireHandle();
22
+ }
23
+ /**
24
+ * 过期时间处理 每分钟检查一次
25
+ */
26
+ async #expireHandle() {
27
+ setInterval(async () => {
28
+ const now = Date.now();
29
+ // 获取代理对象的键值对数组
30
+ const entries = Array.from(this.#expireMap.entries());
31
+ for (const [key, expire] of entries) {
32
+ if (expire < now) {
33
+ await this.#level.del(key);
34
+ this.#expireMap.delete(key); // 通过代理的方式删除键值对
35
+ }
36
+ }
37
+ }, 60000);
38
+ /**
39
+ * 对expireMap进行代理 实现持久化 每次触发都保存到数据库
40
+ */
41
+ const handler = {
42
+ get: function (target, prop, receiver) {
43
+ if (prop === 'get' || prop === 'entries') {
44
+ return function (...args) {
45
+ const reflect = Reflect.get(target, prop).apply(target, args);
46
+ return typeof reflect === 'function' ? reflect.bind(target) : reflect;
47
+ };
48
+ }
49
+ const reflect = Reflect.get(target, prop, receiver);
50
+ return typeof reflect === 'function' ? reflect.bind(target) : reflect;
51
+ },
52
+ set: function (target, key, value) {
53
+ target.set(key, value);
54
+ // 修改后持久化到数据库
55
+ const reflect = Reflect.set(target, key, value);
56
+ return typeof reflect === 'function' ? reflect.bind(target) : reflect;
57
+ },
58
+ deleteProperty: function (target, key) {
59
+ Reflect.deleteProperty(target, key);
60
+ // 删除后持久化到数据库
61
+ const reflect = Reflect.deleteProperty(target, key);
62
+ return typeof reflect === 'function' ? reflect.bind(target) : reflect;
63
+ },
64
+ };
65
+ this.#expireMap = new Proxy(this.#expireMap, handler);
66
+ }
67
+ /**
68
+ * get 获取数据
69
+ * @param {string} key 键
70
+ * @returns {Promise<string>|Error} 数据
71
+ */
72
+ async get(key) {
73
+ try {
74
+ /** 先查过期时间 */
75
+ const expire = this.#expireMap.get(key);
76
+ if (expire && expire < Date.now()) {
77
+ await this.#level.del(key);
78
+ this.#expireMap.delete(key);
79
+ return null;
80
+ }
81
+ return await this.#level.get(key);
82
+ }
83
+ catch (error) {
84
+ if (error.notFound)
85
+ return null;
86
+ throw error;
87
+ }
88
+ }
89
+ /**
90
+ * set 设置数据
91
+ * @param key 键
92
+ * @param value 值
93
+ * @param options 选项
94
+ */
95
+ async set(key, value, options) {
96
+ if (options && options.EX) {
97
+ this.#expireMap.set(key, Date.now() + options.EX * 1000);
98
+ }
99
+ return await this.#level.put(key, value);
100
+ }
101
+ /**
102
+ * del 删除数据
103
+ * @param key 键
104
+ */
105
+ async del(key) {
106
+ this.#expireMap.delete(key);
107
+ return await this.#level.del(key);
108
+ }
109
+ /**
110
+ * keys 获取所有键
111
+ * @param prefix 前缀
112
+ */
113
+ async keys(prefix = '') {
114
+ /** 去掉末尾的* */
115
+ prefix = prefix.replace(/\*$/, '');
116
+ const list = await this.#level.keys({ gte: prefix, lt: `${prefix}\xFF` }).all();
117
+ this.#checkKeys(list);
118
+ return list;
119
+ }
120
+ /**
121
+ * 给一个kyes 检查是否过期
122
+ * @param keys 键数组
123
+ */
124
+ async #checkKeys(keys) {
125
+ for (const key of keys) {
126
+ const expire = this.#expireMap.get(key);
127
+ if (expire && expire < Date.now()) {
128
+ await this.#level.del(key);
129
+ this.#expireMap.delete(key);
130
+ }
131
+ }
132
+ }
133
+ /**
134
+ * incr 递增数据
135
+ * @param {string} key 键
136
+ * @returns {Promise<number>|Error}
137
+ */
138
+ async incr(key) {
139
+ let value = Number(await this.get(key));
140
+ if (value === null) {
141
+ value = 0;
142
+ }
143
+ else {
144
+ value = Number(value);
145
+ if (isNaN(value))
146
+ throw new Error('Value is not a number');
147
+ }
148
+ value += 1;
149
+ await this.set(key, value.toString());
150
+ return value;
151
+ }
152
+ /**
153
+ * decr 递减数据
154
+ * @param {string} key 键
155
+ * @returns {Promise<number>|Error}
156
+ */
157
+ async decr(key) {
158
+ let value = Number(await this.get(key));
159
+ if (value === null) {
160
+ value = 0;
161
+ }
162
+ else {
163
+ value = Number(value);
164
+ if (isNaN(value))
165
+ throw new Error('Value is not a number');
166
+ }
167
+ value -= 1;
168
+ await this.set(key, value.toString());
169
+ return value;
170
+ }
171
+ /**
172
+ * expire 设置过期时间
173
+ * @param {string} key 键
174
+ * @param seconds 过期时间 单位秒
175
+ * @returns {Promise<number>|Error}
176
+ */
177
+ async expire(key, seconds) {
178
+ this.#expireMap.set(key, Date.now() + seconds * 1000);
179
+ return seconds;
180
+ }
181
+ /**
182
+ * ttl 获取过期时间
183
+ * @param {string} key 键
184
+ * @returns {Promise<number>|Error}
185
+ */
186
+ async ttl(key) {
187
+ const expire = this.#expireMap.get(key);
188
+ if (expire) {
189
+ return Math.ceil((expire - Date.now()) / 1000);
190
+ }
191
+ return -2;
192
+ }
193
+ /**
194
+ * setEx 设置数据并设置过期时间
195
+ * @param {string} key 键
196
+ * @param seconds 过期时间 单位秒
197
+ * @param {string} value 值
198
+ * @returns {Promise<void>|Error}
199
+ */
200
+ async setEx(key, seconds, value) {
201
+ this.#expireMap.set(key, Date.now() + seconds * 1000);
202
+ return await this.#level.put(key, value);
203
+ }
204
+ /**
205
+ * exists 判断键是否存在
206
+ * @param {string} key 键
207
+ * @returns {Promise<number>|Error}
208
+ */
209
+ async exists(key) {
210
+ const value = await this.get(key);
211
+ return value === null ? 0 : 1;
212
+ }
213
+ /**
214
+ * zAdd 有序集合添加元素
215
+ * @param {string} key 键
216
+ * @param {object} data 数据
217
+ * @param data.score 分数
218
+ * @param {string} data.value 值
219
+ */
220
+ async zAdd(key, { score, value }) {
221
+ const set = await this.get(key);
222
+ const arr = (set ? JSON.parse(set) : []);
223
+ arr.push({ score, value });
224
+ arr.sort((a, b) => a.score - b.score);
225
+ await this.set(key, JSON.stringify(arr));
226
+ }
227
+ /**
228
+ * zRem 有序集合删除元素
229
+ * @param {string} key 键
230
+ * @param {string} value 值
231
+ */
232
+ async zRem(key, value) {
233
+ const set = await this.get(key);
234
+ if (set === null)
235
+ return;
236
+ let arr = JSON.parse(set);
237
+ arr = arr.filter((item) => item.value !== value);
238
+ await this.set(key, JSON.stringify(arr));
239
+ }
240
+ /**
241
+ * zIncrBy 有序集合分数递增
242
+ * @param {string} key 键
243
+ * @param increment 递增值
244
+ * @param {string} value 值
245
+ * @returns {Promise<number>|Error}
246
+ */
247
+ async zIncrBy(key, increment, value) {
248
+ const set = await this.get(key);
249
+ if (set === null)
250
+ throw new Error('Set does not exist');
251
+ const arr = JSON.parse(set);
252
+ const item = arr.find((item) => item.value === value);
253
+ if (item)
254
+ item.score += increment;
255
+ arr.sort((a, b) => a.score - b.score);
256
+ await this.set(key, JSON.stringify(arr));
257
+ return item.score;
258
+ }
259
+ /**
260
+ * zRangeByScore 有序集合根据分数范围获取元素
261
+ * @param {string} key 键
262
+ * @param min 最小分数
263
+ * @param max 最大分数
264
+ * @returns {Promise<string[]>|Error}
265
+ */
266
+ async zRangeByScore(key, min, max) {
267
+ const set = await this.get(key);
268
+ if (set === null)
269
+ return [];
270
+ const arr = JSON.parse(set);
271
+ return arr.filter((item) => item.score >= min && item.score <= max).map((item) => item.value);
272
+ }
273
+ /**
274
+ * zScore 有序集合获取元素分数
275
+ * @param {string} key 键
276
+ * @param {string} value 值
277
+ * @returns {Promise<number>|Error}
278
+ */
279
+ async zScore(key, value) {
280
+ const set = await this.get(key);
281
+ if (set === null)
282
+ return null;
283
+ const arr = JSON.parse(set);
284
+ const item = arr.find((item) => item.value === value);
285
+ return item ? item.score : null;
286
+ }
287
+ }
@@ -1,5 +1,5 @@
1
- import { GroupCfg, KarinEventTypes, AllListenEvent, PluginRule } from '../types/index.js';
2
- export default class EventHandler {
1
+ import { GroupCfg, KarinEventTypes, AllListenEvent, PluginRule } from '../../types/index.js';
2
+ export declare class EventBaseHandler {
3
3
  e: KarinEventTypes;
4
4
  config: GroupCfg | {};
5
5
  /**
@@ -0,0 +1,173 @@
1
+ import { listener } from '../../core/index.js';
2
+ import { review } from './review.js';
3
+ import { segment, common, logger, config } from '../../utils/index.js';
4
+ export class EventBaseHandler {
5
+ e;
6
+ config;
7
+ /**
8
+ * - 是否打印群消息日志
9
+ */
10
+ GroupMsgPrint;
11
+ /**
12
+ * 处理事件,加入自定义字段
13
+ */
14
+ constructor(e) {
15
+ this.e = e;
16
+ this.config = {};
17
+ this.GroupMsgPrint = false;
18
+ /** 加入e.bot */
19
+ !this.e.bot && Object.defineProperty(this.e, 'bot', { value: listener.getBot(this.e.self_id) });
20
+ if (this.e.group_id)
21
+ this.config = config.group(this.e.group_id, this.e);
22
+ }
23
+ /**
24
+ * 事件处理
25
+ */
26
+ review() {
27
+ /** 检查CD */
28
+ if (!review.CD(this.e, this.config)) {
29
+ logger.debug('[消息拦截] 正在冷却中');
30
+ return true;
31
+ }
32
+ /** 检查群聊黑白名单 */
33
+ if (!review.GroupEnable(this.e)) {
34
+ logger.debug('[消息拦截] 未通过群聊黑白名单检查');
35
+ return true;
36
+ }
37
+ /** 检查用户黑白名单 */
38
+ if (!review.UserEnable(this.e)) {
39
+ logger.debug('[消息拦截] 未通过用户黑白名单检查');
40
+ return true;
41
+ }
42
+ /** 都通过了 */
43
+ return false;
44
+ }
45
+ /**
46
+ * 处理私聊功能 功能开启返回true
47
+ */
48
+ private() {
49
+ /** 检查私聊是否开启 */
50
+ if (this.e.user_id !== 'input' && this.e.isPrivate && !review.Private()) {
51
+ /** 用户处于白名单 */
52
+ if (config.Config?.private?.white_list?.includes(String(this.e.user_id)))
53
+ return true;
54
+ /** 不处于白名单 检查是否存在提示词 */
55
+ if (config.Config?.private?.tips)
56
+ this.e.reply(config.Config.private.tips);
57
+ logger.debug('[消息拦截] 私聊功能未开启');
58
+ return false;
59
+ }
60
+ return true;
61
+ }
62
+ /**
63
+ * 根据事件类型过滤事件
64
+ */
65
+ filtEvent(event) {
66
+ /** 事件映射表 */
67
+ const eventMap = {
68
+ message: () => `message.${this.e.sub_event}`,
69
+ message_sent: () => `message_sent.${this.e.sub_event}`,
70
+ meta_event: () => `message.${this.e.sub_event}`,
71
+ notice: () => `notice.${this.e.sub_event}`,
72
+ request: () => `request.${this.e.sub_event}`,
73
+ };
74
+ const eventType = eventMap[this.e.event]();
75
+ return eventType.includes(event);
76
+ }
77
+ /**
78
+ * 判断权限
79
+ */
80
+ filterPermission(permission) {
81
+ if (!permission || permission === 'all')
82
+ return true;
83
+ if (permission === 'master') {
84
+ if (!this.e.isMaster) {
85
+ this.e.reply('暂无权限,只有主人才能操作');
86
+ return false;
87
+ }
88
+ return true;
89
+ }
90
+ if (permission === 'admin') {
91
+ if (!this.e.isMaster && !this.e.isAdmin) {
92
+ this.e.reply('暂无权限,只有管理员才能操作');
93
+ return false;
94
+ }
95
+ return true;
96
+ }
97
+ if (this.e.isGroup) {
98
+ const list = {
99
+ 'group.owner': {
100
+ role: 'owner',
101
+ name: '群主',
102
+ },
103
+ 'group.admin': {
104
+ role: 'admin',
105
+ name: '群管理员',
106
+ },
107
+ };
108
+ const role = list[permission];
109
+ if (!role)
110
+ return true;
111
+ if (role.role === 'owner' && this.e.sender?.role === 'owner')
112
+ return true;
113
+ if (role.role === 'admin' && (this.e.sender?.role === 'owner' || this.e.sender?.role === 'admin'))
114
+ return true;
115
+ this.e.reply(`暂无权限,只有${role.name}才能操作`);
116
+ return false;
117
+ }
118
+ return true;
119
+ }
120
+ /**
121
+ * 快速回复
122
+ */
123
+ reply() {
124
+ /**
125
+ * 快速回复
126
+ * @param elements 回复内容
127
+ * @param options 回复选项
128
+ */
129
+ this.e.reply = async (elements = '', options = { reply: false, recallMsg: 0, at: false, retry_count: 1 }) => {
130
+ const message = common.makeMessage(elements);
131
+ const { reply = false, recallMsg = 0, at, retry_count = 1 } = options;
132
+ /** 加入at */
133
+ if (at && this.e.isGroup)
134
+ message.unshift(segment.at(this.e.user_id));
135
+ /** 加入引用回复 */
136
+ if (reply && 'message_id' in this.e)
137
+ message.unshift(segment.reply(this.e.message_id));
138
+ /** 先发 提升速度 */
139
+ const result = this.e.replyCallback(message, retry_count);
140
+ const ReplyLog = common.makeMessageLog(message);
141
+ if (this.e.isGroup) {
142
+ review.GroupMsgPrint(this.e) && logger.bot('info', this.e.self_id, `${logger.green(`Send Group ${this.e.group_id}: `)}${ReplyLog}`);
143
+ }
144
+ else {
145
+ this.e.self_id !== 'input' && logger.bot('info', this.e.self_id, `${logger.green(`Send private ${this.e.user_id}: `)}${ReplyLog}`);
146
+ }
147
+ const request = {
148
+ message_id: '',
149
+ message_time: 0,
150
+ raw_data: undefined,
151
+ };
152
+ try {
153
+ listener.emit('karin:count:send', 1);
154
+ /** 取结果 */
155
+ const Res = await result;
156
+ request.message_id = Res.message_id || '';
157
+ request.message_time = Res.message_time || Date.now();
158
+ request.raw_data = Res.raw_data || undefined;
159
+ logger.bot('debug', this.e.self_id, `回复消息结果:${JSON.stringify(request)}`);
160
+ }
161
+ catch (error) {
162
+ logger.bot('error', this.e.self_id, `回复消息失败:${ReplyLog}`);
163
+ logger.bot('error', this.e.self_id, error.stack || error.message || JSON.stringify(error));
164
+ }
165
+ /** 快速撤回 */
166
+ if (recallMsg > 0 && request.message_id) {
167
+ setTimeout(() => this.e.bot.RecallMessage(this.e.contact, request.message_id), recallMsg * 1000);
168
+ }
169
+ return request;
170
+ };
171
+ Object.freeze(this.e.reply);
172
+ }
173
+ }
@@ -1,9 +1,9 @@
1
- import EventHandler from './event.handler.js';
2
- import { KarinMessageType } from '../types/index.js';
1
+ import { EventBaseHandler } from './base.js';
2
+ import { KarinMessageType } from '../../types/index.js';
3
3
  /**
4
4
  * 消息事件
5
5
  */
6
- export declare class MessageHandler extends EventHandler {
6
+ export declare class MessageHandler extends EventBaseHandler {
7
7
  e: KarinMessageType;
8
8
  /**
9
9
  * - 是否打印群消息日志