@nestim/koishi-plugin-qq-group-manager 0.1.12 → 0.1.14
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 -2
- package/lib/service.js +48 -4
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -75,8 +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
|
|
79
|
-
eyePunishGroups: koishi_1.Schema.array(String).role('table').default([]).description('
|
|
78
|
+
eyeSelfId: koishi_1.Schema.string().default('').description('耳目号(小号)的 QQ。填写后,本插件会接收 nestim-eye 上报的「拉人事件 + QQ 号」,并由**主号直接执行处罚**(全程不发任何通知消息)。'),
|
|
79
|
+
eyePunishGroups: koishi_1.Schema.array(String).role('table').default([]).description('耳目上报后,对拉人者执行「拉黑 + 踢人」的群号列表(主号必须在这些群里有管理员/群主权限才能踢人;无权限时仍会拉黑)。留空 = 不执行处罚,只写日志。'),
|
|
80
80
|
eyePunishCooldownMinutes: koishi_1.Schema.natural().default(10).description('同一个人被处罚的冷却时间(分钟),避免重复踢同一个人。'),
|
|
81
81
|
}).description('耳目联动'),
|
|
82
82
|
koishi_1.Schema.object({
|
package/lib/service.js
CHANGED
|
@@ -233,8 +233,43 @@ class QQGroupManagerService extends koishi_1.Service {
|
|
|
233
233
|
return out;
|
|
234
234
|
}
|
|
235
235
|
/**
|
|
236
|
-
*
|
|
237
|
-
*
|
|
236
|
+
* 判断某个 QQ 是否豁免「耳目处罚」。
|
|
237
|
+
*
|
|
238
|
+
* 为什么要豁免:耳目号只能通过「被谁拉进群」来发现拉人者,所以
|
|
239
|
+
* **把耳目号拉进自己群的人**也会被上报。自己人(白名单、bot 自身、
|
|
240
|
+
* 处罚群的群主/管理员)拉小号进自己的群属于正常操作,不该被处罚。
|
|
241
|
+
*
|
|
242
|
+
* 返回豁免原因字符串;返回 '' 表示不豁免。
|
|
243
|
+
*/
|
|
244
|
+
async isEyeExemptAccount(qq, groups) {
|
|
245
|
+
const id = String(qq || '').replace(/\D/g, '');
|
|
246
|
+
if (!id) return '无法识别';
|
|
247
|
+
// 1) 账号白名单
|
|
248
|
+
const allow = Array.isArray(this.config.allowedUserIds) ? this.config.allowedUserIds : [];
|
|
249
|
+
if (allow.some((x) => String(x).replace(/\D/g, '') === id)) return 'allowedUserIds 白名单';
|
|
250
|
+
// 2) bot 自身(含主号与耳目号)
|
|
251
|
+
const bots = Array.from(this.ctx.bots || []);
|
|
252
|
+
if (bots.some((b) => String(b.selfId || '').replace(/\D/g, '') === id)) return 'bot 自身';
|
|
253
|
+
// 3) 处罚群里的群主/管理员
|
|
254
|
+
const bot = this.resolveMainBot();
|
|
255
|
+
if (bot) {
|
|
256
|
+
for (const guildId of groups) {
|
|
257
|
+
try {
|
|
258
|
+
const role = await this.resolveMemberRole({ guildId, platform: 'onebot', userId: id, bot });
|
|
259
|
+
if (role === 'owner' || role === 'admin') return `群 ${guildId} 的${role === 'owner' ? '群主' : '管理员'}`;
|
|
260
|
+
}
|
|
261
|
+
catch { /* 查询失败就不豁免,交给后续流程 */ }
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
return '';
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* 处理耳目号上报的拉人事件 → 由主号**直接执行处罚**。
|
|
268
|
+
*
|
|
269
|
+
* 全链路零对外消息:耳目只上报事件,大号只动手(拉黑 + 踢人),
|
|
270
|
+
* 不在任何群里发通知、不回复。所有动作只写插件日志。
|
|
271
|
+
* 耳目自身不需要任何群权限;主号若无管理权限,踢人会失败但拉黑仍成立。
|
|
272
|
+
*
|
|
238
273
|
* payload: { type: 'private'|'group-invite', qq: string, guildId?: string, evidence?: string, name?: string }
|
|
239
274
|
*/
|
|
240
275
|
async punishReportedUser(payload) {
|
|
@@ -243,11 +278,20 @@ class QQGroupManagerService extends koishi_1.Service {
|
|
|
243
278
|
this._logger.warn(`[eye] 上报的 QQ 号无效,已忽略: ${JSON.stringify(payload)}`);
|
|
244
279
|
return;
|
|
245
280
|
}
|
|
246
|
-
const groups = this.resolveEyePunishGroups();
|
|
247
281
|
const kind = (payload && payload.type) || 'unknown';
|
|
248
282
|
const evidence = String((payload && payload.evidence) || '').slice(0, 120);
|
|
283
|
+
const groups = this.resolveEyePunishGroups();
|
|
249
284
|
if (!groups.length) {
|
|
250
|
-
this._logger.info(`[eye] 收到上报 type=${kind} qq=${qq} 目标群=${(payload && payload.guildId) || '-'} 证据="${evidence}",但 eyePunishGroups
|
|
285
|
+
this._logger.info(`[eye] 收到上报 type=${kind} qq=${qq} 目标群=${(payload && payload.guildId) || '-'} 证据="${evidence}",但 eyePunishGroups 为空 → 不执行处罚`);
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
// 白名单豁免:自己人永远不该被当成「拉人者」处罚。
|
|
289
|
+
// 覆盖三种身份:allowedUserIds 白名单、bot 自身、以及处罚群的群主/管理员。
|
|
290
|
+
// (注意:不是把「拉耳目号进群的人」当好人——而是这些人本来就有权限,
|
|
291
|
+
// 他们拉小号进自己的群属于正常操作。)
|
|
292
|
+
const exempt = await this.isEyeExemptAccount(qq, groups);
|
|
293
|
+
if (exempt) {
|
|
294
|
+
this._logger.info(`[eye] qq=${qq} 命中白名单/管理员豁免(${exempt}),跳过处罚 | 证据="${evidence}"`);
|
|
251
295
|
return;
|
|
252
296
|
}
|
|
253
297
|
// 冷却:同一个人短时间内不重复处罚
|
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.14",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
7
7
|
"files": [
|