koishi-plugin-onebot-verifier 1.2.5 → 1.2.7
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.d.ts +1 -0
- package/lib/index.js +14 -8
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -46,7 +46,8 @@ var Config = import_koishi.Schema.intersect([
|
|
|
46
46
|
import_koishi.Schema.object({
|
|
47
47
|
notifyTarget: import_koishi.Schema.string().description("通知目标(guild/private:number)").required(),
|
|
48
48
|
debugMode: import_koishi.Schema.boolean().description("输出调试日志").default(false),
|
|
49
|
-
kickBan: import_koishi.Schema.boolean().description("被踢自动处理").default(false)
|
|
49
|
+
kickBan: import_koishi.Schema.boolean().description("被踢自动处理").default(false),
|
|
50
|
+
blacklist: import_koishi.Schema.array(import_koishi.Schema.string()).description("群组黑名单").role("table")
|
|
50
51
|
}).description("基础配置"),
|
|
51
52
|
import_koishi.Schema.object({
|
|
52
53
|
friendTimeout: import_koishi.Schema.union([
|
|
@@ -113,10 +114,13 @@ function apply(ctx, config) {
|
|
|
113
114
|
const eventData = session.event?._data || {};
|
|
114
115
|
if (config.debugMode) logger.info(`[操作] 类型: ${kind} 结果: ${pass ? "同意" : "拒绝"} 原因: ${reason || "无"}`);
|
|
115
116
|
if (pass && kind === "guild" && session.guildId && session.userId) inviterMap.set(session.guildId, session.userId);
|
|
116
|
-
if (!pass && kind === "guild" && session.
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
|
|
117
|
+
if (!pass && kind === "guild" && session.bot) {
|
|
118
|
+
const targetId = eventData.operator_id || session.event?.operator?.id || session.userId;
|
|
119
|
+
if (targetId) {
|
|
120
|
+
const rejectMsg = `已拒绝该群组邀请${reason ? `,原因:${reason}` : ""}`;
|
|
121
|
+
await session.bot.sendPrivateMessage(targetId, rejectMsg).catch(() => {
|
|
122
|
+
});
|
|
123
|
+
}
|
|
120
124
|
}
|
|
121
125
|
if (!pass && kind === "guild" && session.guildId && (session.event?.type === "guild-added" || eventData.notice_type === "group_increase")) {
|
|
122
126
|
if (reason) await session.bot?.sendMessage(session.guildId, `${reason},将退出该群`).catch(() => {
|
|
@@ -148,7 +152,7 @@ function apply(ctx, config) {
|
|
|
148
152
|
const groupInfo = kind !== "friend" && session.guildId ? await session.bot.getGuild?.(session.guildId).catch(() => null) : null;
|
|
149
153
|
const adminId = String(eventData.operator_id || session.event?.operator?.id || "");
|
|
150
154
|
const adminInfo = adminId && adminId !== session.userId ? await session.bot.getUser?.(adminId).catch(() => null) : null;
|
|
151
|
-
const typeMap = { friend: "好友申请", member: "加群请求", guild: eventData.post_type === "notice" ? "群组邀请 (
|
|
155
|
+
const typeMap = { friend: "好友申请", member: "加群请求", guild: eventData.post_type === "notice" ? "群组邀请 (审核)" : "群组邀请 (请求)", removed: eventData.sub_type === "kick_me" ? "移出群组" : "退出群组" };
|
|
152
156
|
const statusMap = { auto_pass: " [自动通过]", auto_reject: " [自动拒绝]", waiting: " [等待处理]" };
|
|
153
157
|
const infoLines = [];
|
|
154
158
|
if (userInfo?.avatar) infoLines.push(`<image url="${userInfo.avatar}"/>`);
|
|
@@ -205,6 +209,7 @@ function apply(ctx, config) {
|
|
|
205
209
|
const eventData = session.event?._data || {};
|
|
206
210
|
if (eventData.user_id) session.userId = String(eventData.user_id);
|
|
207
211
|
if (eventData.group_id) session.guildId = String(eventData.group_id);
|
|
212
|
+
if (session.guildId && config.blacklist?.includes(session.guildId)) return;
|
|
208
213
|
try {
|
|
209
214
|
if (config.debugMode) logger.info(`[请求] 类型: ${kind} 数据: ${JSON.stringify(eventData)}`);
|
|
210
215
|
if (kind === "friend") {
|
|
@@ -348,11 +353,11 @@ function apply(ctx, config) {
|
|
|
348
353
|
ctx.on("guild-member-request", hookEvent("member"));
|
|
349
354
|
ctx.on("guild-added", hookEvent("guild"));
|
|
350
355
|
ctx.on("guild-member-removed", async (session) => {
|
|
351
|
-
if (!session.guildId || !session.userId) return;
|
|
356
|
+
if (!session.guildId || !session.userId || config.blacklist?.includes(session.guildId)) return;
|
|
352
357
|
if (config.verifyRules?.some((r) => r.guildId === session.guildId)) historyMap.set(`${session.userId}:${session.guildId}`, Date.now());
|
|
353
358
|
});
|
|
354
359
|
ctx.on("guild-member-added", async (session) => {
|
|
355
|
-
if (!config.specialRules || !session.guildId || !session.userId) return;
|
|
360
|
+
if (!config.specialRules || !session.guildId || !session.userId || config.blacklist?.includes(session.guildId)) return;
|
|
356
361
|
const rule = config.specialRules.find((r) => r.guildId === session.guildId);
|
|
357
362
|
if (rule?.mode === "captcha") {
|
|
358
363
|
let a, b, op = "+", answer;
|
|
@@ -391,6 +396,7 @@ function apply(ctx, config) {
|
|
|
391
396
|
});
|
|
392
397
|
ctx.on("guild-removed", async (session) => {
|
|
393
398
|
if (session.guildId) {
|
|
399
|
+
if (config.blacklist?.includes(session.guildId)) return;
|
|
394
400
|
const eventData = session.event?._data || {};
|
|
395
401
|
if (config.debugMode) logger.info(`[事件] 退出: ${session.guildId} 数据: ${JSON.stringify(eventData)}`);
|
|
396
402
|
if (eventData.sub_type === "kick_me") {
|
package/package.json
CHANGED