koishi-plugin-group-verification 1.0.11 → 1.0.13

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 (3) hide show
  1. package/lib/index.js +71 -23
  2. package/package.json +1 -1
  3. package/src/index.ts +62 -23
package/lib/index.js CHANGED
@@ -251,7 +251,15 @@ ${debugInfo}`];
251
251
  }
252
252
  __name(checkPermission, "checkPermission");
253
253
  const groupVerify = ctx.command("group-verify", "群组验证管理命令").alias("gv", "gverify");
254
- groupVerify.subcommand(".config [keywords:text]", "配置群组验证规则").alias("cfg", "配置", "conf", "设置").option("groupId", "-i <groupId> 指定群号").option("method", "-m <method> 审核方式 (0-3)").option("threshold", "-t <threshold> 阈值参数").option("message", "-msg <message> 自定义提醒消息").option("query", "-? 查询当前配置").option("remove", "-r 删除配置").action(async ({ session, options }, keywords) => {
254
+ groupVerify.subcommand(".config [keywords:text]", "配置群组验证规则").alias(
255
+ "gv.cfg",
256
+ "gverify.cfg",
257
+ "group-verify.cfg",
258
+ "gv.配置",
259
+ "gverify.配置",
260
+ "group-verify.配置",
261
+ "gvc"
262
+ ).option("groupId", "-i <groupId> 指定群号").option("method", "-m <method> 审核方式 (0-3)").option("threshold", "-t <threshold> 阈值参数").option("message", "-msg <message> 自定义提醒消息").option("query", "-? 查询当前配置").option("remove", "-r 删除配置").action(async ({ session, options }, keywords) => {
255
263
  const targetGroupId = options.groupId || session.guildId;
256
264
  const [hasPermission, errorMsg] = await checkPermission(session, targetGroupId);
257
265
  if (!hasPermission) {
@@ -313,9 +321,17 @@ ${debugInfo}`];
313
321
  return `群 ${targetGroupId} 无验证配置`;
314
322
  }
315
323
  }
316
- const keywordList = keywords ? keywords.split(",").map((k) => k.trim()).filter((k) => k) : [];
317
- if (keywordList.length === 0 && !options.query && !options.remove) {
318
- return "请提供关键词参数,或使用 -? 查询配置,-r 删除配置";
324
+ let keywordList = keywords ? keywords.split(",").map((k) => k.trim()).filter((k) => k) : [];
325
+ if (!keywords && !options.query && !options.remove) {
326
+ const hasConfigParams = options.method !== void 0 || options.threshold !== void 0 || options.message !== void 0;
327
+ if (!hasConfigParams) {
328
+ return "请提供关键词参数,或使用 -? 查询配置,-r 删除配置,或提供 -m/-t/-msg 参数修改现有配置";
329
+ }
330
+ const existingConfig2 = await ctx.database.get("group_verification_config", { groupId: targetGroupId });
331
+ if (existingConfig2.length === 0) {
332
+ return "请先提供关键词创建配置,或使用 -? 查询配置,-r 删除配置";
333
+ }
334
+ keywordList = existingConfig2[0].keywords;
319
335
  }
320
336
  let reviewMethod = 0;
321
337
  let reviewParameters = {};
@@ -373,7 +389,15 @@ ${debugInfo}`];
373
389
  return `已为群 ${targetGroupId} 创建验证配置`;
374
390
  }
375
391
  });
376
- groupVerify.subcommand(".approve [userId]", "同意加群申请").alias("accept", "同意", "通过", "gva").action(async ({ session }, userId) => {
392
+ groupVerify.subcommand(".approve [userId]", "同意加群申请").alias(
393
+ "gv.accept",
394
+ "gverify.accept",
395
+ "group-verify.accept",
396
+ "gv.同意",
397
+ "gverify.同意",
398
+ "group-verify.同意",
399
+ "gva"
400
+ ).action(async ({ session }, userId) => {
377
401
  const [hasPermission, errorMsg] = await checkPermission(session);
378
402
  if (!hasPermission) {
379
403
  return errorMsg || "权限不足";
@@ -432,7 +456,15 @@ ${debugInfo}`];
432
456
  return `处理申请时出错: ${error.message}`;
433
457
  }
434
458
  });
435
- groupVerify.subcommand(".reject [userId]", "拒绝加群申请").alias("拒绝", "rej", "gvr").action(async ({ session }, userId) => {
459
+ groupVerify.subcommand(".reject [userId]", "拒绝加群申请").alias(
460
+ "gv.拒绝",
461
+ "gverify.拒绝",
462
+ "group-verify.拒绝",
463
+ "gv.rej",
464
+ "gverify.rej",
465
+ "group-verify.rej",
466
+ "gvr"
467
+ ).action(async ({ session }, userId) => {
436
468
  const [hasPermission, errorMsg] = await checkPermission(session);
437
469
  if (!hasPermission) {
438
470
  return errorMsg || "权限不足";
@@ -489,7 +521,12 @@ ${debugInfo}`];
489
521
  return `处理申请时出错: ${error.message}`;
490
522
  }
491
523
  });
492
- groupVerify.subcommand(".stats [target]", "查看群组验证统计信息").alias("统计", "stat", "statistics").action(async ({ session }, target) => {
524
+ groupVerify.subcommand(".stats [target]", "查看群组验证统计信息").alias(
525
+ "gv.统计",
526
+ "gverify.统计",
527
+ "group-verify.统计",
528
+ "gvs"
529
+ ).action(async ({ session }, target) => {
493
530
  const validTargets = ["all", "total"];
494
531
  const isGroupId = target && /^\d+$/.test(target);
495
532
  const isSpecialTarget = target && validTargets.includes(target.toLowerCase());
@@ -517,7 +554,15 @@ ${debugInfo}`];
517
554
  }
518
555
  return "参数错误";
519
556
  });
520
- groupVerify.subcommand(".pending", "查看待审核加群申请").alias("list", "待审", "pend", "待处理").action(async ({ session }) => {
557
+ groupVerify.subcommand(".pending", "查看待审核加群申请").alias(
558
+ "gv.list",
559
+ "gverify.list",
560
+ "group-verify.list",
561
+ "gv.待处理",
562
+ "gverify.待处理",
563
+ "group-verify.待处理",
564
+ "gvp"
565
+ ).action(async ({ session }) => {
521
566
  if (!session.guildId) {
522
567
  return "请在群聊中使用此命令";
523
568
  }
@@ -537,12 +582,19 @@ ${debugInfo}`];
537
582
  });
538
583
  return result;
539
584
  });
540
- groupVerify.subcommand(".help", "显示帮助信息").alias("帮助", "hlp", "帮助信息").action(() => {
585
+ groupVerify.subcommand(".help", "显示帮助信息").alias("gv.帮助", "gverify.帮助", "group-verify.帮助", "帮助", "hlp", "帮助信息").action(() => {
541
586
  return `群组验证命令帮助:
542
587
  主指令别名:gv, gverify
543
588
 
544
- 配置命令 (.config):
545
- 选项:
589
+ 配置命令 (.config/.cfg):
590
+ 用法:
591
+ 1. 创建新配置:gv.cfg 关键词1,关键词2 -m 1 -t 2
592
+ 2. 修改现有配置:gv.cfg -m 2 -t 60 (不提供关键词)
593
+ 3. 查询配置:gv.cfg -?
594
+ 4. 删除配置:gv.cfg -r
595
+ 5. 自定义提醒:gv.cfg -msg "自定义消息"
596
+
597
+ 参数说明:
546
598
  -i <群号> 指定群号(私聊时必需)
547
599
  -m <方式> 审核方式 (0=全部同意, 1=按数量, 2=按比例, 3=全部拒绝)
548
600
  -t <阈值> 阈值参数(方式1或2时必需)
@@ -550,11 +602,6 @@ ${debugInfo}`];
550
602
  -? 查询当前配置
551
603
  -r 删除配置
552
604
 
553
- 示例:
554
- gv.config 关键词1,关键词2 -m 1 -t 2
555
- gv.config -i 123456789 -?
556
- gv.config -r -i 123456789
557
-
558
605
  提醒消息变量:
559
606
  {user} - 用户名
560
607
  {id} - 用户ID
@@ -565,16 +612,17 @@ ${debugInfo}`];
565
612
  {threshold} - 阈值要求
566
613
  \\n - 换行符
567
614
 
615
+ 快捷命令:
616
+ gvc - 配置命令快捷方式
617
+ gva - 同意申请快捷命令
618
+ gvr - 拒绝申请快捷命令
619
+ gvp - 查看待审核列表快捷命令
620
+ gvs - 查看统计信息快捷命令
621
+
568
622
  权限说明:
569
623
  - 群主/管理员权限
570
624
  - koishi三级以上权限
571
- - 私聊时必须指定群号(-i参数)
572
-
573
- 其他命令:
574
- .approve <用户ID> - 同意加群申请
575
- .reject <用户ID> - 拒绝加群申请
576
- .pending - 查看待审核列表
577
- .stats [群号] - 查看统计信息`;
625
+ - 私聊时必须指定群号(-i参数)`;
578
626
  });
579
627
  ctx.on("ready", async () => {
580
628
  const totalStats = await ctx.database.get("group_verification_stats", { groupId: "TOTAL" });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-group-verification",
3
3
  "description": "Koishi 群组加群验证插件,支持多关键词匹配审核、多种审核方式和详细统计功能",
4
- "version": "1.0.11",
4
+ "version": "1.0.13",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [
package/src/index.ts CHANGED
@@ -371,7 +371,11 @@ export function apply(ctx: Context, config: Config) {
371
371
  // Subcommand: configure group verification
372
372
  groupVerify
373
373
  .subcommand('.config [keywords:text]', '配置群组验证规则')
374
- .alias('cfg', '配置', 'conf', '设置')
374
+ .alias(
375
+ 'gv.cfg', 'gverify.cfg', 'group-verify.cfg',
376
+ 'gv.配置', 'gverify.配置', 'group-verify.配置',
377
+ 'gvc'
378
+ )
375
379
  .option('groupId', '-i <groupId> 指定群号')
376
380
  .option('method', '-m <method> 审核方式 (0-3)')
377
381
  .option('threshold', '-t <threshold> 阈值参数')
@@ -453,11 +457,28 @@ export function apply(ctx: Context, config: Config) {
453
457
  }
454
458
 
455
459
  // 处理配置创建/更新
456
- const keywordList = keywords ? keywords.split(',').map(k => k.trim()).filter(k => k) : []
460
+ let keywordList = keywords ? keywords.split(',').map(k => k.trim()).filter(k => k) : []
457
461
 
458
462
  // 如果没有提供关键词且不是查询/删除操作,则报错
459
- if (keywordList.length === 0 && !options.query && !options.remove) {
460
- return '请提供关键词参数,或使用 -? 查询配置,-r 删除配置'
463
+ // 但允许只提供参数来修改现有配置
464
+ if (!keywords && !options.query && !options.remove) {
465
+ // 检查是否提供了其他配置参数
466
+ const hasConfigParams = options.method !== undefined ||
467
+ options.threshold !== undefined ||
468
+ options.message !== undefined
469
+
470
+ if (!hasConfigParams) {
471
+ return '请提供关键词参数,或使用 -? 查询配置,-r 删除配置,或提供 -m/-t/-msg 参数修改现有配置'
472
+ }
473
+
474
+ // 如果只提供了参数,检查是否存在现有配置
475
+ const existingConfig = await ctx.database.get('group_verification_config', { groupId: targetGroupId })
476
+ if (existingConfig.length === 0) {
477
+ return '请先提供关键词创建配置,或使用 -? 查询配置,-r 删除配置'
478
+ }
479
+
480
+ // 使用现有配置的关键词
481
+ keywordList = existingConfig[0].keywords
461
482
  }
462
483
 
463
484
  // 解析审核方式和阈值
@@ -537,7 +558,11 @@ export function apply(ctx: Context, config: Config) {
537
558
  // Subcommand: approve join request
538
559
  groupVerify
539
560
  .subcommand('.approve [userId]', '同意加群申请')
540
- .alias('accept', '同意', '通过', 'gva')
561
+ .alias(
562
+ 'gv.accept', 'gverify.accept', 'group-verify.accept',
563
+ 'gv.同意', 'gverify.同意', 'group-verify.同意',
564
+ 'gva'
565
+ )
541
566
  .action(async ({ session }, userId) => {
542
567
  // 权限检查
543
568
  const [hasPermission, errorMsg] = await checkPermission(session)
@@ -618,7 +643,11 @@ export function apply(ctx: Context, config: Config) {
618
643
  // Subcommand: reject join request
619
644
  groupVerify
620
645
  .subcommand('.reject [userId]', '拒绝加群申请')
621
- .alias('拒绝', 'rej', 'gvr')
646
+ .alias(
647
+ 'gv.拒绝', 'gverify.拒绝', 'group-verify.拒绝',
648
+ 'gv.rej', 'gverify.rej', 'group-verify.rej',
649
+ 'gvr'
650
+ )
622
651
  .action(async ({ session }, userId) => {
623
652
  // 权限检查
624
653
  const [hasPermission, errorMsg] = await checkPermission(session)
@@ -699,7 +728,10 @@ export function apply(ctx: Context, config: Config) {
699
728
  // Subcommand: view statistics
700
729
  groupVerify
701
730
  .subcommand('.stats [target]', '查看群组验证统计信息')
702
- .alias('统计', 'stat', 'statistics')
731
+ .alias(
732
+ 'gv.统计', 'gverify.统计', 'group-verify.统计',
733
+ 'gvs'
734
+ )
703
735
  .action(async ({ session }, target) => {
704
736
  // 参数验证:只能是群号、all、total或空
705
737
  const validTargets = ['all', 'total']
@@ -746,7 +778,11 @@ export function apply(ctx: Context, config: Config) {
746
778
  // Subcommand: view pending requests
747
779
  groupVerify
748
780
  .subcommand('.pending', '查看待审核加群申请')
749
- .alias('list', '待审', 'pend', '待处理')
781
+ .alias(
782
+ 'gv.list', 'gverify.list', 'group-verify.list',
783
+ 'gv.待处理', 'gverify.待处理', 'group-verify.待处理',
784
+ 'gvp'
785
+ )
750
786
  .action(async ({ session }) => {
751
787
  if (!session.guildId) {
752
788
  return '请在群聊中使用此命令'
@@ -775,13 +811,20 @@ export function apply(ctx: Context, config: Config) {
775
811
  // Subcommand: help information
776
812
  groupVerify
777
813
  .subcommand('.help', '显示帮助信息')
778
- .alias('帮助', 'hlp', '帮助信息')
814
+ .alias('gv.帮助', 'gverify.帮助', 'group-verify.帮助', '帮助', 'hlp', '帮助信息')
779
815
  .action(() => {
780
816
  return `群组验证命令帮助:
781
817
  主指令别名:gv, gverify
782
818
 
783
- 配置命令 (.config):
784
- 选项:
819
+ 配置命令 (.config/.cfg):
820
+ 用法:
821
+ 1. 创建新配置:gv.cfg 关键词1,关键词2 -m 1 -t 2
822
+ 2. 修改现有配置:gv.cfg -m 2 -t 60 (不提供关键词)
823
+ 3. 查询配置:gv.cfg -?
824
+ 4. 删除配置:gv.cfg -r
825
+ 5. 自定义提醒:gv.cfg -msg "自定义消息"
826
+
827
+ 参数说明:
785
828
  -i <群号> 指定群号(私聊时必需)
786
829
  -m <方式> 审核方式 (0=全部同意, 1=按数量, 2=按比例, 3=全部拒绝)
787
830
  -t <阈值> 阈值参数(方式1或2时必需)
@@ -789,11 +832,6 @@ export function apply(ctx: Context, config: Config) {
789
832
  -? 查询当前配置
790
833
  -r 删除配置
791
834
 
792
- 示例:
793
- gv.config 关键词1,关键词2 -m 1 -t 2
794
- gv.config -i 123456789 -?
795
- gv.config -r -i 123456789
796
-
797
835
  提醒消息变量:
798
836
  {user} - 用户名
799
837
  {id} - 用户ID
@@ -804,16 +842,17 @@ export function apply(ctx: Context, config: Config) {
804
842
  {threshold} - 阈值要求
805
843
  \\n - 换行符
806
844
 
845
+ 快捷命令:
846
+ gvc - 配置命令快捷方式
847
+ gva - 同意申请快捷命令
848
+ gvr - 拒绝申请快捷命令
849
+ gvp - 查看待审核列表快捷命令
850
+ gvs - 查看统计信息快捷命令
851
+
807
852
  权限说明:
808
853
  - 群主/管理员权限
809
854
  - koishi三级以上权限
810
- - 私聊时必须指定群号(-i参数)
811
-
812
- 其他命令:
813
- .approve <用户ID> - 同意加群申请
814
- .reject <用户ID> - 拒绝加群申请
815
- .pending - 查看待审核列表
816
- .stats [群号] - 查看统计信息`
855
+ - 私聊时必须指定群号(-i参数)`
817
856
  })
818
857
 
819
858
  // 插件初始化时确保总计统计行存在