koishi-plugin-onebot-verifier 1.2.9 → 1.2.10

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 +14 -12
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -211,9 +211,11 @@ function apply(ctx, config) {
211
211
  const eventData = session.event?._data || {};
212
212
  if (eventData.user_id) session.userId = String(eventData.user_id);
213
213
  if (eventData.group_id) session.guildId = String(eventData.group_id);
214
+ const isApply = kind === "guild" && eventData.post_type === "request" && !!eventData.invited_id && String(eventData.invited_id) !== String(eventData.self_id);
215
+ if (isApply) session.userId = String(eventData.invited_id);
214
216
  if (session.guildId && config.blacklist?.includes(session.guildId)) return;
215
217
  try {
216
- if (config.debugMode) logger.info(`[请求] 类型: ${kind} 数据: ${JSON.stringify(eventData)}`);
218
+ if (config.debugMode) logger.info(`[请求] 类型: ${isApply ? "member" : kind} 数据: ${JSON.stringify(eventData)}`);
217
219
  const verifyText = getComment(eventData.comment);
218
220
  if (kind === "friend") {
219
221
  const existingTask = [...activeTasks.values()].find((t) => t.kind === "friend" && t.session.userId === session.userId);
@@ -242,7 +244,7 @@ function apply(ctx, config) {
242
244
  existingTask.messages.forEach((id) => activeTasks.delete(id));
243
245
  }
244
246
  }
245
- if (kind === "member") {
247
+ if (isApply || kind === "member") {
246
248
  const rules = config.verifyRules?.filter((r) => r.guildId === session.guildId) || [];
247
249
  for (const rule of rules) {
248
250
  const stats = (rule.minLevel ?? 0) > 0 && session.onebot && session.userId ? await session.onebot.getStrangerInfo(session.userId, true).catch(() => ({})) : null;
@@ -257,32 +259,32 @@ function apply(ctx, config) {
257
259
  const isFrequent = rule.frequency && Date.now() - lastLeaveTime < rule.frequency * 6e4;
258
260
  if (isFrequent) {
259
261
  if (config.frequencyMode === "reject") {
260
- await executeAction(session, kind, false, "频繁申请,自动拒绝");
261
- await sendNotice(session, kind, "auto_reject");
262
+ await executeAction(session, isApply ? "member" : kind, false, "频繁申请,自动拒绝");
263
+ await sendNotice(session, isApply ? "member" : kind, "auto_reject");
262
264
  return;
263
265
  } else if (config.frequencyMode === "ignore") {
264
- return await setupManual(session, kind);
266
+ return await setupManual(session, isApply ? "member" : kind);
265
267
  } else if (config.frequencyMode === "delay") {
266
- return await setupManual(session, kind, void 0, false, rule.action === "accept");
268
+ return await setupManual(session, isApply ? "member" : kind, void 0, false, rule.action === "accept");
267
269
  }
268
270
  }
269
271
  if (rule.action) {
270
- await executeAction(session, kind, rule.action === "accept", rule.action === "accept" ? "" : "错误回答,自动拒绝");
271
- await sendNotice(session, kind, rule.action === "accept" ? "auto_pass" : "auto_reject");
272
+ await executeAction(session, isApply ? "member" : kind, rule.action === "accept", rule.action === "accept" ? "" : "错误回答,自动拒绝");
273
+ await sendNotice(session, isApply ? "member" : kind, rule.action === "accept" ? "auto_pass" : "auto_reject");
272
274
  return;
273
275
  }
274
276
  }
275
277
  }
276
278
  const specialRule = config.specialRules?.find((r) => r.guildId === session.guildId);
277
279
  if (specialRule) {
278
- if (specialRule.mode === "vote") return await setupManual(session, kind, "vote", config.voteInSitu);
280
+ if (specialRule.mode === "vote") return await setupManual(session, isApply ? "member" : kind, "vote", config.voteInSitu);
279
281
  if (specialRule.mode === "captcha") {
280
- await executeAction(session, kind, true, "验证码验证,自动通过");
281
- await sendNotice(session, kind, "auto_pass");
282
+ await executeAction(session, isApply ? "member" : kind, true, "验证码验证,自动通过");
283
+ await sendNotice(session, isApply ? "member" : kind, "auto_pass");
282
284
  return;
283
285
  }
284
286
  }
285
- return await setupManual(session, kind);
287
+ return await setupManual(session, isApply ? "member" : kind);
286
288
  }
287
289
  let verdict = false;
288
290
  if (kind === "friend") {
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.9",
4
+ "version": "1.2.10",
5
5
  "contributors": [
6
6
  "Yis_Rime <yis_rime@outlook.com>"
7
7
  ],