koishi-plugin-bind-bot 2.1.3 → 2.1.4

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.
@@ -43,8 +43,8 @@ class GroupRequestReviewHandler extends base_handler_1.BaseHandler {
43
43
  // 监听用户成功进群
44
44
  this.ctx.on('guild-member-added', this.handleUserJoined.bind(this));
45
45
  // 监听表情回应(NapCat扩展事件)
46
- // 使用通用 'message' 事件监听,在 handleNotice 中过滤
47
- this.ctx.on('message', this.handleNotice.bind(this));
46
+ // 使用 'notice' 事件监听群表情回应事件(session.subtype === 'group-msg-emoji-like')
47
+ this.ctx.on('notice', this.handleNotice.bind(this));
48
48
  // 中间件:处理拒绝理由
49
49
  this.ctx.middleware(this.handleRejectReason.bind(this));
50
50
  // 定时清理过期记录
@@ -107,13 +107,20 @@ class GroupRequestReviewHandler extends base_handler_1.BaseHandler {
107
107
  return;
108
108
  }
109
109
  // 获取原始事件数据(使用类型断言访问 onebot 扩展属性)
110
- const sessionAny = session;
111
- if (!sessionAny.onebot || !sessionAny.onebot.likes) {
110
+ const onebotSession = session;
111
+ const onebotData = onebotSession.onebot;
112
+ if (!onebotData?.likes || onebotData.likes.length === 0) {
112
113
  return;
113
114
  }
114
- const emojiData = sessionAny.onebot.likes;
115
- const msgId = session.messageId;
116
- const operatorId = this.deps.normalizeQQId(session.userId);
115
+ // 从原始 OneBot 数据中读取(更可靠)
116
+ const msgId = onebotData.message_id?.toString() || session.messageId;
117
+ const userId = onebotData.user_id?.toString() || session.userId;
118
+ const emojiData = onebotData.likes;
119
+ if (!msgId || !userId) {
120
+ this.logger.warn('入群审批', '表情回应事件缺少必要数据: messageId 或 userId');
121
+ return;
122
+ }
123
+ const operatorId = this.deps.normalizeQQId(userId);
117
124
  this.logger.debug('入群审批', `收到表情回应 - 消息: ${msgId}, 操作者: ${operatorId}, 表情数: ${emojiData.length}`);
118
125
  // 检查是否是待审批的消息
119
126
  const pendingReq = this.pendingRequests.get(msgId);
@@ -177,7 +184,7 @@ class GroupRequestReviewHandler extends base_handler_1.BaseHandler {
177
184
  koishi_1.h.image(avatar),
178
185
  koishi_1.h.text(`\n👤 昵称:${nickname}\n`),
179
186
  koishi_1.h.text(`🆔 QQ号:${qq}\n`),
180
- koishi_1.h.text(`💬 回答:${answer}\n\n`),
187
+ koishi_1.h.text(`💬 入群${answer}\n\n`),
181
188
  koishi_1.h.text('━━━━━━━━━━━━━━━\n'),
182
189
  koishi_1.h.text('请管理员点击表情回应:\n'),
183
190
  koishi_1.h.text('👍 /太赞了 - 通过并自动绑定\n'),
@@ -353,13 +360,15 @@ class GroupRequestReviewHandler extends base_handler_1.BaseHandler {
353
360
  // 检查是否是同一个管理员
354
361
  const operatorId = this.deps.normalizeQQId(session.userId);
355
362
  if (operatorId !== rejectFlow.operatorId) {
356
- return '⚠️ 只有发起拒绝的管理员可以提供理由';
363
+ void session.send('⚠️ 只有发起拒绝的管理员可以提供理由');
364
+ return;
357
365
  }
358
366
  // 检查是否超时
359
367
  if (Date.now() > rejectFlow.timeout) {
360
368
  this.rejectFlows.delete(session.quote.id);
361
369
  rejectFlow.pendingRequest.status = 'pending';
362
- return '❌ 拒绝流程已超时,请重新操作';
370
+ void session.send('❌ 拒绝流程已超时,请重新操作');
371
+ return;
363
372
  }
364
373
  // 执行拒绝
365
374
  const reason = session.content;
@@ -369,12 +378,12 @@ class GroupRequestReviewHandler extends base_handler_1.BaseHandler {
369
378
  this.logger.info('入群审批', `已拒绝入群 - QQ: ${pendingRequest.applicantQQ}, 理由: ${reason}`, true);
370
379
  pendingRequest.status = 'rejected';
371
380
  this.rejectFlows.delete(session.quote.id);
372
- return `✅ 已拒绝 ${pendingRequest.applicantQQ} 的入群申请\n拒绝理由:${reason}`;
381
+ await session.send(`✅ 已拒绝 ${pendingRequest.applicantQQ} 的入群申请\n拒绝理由:${reason}`);
373
382
  }
374
383
  catch (error) {
375
384
  this.logger.error('入群审批', `拒绝入群失败: ${error.message}`, error);
376
385
  pendingRequest.status = 'pending';
377
- return `❌ 拒绝失败:${error.message}`;
386
+ await session.send(`❌ 拒绝失败:${error.message}`);
378
387
  }
379
388
  }
380
389
  /**
package/lib/index.js CHANGED
@@ -55,11 +55,9 @@ exports.Config = koishi_1.Schema.object({
55
55
  groupRequestReview: koishi_1.Schema.object({
56
56
  enabled: koishi_1.Schema.boolean().description('是否启用入群申请审批功能').default(false),
57
57
  targetGroupId: koishi_1.Schema.string()
58
- .description('需要审批的目标群ID(入群申请来源群)')
59
- .default('931805503'),
58
+ .description('需要审批的目标群ID(入群申请来源群)'),
60
59
  reviewGroupId: koishi_1.Schema.string()
61
- .description('管理员审批操作所在的群ID(播报群)')
62
- .default('290238092'),
60
+ .description('管理员审批操作所在的群ID(播报群)'),
63
61
  approveAutoBindEmoji: koishi_1.Schema.string()
64
62
  .description('批准并自动绑定的表情ID(/太赞了)')
65
63
  .default('389'),
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-bind-bot",
3
3
  "description": "[WittF自用] BIND-BOT - 账号绑定管理机器人,支持Minecraft账号和B站账号绑定与管理。",
4
- "version": "2.1.3",
4
+ "version": "2.1.4",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [