@nestim/koishi-plugin-qq-group-manager 0.1.14 → 0.1.16
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/lib/index.js +2 -1
- package/lib/service.js +48 -3
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -75,7 +75,8 @@ exports.Config = koishi_1.Schema.intersect([
|
|
|
75
75
|
banRecordOnKick: koishi_1.Schema.boolean().default(true).description('有人被移出群聊时是否自动把被踢者加入黑名单。只处理明确判定为「被踢」的事件(subtype=passive/kick),主动退群(leave/quit)与 subtype 缺失一律不记录;bot 自己永不记入。设为 false 则关闭该自动拉黑,只保留手动 [ban]。'),
|
|
76
76
|
}).description('黑名单'),
|
|
77
77
|
koishi_1.Schema.object({
|
|
78
|
-
eyeSelfId: koishi_1.Schema.string().default('').description('耳目号(小号)的 QQ。填写后,本插件会接收 nestim-eye 上报的「拉人事件 + QQ
|
|
78
|
+
eyeSelfId: koishi_1.Schema.string().default('').description('耳目号(小号)的 QQ。填写后,本插件会接收 nestim-eye 上报的「拉人事件 + QQ 号」,并由**主号直接执行处罚**。'),
|
|
79
|
+
eyeNotifyGuildId: koishi_1.Schema.string().default('').description('执法台账发送到哪个群(填群号,用主号发送)。每次处罚后发一条简短记录;耳目号自身全程不发言。留空 = 不发台账。'),
|
|
79
80
|
eyePunishGroups: koishi_1.Schema.array(String).role('table').default([]).description('耳目上报后,对拉人者执行「拉黑 + 踢人」的群号列表(主号必须在这些群里有管理员/群主权限才能踢人;无权限时仍会拉黑)。留空 = 不执行处罚,只写日志。'),
|
|
80
81
|
eyePunishCooldownMinutes: koishi_1.Schema.natural().default(10).description('同一个人被处罚的冷却时间(分钟),避免重复踢同一个人。'),
|
|
81
82
|
}).description('耳目联动'),
|
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,
|
|
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,43 @@ 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}"`);
|
|
348
|
+
// 执法台账:处罚后往指定群发一条简短记录(耳目号依旧不发言,这条由主号发出)
|
|
349
|
+
await this.sendEyeLedger({ qq, kind, evidence, banned, kicked, failed, reason: punReason });
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* 发一条「执法台账」到 eyeNotifyGuildId 指定的群。
|
|
353
|
+
* 仅由主号发出;耳目号全程静默。发送失败只记日志,不影响处罚结果。
|
|
354
|
+
*/
|
|
355
|
+
async sendEyeLedger(info) {
|
|
356
|
+
const target = String(this.config.eyeNotifyGuildId || '').replace(/\D/g, '');
|
|
357
|
+
if (!target)
|
|
358
|
+
return false;
|
|
359
|
+
const bot = this.resolveMainBot();
|
|
360
|
+
if (!bot || typeof bot.sendMessage !== 'function')
|
|
361
|
+
return false;
|
|
362
|
+
const lines = [
|
|
363
|
+
'【耳目执法】',
|
|
364
|
+
`对象:${info.qq}`,
|
|
365
|
+
`原因:${info.reason}`,
|
|
366
|
+
`触发:${info.kind === 'private' ? '私聊小号拉人' : '小号被拉进新群'}`,
|
|
367
|
+
];
|
|
368
|
+
if (info.evidence)
|
|
369
|
+
lines.push(`证据:${info.evidence}`);
|
|
370
|
+
lines.push(`拉黑:${info.banned.length ? info.banned.join(',') : '无'}`);
|
|
371
|
+
lines.push(`踢出:${info.kicked.length ? info.kicked.join(',') : '无'}`);
|
|
372
|
+
if (info.failed.length)
|
|
373
|
+
lines.push(`未完成:${info.failed.join('; ')}`);
|
|
374
|
+
lines.push(`时间:${new Date().toLocaleString('zh-CN', { hour12: false })}`);
|
|
375
|
+
try {
|
|
376
|
+
await bot.sendMessage(target, lines.join('\n'));
|
|
377
|
+
this._logger.info(`[eye] 执法台账已发到群 ${target}`);
|
|
378
|
+
return true;
|
|
379
|
+
}
|
|
380
|
+
catch (error) {
|
|
381
|
+
this._logger.warn(`[eye] 执法台账发送失败: ${String(error)}`);
|
|
382
|
+
return false;
|
|
383
|
+
}
|
|
339
384
|
}
|
|
340
385
|
isPlatformAllowed(platform) {
|
|
341
386
|
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.
|
|
4
|
+
"version": "0.1.16",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
7
7
|
"files": [
|