koishi-plugin-onebot-verifier 1.1.4 → 1.1.6
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 +4 -5
- package/lib/index.js +19 -22
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -3,18 +3,17 @@ export declare const name = "onebot-verifier";
|
|
|
3
3
|
export declare const inject: {
|
|
4
4
|
optional: string[];
|
|
5
5
|
};
|
|
6
|
-
export declare const usage = "\n<div style=\"border-radius: 10px; border: 1px solid #ddd; padding: 16px; margin-bottom: 20px; box-shadow: 0 2px 5px rgba(0,0,0,0.1);\">\n <h2 style=\"margin-top: 0; color: #4a6ee0;\">\uD83D\uDCCC \u63D2\u4EF6\u8BF4\u660E</h2>\n <p>\uD83D\uDCD6 <strong>\u4F7F\u7528\u6587\u6863</strong>\uFF1A\u8BF7\u70B9\u51FB\u5DE6\u4E0A\u89D2\u7684 <strong>\u63D2\u4EF6\u4E3B\u9875</strong> \u67E5\u770B\u63D2\u4EF6\u4F7F\u7528\u6587\u6863</p>\n <p>\uD83D\uDD0D <strong>\u66F4\u591A\u63D2\u4EF6</strong>\uFF1A\u53EF\u8BBF\u95EE <a href=\"https://github.com/YisRime\" style=\"color:#4a6ee0;text-decoration:none;\">\u82E1\u6DDE\u7684 GitHub</a> \u67E5\u770B\u672C\u4EBA\u7684\u6240\u6709\u63D2\u4EF6</p>\n</div>\n<div style=\"border-radius: 10px; border: 1px solid #ddd; padding: 16px; margin-bottom: 20px; box-shadow: 0 2px 5px rgba(0,0,0,0.1);\">\n <h2 style=\"margin-top: 0; color: #e0574a;\">\u2764\uFE0F \u652F\u6301\u4E0E\u53CD\u9988</h2>\n <p>\uD83C\uDF1F \u559C\u6B22\u8FD9\u4E2A\u63D2\u4EF6\uFF1F\u8BF7\u5728 <a href=\"https://github.com/YisRime\" style=\"color:#e0574a;text-decoration:none;\">GitHub</a> \u4E0A\u7ED9\u6211\u4E00\u4E2A Star\uFF01</p>\n <p>\uD83D\uDC1B \u9047\u5230\u95EE\u9898\uFF1F\u8BF7\u901A\u8FC7 <strong>Issues</strong> \u63D0\u4EA4\u53CD\u9988\uFF0C\u6216\u52A0\u5165 QQ \u7FA4 <a href=\"https://qm.qq.com/q/PdLMx9Jowq\" style=\"color:#e0574a;text-decoration:none;\"><strong>855571375</strong></a> \u8FDB\u884C\u4EA4\u6D41</p>\n</div>\n";
|
|
6
|
+
export declare const usage = "\n<div style=\"border-radius: 10px; border: 1px solid #ddd; padding: 16px; margin-bottom: 20px; box-shadow: 0 2px 5px rgba(0,0,0,0.1);\">\n <h2 style=\"margin-top: 0; color: #4a6ee0;\">\uD83D\uDCCC \u63D2\u4EF6\u8BF4\u660E</h2>\n <p>\uD83D\uDCD6 <strong>\u4F7F\u7528\u6587\u6863</strong>\uFF1A\u8BF7\u70B9\u51FB\u5DE6\u4E0A\u89D2\u7684 <strong>\u63D2\u4EF6\u4E3B\u9875</strong> \u67E5\u770B\u63D2\u4EF6\u4F7F\u7528\u6587\u6863</p>\n <p>\uD83D\uDD0D <strong>\u66F4\u591A\u63D2\u4EF6</strong>\uFF1A\u53EF\u8BBF\u95EE <a href=\"https://github.com/YisRime\" style=\"color:#4a6ee0;text-decoration:none;\">\u82E1\u6DDE\u7684 GitHub</a> \u67E5\u770B\u672C\u4EBA\u7684\u6240\u6709\u63D2\u4EF6</p>\n</div>\n<div style=\"border-radius: 10px; border: 1px solid #ddd; padding: 16px; margin-bottom: 20px; box-shadow: 0 2px 5px rgba(0,0,0,0.1);\">\n <h2 style=\"margin-top: 0; color: #e0574a;\">\u2764\uFE0F \u652F\u6301\u4E0E\u53CD\u9988</h2>\n <p>\uD83C\uDF1F \u559C\u6B22\u8FD9\u4E2A\u63D2\u4EF6\uFF1F\u8BF7\u5728 <a href=\"https://github.com/YisRime\" style=\"color:#e0574a;text-decoration:none;\">GitHub</a> \u4E0A\u7ED9\u6211\u4E00\u4E2A Star\uFF01</p>\n <p>\uD83D\uDC1B \u9047\u5230\u95EE\u9898\uFF1F\u8BF7\u901A\u8FC7 <strong>Issues</strong> \u63D0\u4EA4\u53CD\u9988\uFF0C\u6216\u52A0\u5165 QQ \u7FA4 <a href=\"https://qm.qm.qq.com/q/PdLMx9Jowq\" style=\"color:#e0574a;text-decoration:none;\"><strong>855571375</strong></a> \u8FDB\u884C\u4EA4\u6D41</p>\n</div>\n";
|
|
7
7
|
export interface Config {
|
|
8
8
|
notifyTarget?: string;
|
|
9
9
|
debugMode?: boolean;
|
|
10
10
|
kickBan?: boolean;
|
|
11
|
-
|
|
12
|
-
timeoutAction?: 'accept' | 'reject';
|
|
11
|
+
friendTimeout: false | number;
|
|
13
12
|
friendLevel?: number;
|
|
14
13
|
friendRegex?: string;
|
|
15
14
|
minMembers?: number;
|
|
16
15
|
maxCapacity?: number;
|
|
17
|
-
|
|
16
|
+
memberTimeout: false | number;
|
|
18
17
|
verifyRules?: {
|
|
19
18
|
guildId: string;
|
|
20
19
|
keyword?: string;
|
|
@@ -31,4 +30,4 @@ export interface Config {
|
|
|
31
30
|
voteInSitu?: boolean;
|
|
32
31
|
}
|
|
33
32
|
export declare const Config: Schema<Config>;
|
|
34
|
-
export declare function apply(ctx: Context, config
|
|
33
|
+
export declare function apply(ctx: Context, config: Config): void;
|
package/lib/index.js
CHANGED
|
@@ -39,7 +39,7 @@ var usage = `
|
|
|
39
39
|
<div style="border-radius: 10px; border: 1px solid #ddd; padding: 16px; margin-bottom: 20px; box-shadow: 0 2px 5px rgba(0,0,0,0.1);">
|
|
40
40
|
<h2 style="margin-top: 0; color: #e0574a;">❤️ 支持与反馈</h2>
|
|
41
41
|
<p>🌟 喜欢这个插件?请在 <a href="https://github.com/YisRime" style="color:#e0574a;text-decoration:none;">GitHub</a> 上给我一个 Star!</p>
|
|
42
|
-
<p>🐛 遇到问题?请通过 <strong>Issues</strong> 提交反馈,或加入 QQ 群 <a href="https://qm.qq.com/q/PdLMx9Jowq" style="color:#e0574a;text-decoration:none;"><strong>855571375</strong></a> 进行交流</p>
|
|
42
|
+
<p>🐛 遇到问题?请通过 <strong>Issues</strong> 提交反馈,或加入 QQ 群 <a href="https://qm.qm.qq.com/q/PdLMx9Jowq" style="color:#e0574a;text-decoration:none;"><strong>855571375</strong></a> 进行交流</p>
|
|
43
43
|
</div>
|
|
44
44
|
`;
|
|
45
45
|
var Config = import_koishi.Schema.intersect([
|
|
@@ -49,22 +49,20 @@ var Config = import_koishi.Schema.intersect([
|
|
|
49
49
|
kickBan: import_koishi.Schema.boolean().description("被踢自动处理").default(false)
|
|
50
50
|
}).description("基础配置"),
|
|
51
51
|
import_koishi.Schema.object({
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
import_koishi.Schema.
|
|
55
|
-
|
|
56
|
-
]).description("默认超时操作").default("accept"),
|
|
52
|
+
friendTimeout: import_koishi.Schema.union([
|
|
53
|
+
import_koishi.Schema.const(false).description("手动"),
|
|
54
|
+
import_koishi.Schema.number().description("正数同意/负数拒绝").default(360)
|
|
55
|
+
]).description("超时处理").default(false),
|
|
57
56
|
friendLevel: import_koishi.Schema.number().description("最低好友等级").default(0).min(0).max(256),
|
|
58
57
|
friendRegex: import_koishi.Schema.string().description("好友验证正则"),
|
|
59
58
|
minMembers: import_koishi.Schema.number().description("最低群成员数").default(0).min(0).max(3e3),
|
|
60
59
|
maxCapacity: import_koishi.Schema.number().description("最低受邀容量").default(0).min(0).max(3e3)
|
|
61
60
|
}).description("好友邀群配置"),
|
|
62
61
|
import_koishi.Schema.object({
|
|
63
|
-
|
|
64
|
-
import_koishi.Schema.const(
|
|
65
|
-
import_koishi.Schema.
|
|
66
|
-
|
|
67
|
-
]).description("处理模式").default("manual"),
|
|
62
|
+
memberTimeout: import_koishi.Schema.union([
|
|
63
|
+
import_koishi.Schema.const(false).description("手动"),
|
|
64
|
+
import_koishi.Schema.number().description("正数同意/负数拒绝").default(360)
|
|
65
|
+
]).description("超时处理").default(false),
|
|
68
66
|
verifyRules: import_koishi.Schema.array(import_koishi.Schema.object({
|
|
69
67
|
guildId: import_koishi.Schema.string().description("群号").required(),
|
|
70
68
|
keyword: import_koishi.Schema.string().description("正则"),
|
|
@@ -93,7 +91,7 @@ var Config = import_koishi.Schema.intersect([
|
|
|
93
91
|
]).description("[验证]难度").default("simple")
|
|
94
92
|
}).description("特殊验证配置")
|
|
95
93
|
]);
|
|
96
|
-
function apply(ctx, config
|
|
94
|
+
function apply(ctx, config) {
|
|
97
95
|
const logger = new import_koishi.Logger("onebot-verifier");
|
|
98
96
|
const activeTasks = /* @__PURE__ */ new Map();
|
|
99
97
|
const activeCaptchas = /* @__PURE__ */ new Map();
|
|
@@ -158,8 +156,7 @@ function apply(ctx, config = {}) {
|
|
|
158
156
|
}
|
|
159
157
|
}, "sendNotice");
|
|
160
158
|
const setupManual = /* @__PURE__ */ __name(async (session, kind, specialMode, useInSitu) => {
|
|
161
|
-
const
|
|
162
|
-
const action = kind === "member" ? config.verifyMode : config.timeoutAction;
|
|
159
|
+
const timeoutCfg = kind === "member" ? config.memberTimeout : config.friendTimeout;
|
|
163
160
|
let targetStr = config.notifyTarget || "";
|
|
164
161
|
if (useInSitu && kind === "member" && session.guildId) targetStr = `guild:${session.guildId}`;
|
|
165
162
|
const msgIds = await sendNotice(session, kind, "waiting", targetStr);
|
|
@@ -171,22 +168,22 @@ function apply(ctx, config = {}) {
|
|
|
171
168
|
task.votes = { yes: /* @__PURE__ */ new Set(), no: /* @__PURE__ */ new Set() };
|
|
172
169
|
}
|
|
173
170
|
msgIds.forEach((id) => activeTasks.set(id, task));
|
|
174
|
-
if (
|
|
171
|
+
if (typeof timeoutCfg === "number") {
|
|
172
|
+
const waitMinutes = Math.abs(timeoutCfg);
|
|
173
|
+
const isPass = timeoutCfg > 0;
|
|
175
174
|
task.timer = setTimeout(async () => {
|
|
176
175
|
if (!activeTasks.has(msgIds[0])) return;
|
|
177
176
|
msgIds.forEach((id) => activeTasks.delete(id));
|
|
178
|
-
let
|
|
179
|
-
if (specialMode === "vote"
|
|
180
|
-
|
|
181
|
-
const isPass = finalAction === "accept";
|
|
182
|
-
await executeAction(session, kind, isPass, isPass ? "" : "等待超时,自动拒绝");
|
|
177
|
+
let finalActionPass = isPass;
|
|
178
|
+
if (specialMode === "vote") finalActionPass = false;
|
|
179
|
+
await executeAction(session, kind, finalActionPass, finalActionPass ? "" : "等待超时,自动拒绝");
|
|
183
180
|
const [targetType, targetId] = targetStr.split(":");
|
|
184
181
|
if (targetId && session.bot) {
|
|
185
|
-
const statusText = `已自动${
|
|
182
|
+
const statusText = `已自动${finalActionPass ? "通过" : "拒绝"}该请求`;
|
|
186
183
|
await (targetType === "private" ? session.bot.sendPrivateMessage(targetId, statusText) : session.bot.sendMessage(targetId, statusText)).catch(() => {
|
|
187
184
|
});
|
|
188
185
|
}
|
|
189
|
-
if (config.debugMode) logger.info(`[操作] 等待超时,默认${
|
|
186
|
+
if (config.debugMode) logger.info(`[操作] 等待超时,默认${finalActionPass ? "通过" : "拒绝"}`);
|
|
190
187
|
}, waitMinutes * 6e4);
|
|
191
188
|
}
|
|
192
189
|
}, "setupManual");
|