koishi-plugin-ll-schedule 1.4.1 → 1.4.2

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/index.js +20 -2
  2. package/package.json +2 -1
package/index.js CHANGED
@@ -23,7 +23,7 @@ exports.usage = `定时提醒:每个任务一个大文本框(schedule)。每
23
23
  星期:周一/周六/每天/工作日/周末/1,3,5 时间:12:20, 18:20, 21:20(可多个)
24
24
  内容支持 Markdown 卡片、模板变量 {date} {time} {week} {task}
25
25
 
26
- 群命令:订阅 任务名 / 取消订阅 任务名 / 订阅列表 / schedule.list / schedule.groups / schedule.test 任务名 / 我的ID
26
+ 群命令:订阅 任务名 / 取消订阅 任务名 / 订阅列表 / schedule.list / schedule.groups / schedule.test 任务名 / schedule.testcur 任务名(只发当前群) / 我的ID
27
27
  `
28
28
 
29
29
  // ===== 纯函数(可单测) =====
@@ -461,9 +461,11 @@ function apply(ctx, config) {
461
461
 
462
462
  const groups = (task.groups && task.groups.length > 0) ? task.groups : null
463
463
  const taskSubs = subs.get(name)
464
+ // 测试模式(skipSubs)时忽略所有订阅群,只发 groups(即当前测试群)
465
+ const useSubs = !opts.skipSubs
464
466
 
465
467
  for (const bot of bots) {
466
- const subTargets = taskSubs
468
+ const subTargets = (useSubs && taskSubs)
467
469
  ? [...taskSubs.values()].filter(s => s.botSid === bot.sid).map(s => s.guildId)
468
470
  : []
469
471
 
@@ -612,6 +614,22 @@ function apply(ctx, config) {
612
614
  return `✅ 已发送任务 "${name}"`
613
615
  })
614
616
 
617
+ ctx.command('schedule.testcur <name>', '只向当前群测试发送(不发订阅群)')
618
+ .action(async ({ session }, name) => {
619
+ logger.info(`[schedule] 命令被调用: schedule.testcur name=${name}`)
620
+ const tasks = config.tasks || {}
621
+ const task = tasks[name]
622
+ if (!task) return `未找到任务 "${name}",可用 schedule.list 查看任务名`
623
+ if (!session.guildId) return '❌ 只能在群里使用'
624
+ const testTask = { ...task, groups: [String(session.guildId)] }
625
+ const rows = parseScheduleRows(task)
626
+ const day = todayDay()
627
+ const hit = rows.find(r => dayMatches(parseDays(r.wd), day))
628
+ const sendText = hit ? (hit.text || '') : (rows.length ? (rows[0].text || '') : '')
629
+ await sendTask(name, testTask, { text: sendText, markdown: task.markdown, onlyBotSid: session.bot?.sid, skipSubs: true })
630
+ return `✅ 已向当前群测试发送任务 "${name}"(没有发给订阅群)`
631
+ })
632
+
615
633
  // ===== 群内订阅命令 =====
616
634
  async function isGroupAdmin(session) {
617
635
  if (!session.guildId || !session.userId) return false
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koishi-plugin-ll-schedule",
3
- "version": "1.4.1",
3
+ "version": "1.4.2",
4
4
  "description": "Scheduled message sender with weekly slots (per-day time & content), QQ official markdown card support",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -24,3 +24,4 @@
24
24
 
25
25
 
26
26
 
27
+