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.
Files changed (2) hide show
  1. package/lib/index.js +16 -11
  2. 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:1"),
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
- const curTime = eventData.time || 0;
206
- for (const task of activeTasks.values()) {
207
- const o = task.session.event?._data || {};
208
- if (Math.abs(curTime - (o.time || 0)) < 300) {
209
- if (task.kind === kind && o.self_id === eventData.self_id && o.user_id === eventData.user_id && o.group_id === eventData.group_id && o.comment === eventData.comment) {
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
- return;
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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-onebot-verifier",
3
3
  "description": "[仅支持 Onebot 平台]支持好友申请/群组邀请/加群请求等的自动审核,可根据等级与正则进行筛选,并有入群验证码、投票表决、被踢清理等功能。",
4
- "version": "1.2.2",
4
+ "version": "1.2.4",
5
5
  "contributors": [
6
6
  "Yis_Rime <yis_rime@outlook.com>"
7
7
  ],