@nestim/koishi-plugin-qq-group-manager 0.1.14 → 0.1.15

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 (2) hide show
  1. package/lib/service.js +12 -3
  2. package/package.json +1 -1
package/lib/service.js CHANGED
@@ -285,6 +285,12 @@ class QQGroupManagerService extends koishi_1.Service {
285
285
  this._logger.info(`[eye] 收到上报 type=${kind} qq=${qq} 目标群=${(payload && payload.guildId) || '-'} 证据="${evidence}",但 eyePunishGroups 为空 → 不执行处罚`);
286
286
  return;
287
287
  }
288
+ // 「拉入本群不算」:耳目号被拉进我们自己的群属于正常操作,不处罚。
289
+ const fromGuild = String((payload && payload.guildId) || '').replace(/\D/g, '');
290
+ if (fromGuild && groups.includes(fromGuild)) {
291
+ this._logger.info(`[eye] 上报对象是被拉进本群(${fromGuild}),按规则不算拉人,跳过处罚 | qq=${qq}`);
292
+ return;
293
+ }
288
294
  // 白名单豁免:自己人永远不该被当成「拉人者」处罚。
289
295
  // 覆盖三种身份:allowedUserIds 白名单、bot 自身、以及处罚群的群主/管理员。
290
296
  // (注意:不是把「拉耳目号进群的人」当好人——而是这些人本来就有权限,
@@ -306,13 +312,16 @@ class QQGroupManagerService extends koishi_1.Service {
306
312
  this._logger.warn('[eye] 找不到主号 bot,无法执行处罚');
307
313
  return;
308
314
  }
315
+ // 处罚原因:OneBot 的 setGroupKick 没有「理由」字段(协议限制),
316
+ // 所以原因写进黑名单备注与日志,保证事后可查。
317
+ const punReason = '涉嫌诈骗/拉入广告群';
309
318
  const banned = [];
310
319
  const kicked = [];
311
320
  const failed = [];
312
321
  for (const guildId of groups) {
313
322
  const fake = { guildId, platform: 'onebot', userId: qq, bot, send: async () => { } };
314
323
  try {
315
- const r = await this.addToBlacklist(fake, qq, '');
324
+ const r = await this.addToBlacklist(fake, qq, punReason);
316
325
  if (r && r.ok)
317
326
  banned.push(guildId);
318
327
  else if (/已在/.test(String((r && r.message) || '')))
@@ -324,7 +333,7 @@ class QQGroupManagerService extends koishi_1.Service {
324
333
  failed.push(`${guildId}(拉黑异常)`);
325
334
  }
326
335
  try {
327
- const r = await this.kick(fake, qq, true, `拉人(${kind})`);
336
+ const r = await this.kick(fake, qq, true, punReason);
328
337
  if (r && r.ok)
329
338
  kicked.push(guildId);
330
339
  else
@@ -335,7 +344,7 @@ class QQGroupManagerService extends koishi_1.Service {
335
344
  }
336
345
  }
337
346
  this._eyePunishAt.set(qq, Date.now());
338
- this._logger.info(`[eye] 已处罚 qq=${qq} 来源=${kind} 拉黑=[${banned.join(',')}] 踢出=[${kicked.join(',')}] 失败=[${failed.join('; ')}] 证据="${evidence}"`);
347
+ this._logger.info(`[eye] 已处罚 qq=${qq} 原因=${punReason} 来源=${kind} 拉黑=[${banned.join(',')}] 踢出=[${kicked.join(',')}] 失败=[${failed.join('; ')}] 证据="${evidence}"`);
339
348
  }
340
349
  isPlatformAllowed(platform) {
341
350
  if (!platform)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nestim/koishi-plugin-qq-group-manager",
3
3
  "description": "Koishi QQ群管理插件(OneBot/LLOneBot):群管命令、权限校验、文本菜单、复读、AI群聊回复、记忆库、识图与自动管控(禁言/踢人)。",
4
- "version": "0.1.14",
4
+ "version": "0.1.15",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [