koishi-plugin-cfmrmod 1.0.4 → 1.0.5

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/README.md +29 -1
  2. package/dist/notify.js +24 -25
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -13,14 +13,42 @@ Koishi 插件:搜索 CurseForge / Modrinth / MCMod,并渲染图片卡片。
13
13
  - `cnmc.mod/.data/.pack/.tutorial/.author/.user <关键词>`
14
14
  - `cf.help` / `mr.help` / `cnmc.help`
15
15
 
16
+ #### 更新通知(notify)
17
+ - `notify.add <platform> <projectId>` 添加订阅
18
+ - `notify.remove <platform> <projectId>` 删除订阅
19
+ - `notify.list` 列出订阅
20
+ - `notify.enable <onoff>` 启用/禁用本群通知
21
+ - `notify.check [arg] [-b]` 手动检查更新(arg 为序号或 projectId;-b 强制发送最新卡片)
22
+ - `notify.helpme` 查看完整参数说明
23
+
24
+ 参数说明:
25
+ - `<platform>`:平台代码,`mr`=Modrinth,`cf`=CurseForge
26
+ - `<projectId>`:平台项目 ID(不是名称)
27
+ - `<onoff>`:`on/off` 或 `true/false`
28
+ - `[arg]`:`notify.check` 的参数,可填订阅序号或 `projectId`
29
+ - `-b`:强制发送最新卡片(忽略是否更新)
30
+
16
31
  列表交互:输入序号查看,`n` 下一页,`p` 上一页,`q` 退出。
17
32
 
18
33
  ### 配置要点
34
+ #### 通用
19
35
  - `prefixes`: 设置 `cf` / `mr` / `cnmc` 指令前缀
20
- - `fontPath`: 中文字体路径
21
36
  - `timeouts`: 搜索会话超时(毫秒)
22
37
  - `debug`: 调试日志开关
23
38
 
39
+ #### 更新通知(notify)
40
+ - `notify.enabled`: 是否开启更新通知
41
+ - `notify.interval`: 全局轮询间隔(毫秒)
42
+ - `notify.adminAuthority`: 权限等级(1=全部,2=管理员+群主,3=仅群主)
43
+ - `notify.stateFile`: 状态文件路径(JSON)
44
+ - `notify.groups`: 通知群组列表
45
+ - `channelId`: 群/频道 ID
46
+ - `enabled`: 是否启用本群通知
47
+ - `subs`: 订阅列表
48
+ - `platform`: `mr` 或 `cf`
49
+ - `projectId`: 项目 ID
50
+ - `interval`: 单独轮询间隔(毫秒),<=0 禁用
51
+
24
52
  ## 项目特点
25
53
  - 支持 CurseForge / Modrinth / MCMod 多平台搜索
26
54
  - 结果以图片卡片形式展示
package/dist/notify.js CHANGED
@@ -472,17 +472,17 @@ function apply(ctx, config, options) {
472
472
  const tick = Math.max(60 * 1000, Number(config.interval) || 30 * 60 * 1000);
473
473
  ctx.setInterval(() => checkOnce().catch(() => null), tick);
474
474
  }
475
- ctx.command('notify.add <platform> <projectId> [channelId]', '添加更新订阅')
476
- .action(async ({ session }, platform, projectId, channelId) => {
475
+ ctx.command('notify.add <platform> <projectId>', '添加更新订阅')
476
+ .action(async ({ session }, platform, projectId) => {
477
477
  if (!platform || !projectId)
478
478
  return '参数不足。';
479
479
  const platformKey = normalizePlatform(platform);
480
480
  if (!platformKey)
481
481
  return '平台参数错误,请使用 mr 或 cf。';
482
- const targetChannel = channelId || session.channelId;
482
+ const targetChannel = session.channelId;
483
483
  if (!targetChannel)
484
484
  return '只能在群聊使用或指定 channelId。';
485
- if (!await requireManage(session, channelId))
485
+ if (!await requireManage(session))
486
486
  return '权限不足。';
487
487
  const pid = String(projectId).trim();
488
488
  if (!pid)
@@ -497,17 +497,17 @@ function apply(ctx, config, options) {
497
497
  group.subs = list;
498
498
  return `已添加订阅:${platformKey}:${pid}`;
499
499
  });
500
- ctx.command('notify.remove <platform> <projectId> [channelId]', '删除更新订阅')
501
- .action(async ({ session }, platform, projectId, channelId) => {
500
+ ctx.command('notify.remove <platform> <projectId>', '删除更新订阅')
501
+ .action(async ({ session }, platform, projectId) => {
502
502
  if (!platform || !projectId)
503
503
  return '参数不足。';
504
504
  const platformKey = normalizePlatform(platform);
505
505
  if (!platformKey)
506
506
  return '平台参数错误,请使用 mr 或 cf。';
507
- const targetChannel = channelId || session.channelId;
507
+ const targetChannel = session.channelId;
508
508
  if (!targetChannel)
509
509
  return '只能在群聊使用或指定 channelId。';
510
- if (!await requireManage(session, channelId))
510
+ if (!await requireManage(session))
511
511
  return '权限不足。';
512
512
  const pid = String(projectId).trim();
513
513
  if (!pid)
@@ -521,12 +521,12 @@ function apply(ctx, config, options) {
521
521
  return '未找到订阅。';
522
522
  return `已删除订阅:${platformKey}:${pid}`;
523
523
  });
524
- ctx.command('notify.list [channelId]', '列出订阅')
525
- .action(async ({ session }, channelId) => {
526
- const targetChannel = channelId || session.channelId;
524
+ ctx.command('notify.list', '列出订阅')
525
+ .action(async ({ session }) => {
526
+ const targetChannel = session.channelId;
527
527
  if (!targetChannel)
528
528
  return '只能在群聊使用或指定 channelId。';
529
- if (!await requireManage(session, channelId))
529
+ if (!await requireManage(session))
530
530
  return '权限不足。';
531
531
  const group = getGroup(targetChannel);
532
532
  if (!group)
@@ -544,12 +544,12 @@ function apply(ctx, config, options) {
544
544
  });
545
545
  return [`本群通知:${status}`, ...lines].join('\n');
546
546
  });
547
- ctx.command('notify.enable <onoff> [channelId]', '启用/禁用本群通知')
548
- .action(async ({ session }, onoff, channelId) => {
549
- const targetChannel = channelId || session.channelId;
547
+ ctx.command('notify.enable <onoff>', '启用/禁用本群通知')
548
+ .action(async ({ session }, onoff) => {
549
+ const targetChannel = session.channelId;
550
550
  if (!targetChannel)
551
551
  return '只能在群聊使用或指定 channelId。';
552
- if (!await requireManage(session, channelId))
552
+ if (!await requireManage(session))
553
553
  return '权限不足。';
554
554
  const flag = parseOnOff(onoff);
555
555
  if (flag === null)
@@ -558,21 +558,20 @@ function apply(ctx, config, options) {
558
558
  group.enabled = flag;
559
559
  return flag ? '已启用本群通知。' : '已禁用本群通知。';
560
560
  });
561
- ctx.command('notify.help', '查看通知系统帮助')
561
+ ctx.command('notify.helpme', '查看通知系统帮助')
562
562
  .action(() => {
563
563
  return [
564
564
  'notify 使用说明:',
565
- '1) notify.add <platform> <projectId> [channelId] 添加订阅',
566
- '2) notify.remove <platform> <projectId> [channelId] 删除订阅',
567
- '3) notify.list [channelId] 列出订阅',
568
- '4) notify.enable <onoff> [channelId] 启用/禁用',
565
+ '1) notify.add platform projectId 添加订阅',
566
+ '2) notify.remove platform projectId 删除订阅',
567
+ '3) notify.list 列出订阅',
568
+ '4) notify.enable onoff 启用/禁用',
569
569
  '5) notify.check [arg] [-b] 手动检查更新(arg 为序号或 projectId)',
570
570
  '平台:mr=Modrinth,cf=CurseForge',
571
571
  '参数说明:',
572
- '- <platform>:平台代码,填写 mr 或 cf',
573
- '- <projectId>:平台项目ID(Modrinth/CurseForge 的项目ID,不是名称)',
574
- '- [channelId]:可选,目标频道ID,格式 platform:channelId(如 onebot:123456)',
575
- '- <onoff>:启用开关,填写 on/off 或 true/false',
572
+ '- platform]:平台代码,填写 mr 或 cf',
573
+ '- projectId]:平台项目ID(Modrinth/CurseForge 的项目ID,不是名称)',
574
+ '- [onoff]:启用开关,填写 on/off 或 true/false',
576
575
  '- [arg]:notify.check 的参数,可填订阅序号或 projectId',
577
576
  '- -b:强制发送最新卡片(忽略是否更新)',
578
577
  ].join('\n');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koishi-plugin-cfmrmod",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "Koishi 插件:搜索 CurseForge/Modrinth/MCMod 并渲染图片卡片",
5
5
  "main": "dist/index.js",
6
6
  "files": [