koishi-plugin-group-verification 1.0.32 → 1.0.33

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 CHANGED
@@ -882,7 +882,7 @@ function apply(ctx, config) {
882
882
  userId: "string",
883
883
  userName: "string",
884
884
  requestMessage: "string",
885
- // store the raw requestId if provided by OneBot event; used for approving/rejecting
885
+ // 保存 OneBot 事件提供的原始 requestId;用于同意/拒绝操作
886
886
  requestId: "string",
887
887
  // record full timestamp as string to keep time component
888
888
  applyTime: "string"
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "bugs": {
9
9
  "url": "https://github.com/LHDyx/koishi-plugin-group-verification/issues"
10
10
  },
11
- "version": "1.0.32",
11
+ "version": "1.0.33",
12
12
  "main": "lib/index.js",
13
13
  "typings": "lib/index.d.ts",
14
14
  "files": [
package/readme.md CHANGED
@@ -134,6 +134,22 @@ group-verify.blacklist i <用户ID> [群号|all]
134
134
 
135
135
  ## ⚙️ 参数说明
136
136
 
137
+ ### 日志级别配置
138
+
139
+ 插件启动时会输出运行状态,并根据 `logLevel` 调整输出量。
140
+ - `debug`:打印所有调试细节,包括权限检查、命令解析等。
141
+ - `info`:默认值,记录关键事件(插件启动、配置修改、自动拒绝、黑名单踢人等)。
142
+ - `warn`:记录可恢复的异常,例如尝试踢出用户失败、数据库操作问题。
143
+ - `error`:仅在遇到严重错误时输出。
144
+
145
+ 添加黑名单时会尝试在对应群踢出该用户,成功记为 `info`,失败记为 `warn`。
146
+
147
+ ### 严格群号检查
148
+
149
+ `enableStrictGroupCheck` 可开启简单群号格式验证(长度 5‑15 位),
150
+ 影响所有需要群号的命令。
151
+
152
+
137
153
  ### 审核方式 (-m)
138
154
 
139
155
  *如果改变审核方式而未提供 `-t`,阈值会自动设置为最大值(方式1为关键词数量,方式2为100)。*
package/src/index.ts CHANGED
@@ -57,7 +57,7 @@ export interface PendingVerification {
57
57
  userId: string
58
58
  userName: string
59
59
  requestMessage: string
60
- // raw OneBot requestId (may be empty string)
60
+ // 原始 OneBot requestId(字符串可能为空)
61
61
  requestId?: string
62
62
  applyTime: string | Date
63
63
  }
@@ -104,11 +104,11 @@ export const inject = ['database']
104
104
  */
105
105
  export interface TokenizeResult {
106
106
  tokens: string[];
107
- seps: string[]; // separator that preceded each token: ' ' or ',' or '' (start)
107
+ seps: string[]; // 每个令牌前面的分隔符:' ' ',' ''(表示开始)
108
108
  error?: string;
109
109
  }
110
110
 
111
- // Sentinel characters used internally to distinguish escaped quotes/backslashes
111
+ // 内部哨兵字符,用于区分转义的引号或反斜杠
112
112
  const ESC_QUOTE = '\u0000';
113
113
  const ESC_BACKSLASH = '\u0001';
114
114
 
@@ -116,7 +116,7 @@ export function tokenize(input: string): TokenizeResult {
116
116
  const tokens: string[] = [];
117
117
  const seps: string[] = [];
118
118
  let cur = '';
119
- let lastSep = ''; // separator before current token
119
+ let lastSep = ''; // 当前令牌之前的分隔符
120
120
  let i = 0;
121
121
 
122
122
  const flush = () => {
@@ -131,7 +131,7 @@ export function tokenize(input: string): TokenizeResult {
131
131
  while (i < input.length) {
132
132
  const ch = input[i];
133
133
  if (ch === ' ' || ch === ',') {
134
- // record separator for next token
134
+ // 记录下一个令牌的分隔符
135
135
  lastSep = ch;
136
136
  flush();
137
137
  i++;
@@ -226,7 +226,7 @@ export interface ParsedArgs {
226
226
  /**
227
227
  * 验证关键词格式:仅允许用逗号和引号分隔,禁止纯空格分隔
228
228
  */
229
- // helper used during parsing
229
+ // 解析过程中使用的辅助函数
230
230
  function validateKeywordFormat(raw: string): boolean {
231
231
  if (raw.includes(',') || raw.includes('"')) {
232
232
  return true;
@@ -403,7 +403,8 @@ export async function incrementTotal(ctx: Context, groupId: string) {
403
403
  await syncTotalStats(ctx)
404
404
  }
405
405
 
406
- // helper to decide reviewParameters based on existing configuration, keyword list, user inputs,
406
+ // 根据已有配置、关键词列表及用户输入确定阈值参数的辅助函数,
407
+ // 并处理审核方式更改所致的自动调整
407
408
  // and whether the audit method has been changed by the command.
408
409
  export interface ThresholdResult {
409
410
  reviewParameters: number
@@ -603,7 +604,7 @@ export function parseConfigArgs(raw: string): ParsedArgs {
603
604
 
604
605
  const isFlag = (tok: string) => /^-(?:i|m|t|msg|nomsg|\?|r)$/.test(tok);
605
606
 
606
- // catch unescaped stray quotes before we unescape the sentinel symbols
607
+ // 在还原哨兵字符之前处理未转义的杂散引号
607
608
  for (const tok of tokens) {
608
609
  if (tok.includes('"')) {
609
610
  error = '存在未转义的引号';
@@ -611,7 +612,7 @@ export function parseConfigArgs(raw: string): ParsedArgs {
611
612
  }
612
613
  }
613
614
 
614
- // unescape sentinel placeholders back to real characters
615
+ // 将哨兵占位符还原为真实字符
615
616
  tokens = tokens.map(t =>
616
617
  t.replace(new RegExp(ESC_QUOTE, 'g'), '"').replace(new RegExp(ESC_BACKSLASH, 'g'), '\\')
617
618
  );
@@ -781,7 +782,7 @@ export async function handleFailedVerification(
781
782
  // 无法获取群名称时使用默认值
782
783
  }
783
784
 
784
- // extract requestId if available (OneBot event attaches it)
785
+ // 如果可用则提取 requestIdOneBot 事件会附带)
785
786
  const requestId = ((session.event as any)?.requestId) || session.messageId || ''
786
787
 
787
788
  // 删除同一用户在该群之前的所有待审核记录,保留最新一个
@@ -1014,7 +1015,7 @@ export async function processBlacklistCommand(ctx: Context, session: any, rawArg
1014
1015
  const globalRows = await ctx.database.get('group_verification_blacklist', { groupId: 'all' })
1015
1016
  const globalHit = globalRows.length > 0 && (globalRows[0].entries || {})[targetUser] !== undefined
1016
1017
 
1017
- // helper to format reply using template
1018
+ // 使用模板格式化回复的辅助函数
1018
1019
  const tmpl = (config && config.blacklistInfoTemplate) || '全局黑名单: {global}\n本群黑名单: {group}'
1019
1020
  const formatReply = (localHit: boolean, groupsList?: string[]) => {
1020
1021
  if (groupsList) {
@@ -1132,7 +1133,7 @@ export function apply(ctx: Context, config: Config) {
1132
1133
  userId: 'string',
1133
1134
  userName: 'string',
1134
1135
  requestMessage: 'string',
1135
- // store the raw requestId if provided by OneBot event; used for approving/rejecting
1136
+ // 保存 OneBot 事件提供的原始 requestId;用于同意/拒绝操作
1136
1137
  requestId: 'string',
1137
1138
  // record full timestamp as string to keep time component
1138
1139
  applyTime: 'string'