koishi-plugin-onebot-verifier 1.2.2 → 1.2.4
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 +16 -11
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -88,7 +88,7 @@ var Config = import_koishi.Schema.intersect([
|
|
|
88
88
|
}).description("加群请求配置"),
|
|
89
89
|
import_koishi.Schema.object({
|
|
90
90
|
voteInSitu: import_koishi.Schema.boolean().description("[投票]原群投票模式").default(true),
|
|
91
|
-
voteRatio: import_koishi.Schema.string().description("[投票]支持/反对人数").default("5:
|
|
91
|
+
voteRatio: import_koishi.Schema.string().description("[投票]支持/反对人数").default("5:2"),
|
|
92
92
|
captchaDiff: import_koishi.Schema.union([
|
|
93
93
|
import_koishi.Schema.const("simple").description("简单"),
|
|
94
94
|
import_koishi.Schema.const("medium").description("中等"),
|
|
@@ -143,7 +143,7 @@ function apply(ctx, config) {
|
|
|
143
143
|
const groupInfo = kind !== "friend" && session.guildId ? await session.bot.getGuild?.(session.guildId).catch(() => null) : null;
|
|
144
144
|
const adminId = String(eventData.operator_id || session.event?.operator?.id || "");
|
|
145
145
|
const adminInfo = adminId && adminId !== session.userId ? await session.bot.getUser?.(adminId).catch(() => null) : null;
|
|
146
|
-
const typeMap = { friend: "好友申请", member: "加群请求", guild: "群组邀请", removed: eventData.sub_type === "kick_me" ? "移出群组" : "退出群组" };
|
|
146
|
+
const typeMap = { friend: "好友申请", member: "加群请求", guild: eventData.post_type === "notice" ? "群组邀请 [通过]" : "群组邀请 [请求]", removed: eventData.sub_type === "kick_me" ? "移出群组" : "退出群组" };
|
|
147
147
|
const statusMap = { auto_pass: " [自动通过]", auto_reject: " [自动拒绝]", waiting: " [等待处理]" };
|
|
148
148
|
const infoLines = [];
|
|
149
149
|
if (userInfo?.avatar) infoLines.push(`<image url="${userInfo.avatar}"/>`);
|
|
@@ -202,15 +202,23 @@ function apply(ctx, config) {
|
|
|
202
202
|
if (eventData.group_id) session.guildId = String(eventData.group_id);
|
|
203
203
|
try {
|
|
204
204
|
if (config.debugMode) logger.info(`[请求] 类型: ${kind} 数据: ${JSON.stringify(eventData)}`);
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
const
|
|
208
|
-
|
|
209
|
-
|
|
205
|
+
if (kind === "friend") {
|
|
206
|
+
const flag = eventData.flag || `${session.userId}:${eventData.time}`;
|
|
207
|
+
const now = Date.now();
|
|
208
|
+
const flagKey = `flag:${flag}`;
|
|
209
|
+
if (historyMap.has(flagKey) && now - historyMap.get(flagKey) < 3e4) return;
|
|
210
|
+
historyMap.set(flagKey, now);
|
|
211
|
+
let updatedPending = false;
|
|
212
|
+
for (const task of new Set(activeTasks.values())) {
|
|
213
|
+
if (task.kind === "friend" && task.session.userId === session.userId) {
|
|
210
214
|
task.session = session;
|
|
211
|
-
|
|
215
|
+
updatedPending = true;
|
|
212
216
|
}
|
|
213
217
|
}
|
|
218
|
+
if (updatedPending) return;
|
|
219
|
+
const userKey = `friend:${session.userId}`;
|
|
220
|
+
if (historyMap.has(userKey) && now - historyMap.get(userKey) < 3e4) return;
|
|
221
|
+
historyMap.set(userKey, now);
|
|
214
222
|
}
|
|
215
223
|
const verifyText = getComment(eventData.comment);
|
|
216
224
|
if (kind === "member") {
|
|
@@ -379,9 +387,6 @@ function apply(ctx, config) {
|
|
|
379
387
|
ctx.on("guild-removed", async (session) => {
|
|
380
388
|
if (session.guildId) {
|
|
381
389
|
const eventData = session.event?._data || {};
|
|
382
|
-
const curTime = eventData.time || 0;
|
|
383
|
-
if (Math.abs(curTime - (historyMap.get(session.guildId) || 0)) < 300) return;
|
|
384
|
-
historyMap.set(session.guildId, curTime);
|
|
385
390
|
if (config.debugMode) logger.info(`[事件] 退出: ${session.guildId} 数据: ${JSON.stringify(eventData)}`);
|
|
386
391
|
if (eventData.sub_type === "kick_me") {
|
|
387
392
|
const inviterId = inviterMap.get(session.guildId);
|
package/package.json
CHANGED