koishi-plugin-ll-schedule 1.7.2 → 1.7.3

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 +42 -0
  2. package/package.json +2 -1
package/index.js CHANGED
@@ -918,6 +918,48 @@ function apply(ctx, config) {
918
918
  return formatTaskList()
919
919
  })
920
920
 
921
+ // 自检:把"插件认为的当前时间 / 解析出的活动表 / 下一次提醒时刻"全打出来,便于排查
922
+ ctx.command('schedule.debug', '自检:查看当前时间、活动表解析结果、下一次提醒时刻')
923
+ .action(() => {
924
+ const now = new Date()
925
+ const day = todayDay(now)
926
+ const hm = nowHM(now)
927
+ const nowMin = hmToMin(hm)
928
+ const acts = parseActivities(config.activities)
929
+ const instances = expandInstances(acts)
930
+ const lines = [
931
+ `🕐 插件当前时间:${todayStr(now)} ${hm}:${String(now.getSeconds()).padStart(2, '0')}(星期${WEEK_CN[day]})`,
932
+ `📋 活动表:解析出 ${acts.length} 个活动 / ${instances.length} 个时段实例`,
933
+ ]
934
+ for (const a of acts) {
935
+ lines.push(`【${a.name}】提前 ${a.advance} 分钟,${a.slots.length} 行`)
936
+ for (const s of a.slots) {
937
+ lines.push(` · ${s.wd} ${s.start}-${s.end}${s.place ? ' 地点:' + s.place : ''}`)
938
+ }
939
+ }
940
+ // 下一次提醒
941
+ let best = null
942
+ for (const inst of instances) {
943
+ const fireMin = inst.startMin - (inst.advance || 0)
944
+ let offset = (inst.day - day + 7) % 7
945
+ if (offset === 0 && fireMin <= nowMin) offset = 7
946
+ const key = offset * 1440 + fireMin
947
+ if (!best || key < best.key) best = { key, inst, offset, fireMin }
948
+ }
949
+ if (best) {
950
+ const hh = String(Math.floor(best.fireMin / 60)).padStart(2, '0')
951
+ const mm = String(best.fireMin % 60).padStart(2, '0')
952
+ const when = best.offset === 0 ? '今天' : `星期${WEEK_CN[((day - 1 + best.offset) % 7) + 1]}`
953
+ lines.push(`⏭ 下一次提醒:「${best.inst.activity}」${when} ${hh}:${mm}(活动 ${best.inst.start}-${best.inst.end}${best.inst.place ? ' ' + best.inst.place : ''})`)
954
+ }
955
+ else {
956
+ lines.push('⏭ 下一次提醒:(活动表为空)')
957
+ }
958
+ lines.push(`💾 已订阅群:${(subs.get(ALL) || new Map()).size} 个`)
959
+ logger.info('[schedule] 命令被调用: schedule.debug')
960
+ return lines.join('\n')
961
+ })
962
+
921
963
  ctx.command('schedule.groups', '查看机器人已知的群')
922
964
  .action(async () => {
923
965
  logger.info('[schedule] 命令被调用: schedule.groups')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koishi-plugin-ll-schedule",
3
- "version": "1.7.2",
3
+ "version": "1.7.3",
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": [
@@ -34,3 +34,4 @@
34
34
 
35
35
 
36
36
 
37
+