koishi-plugin-onebot-verifier 1.2.7 → 1.2.9
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 -1
- package/lib/index.js +27 -16
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ 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.
|
|
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";
|
|
7
7
|
export interface Config {
|
|
8
8
|
notifyTarget?: string;
|
|
9
9
|
debugMode?: boolean;
|
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.
|
|
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>
|
|
43
43
|
</div>
|
|
44
44
|
`;
|
|
45
45
|
var Config = import_koishi.Schema.intersect([
|
|
@@ -160,7 +160,9 @@ function apply(ctx, config) {
|
|
|
160
160
|
if (kind !== "guild" && kind !== "removed" || session.userId && session.userId !== session.selfId) infoLines.push(`用户:${userInfo?.name || session.userId}${session.userId ? `(${session.userId})` : ""}`);
|
|
161
161
|
if (adminId) infoLines.push(`管理:${adminInfo?.name ? `${adminInfo.name}(${adminId})` : adminId}`);
|
|
162
162
|
if (session.guildId) infoLines.push(`群组:${groupInfo?.name ? `${groupInfo.name}(${session.guildId})` : session.guildId}`);
|
|
163
|
+
if (eventData.invitor_id && String(eventData.invitor_id) !== "0") infoLines.push(`邀请者:${eventData.invitor_id}`);
|
|
163
164
|
if (eventData.comment) infoLines.push(`验证信息:${eventData.comment}`);
|
|
165
|
+
if (eventData.via) infoLines.push(`来源:${eventData.via}`);
|
|
164
166
|
if (status === "waiting" && kind !== "removed") {
|
|
165
167
|
if (specialMode === "vote") infoLines.push(`[投票模式]需${config.voteRatio.split(":")[0]}人同意或${config.voteRatio.split(":")[1]}人拒绝`);
|
|
166
168
|
infoLines.push(`使用"y/n"回复本消息以处理该请求`);
|
|
@@ -212,25 +214,34 @@ function apply(ctx, config) {
|
|
|
212
214
|
if (session.guildId && config.blacklist?.includes(session.guildId)) return;
|
|
213
215
|
try {
|
|
214
216
|
if (config.debugMode) logger.info(`[请求] 类型: ${kind} 数据: ${JSON.stringify(eventData)}`);
|
|
217
|
+
const verifyText = getComment(eventData.comment);
|
|
215
218
|
if (kind === "friend") {
|
|
216
|
-
const
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
219
|
+
const existingTask = [...activeTasks.values()].find((t) => t.kind === "friend" && t.session.userId === session.userId);
|
|
220
|
+
if (existingTask) {
|
|
221
|
+
if (existingTask.timer) clearTimeout(existingTask.timer);
|
|
222
|
+
const oldVerifyText = getComment(existingTask.session.event?._data?.comment);
|
|
223
|
+
if (oldVerifyText === verifyText) {
|
|
224
|
+
existingTask.session = session;
|
|
225
|
+
const timeoutCfg = config.friendTimeout;
|
|
226
|
+
if (typeof timeoutCfg === "number") {
|
|
227
|
+
const isPass = timeoutCfg > 0;
|
|
228
|
+
existingTask.timer = setTimeout(async () => {
|
|
229
|
+
if (!activeTasks.has(existingTask.messages[0])) return;
|
|
230
|
+
existingTask.messages.forEach((id) => activeTasks.delete(id));
|
|
231
|
+
await executeAction(session, "friend", isPass, isPass ? "" : "等待超时,自动拒绝");
|
|
232
|
+
const [targetType, targetId] = (config.notifyTarget || "").split(":");
|
|
233
|
+
if (targetId && session.bot) {
|
|
234
|
+
const statusText = `已自动${isPass ? "通过" : "拒绝"}该请求`;
|
|
235
|
+
await (targetType === "private" ? session.bot.sendPrivateMessage(targetId, statusText) : session.bot.sendMessage(targetId, statusText)).catch(() => {
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
}, Math.abs(timeoutCfg) * 6e4);
|
|
239
|
+
}
|
|
240
|
+
return;
|
|
226
241
|
}
|
|
242
|
+
existingTask.messages.forEach((id) => activeTasks.delete(id));
|
|
227
243
|
}
|
|
228
|
-
if (updatedPending) return;
|
|
229
|
-
const userKey = `friend:${session.userId}`;
|
|
230
|
-
if (historyMap.has(userKey) && now - historyMap.get(userKey) < 3e4) return;
|
|
231
|
-
historyMap.set(userKey, now);
|
|
232
244
|
}
|
|
233
|
-
const verifyText = getComment(eventData.comment);
|
|
234
245
|
if (kind === "member") {
|
|
235
246
|
const rules = config.verifyRules?.filter((r) => r.guildId === session.guildId) || [];
|
|
236
247
|
for (const rule of rules) {
|
package/package.json
CHANGED