koishi-plugin-ll-schedule 1.7.2 → 1.7.4
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/index.js +68 -0
- package/package.json +3 -1
package/index.js
CHANGED
|
@@ -918,6 +918,74 @@ function apply(ctx, config) {
|
|
|
918
918
|
return formatTaskList()
|
|
919
919
|
})
|
|
920
920
|
|
|
921
|
+
// 自检:看当前时间 / 活动表解析结果 / 某时刻会触发什么
|
|
922
|
+
// 可加参数模拟,如:schedule.debug 18:58 或 schedule.debug 周四18:58
|
|
923
|
+
ctx.command('schedule.debug [arg:text]', '自检:可加时间模拟(例:schedule.debug 18:58)')
|
|
924
|
+
.action((_, arg) => {
|
|
925
|
+
logger.info(`[schedule] 命令被调用: schedule.debug arg=${arg || ''}`)
|
|
926
|
+
const now = new Date()
|
|
927
|
+
const nowDay = todayDay(now)
|
|
928
|
+
const acts = parseActivities(config.activities)
|
|
929
|
+
const instances = expandInstances(acts)
|
|
930
|
+
let day = nowDay
|
|
931
|
+
let hm = nowHM(now)
|
|
932
|
+
let simulated = false
|
|
933
|
+
if (arg) {
|
|
934
|
+
const tm = String(arg).match(/(\d{1,2}):(\d{2})/)
|
|
935
|
+
if (tm) {
|
|
936
|
+
hm = `${String(tm[1]).padStart(2, '0')}:${tm[2]}`
|
|
937
|
+
simulated = true
|
|
938
|
+
}
|
|
939
|
+
const dm = String(arg).match(/(?:周|星期|礼拜)([一二三四五六日天1-7])/)
|
|
940
|
+
if (dm) {
|
|
941
|
+
const map = { '一': 1, '二': 2, '三': 3, '四': 4, '五': 5, '六': 6, '日': 7, '天': 7 }
|
|
942
|
+
day = map[dm[1]] || parseInt(dm[1], 10) || day
|
|
943
|
+
simulated = true
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
const simDate = new Date(now)
|
|
947
|
+
simDate.setDate(now.getDate() + ((day - nowDay + 7) % 7))
|
|
948
|
+
|
|
949
|
+
const lines = [
|
|
950
|
+
`🕐 插件当前时间:${todayStr(now)} ${nowHM(now)}:${String(now.getSeconds()).padStart(2, '0')}(星期${WEEK_CN[nowDay]})`,
|
|
951
|
+
`📋 活动表:${acts.length} 个活动 / ${instances.length} 个时段实例`,
|
|
952
|
+
]
|
|
953
|
+
for (const a of acts) {
|
|
954
|
+
lines.push(`【${a.name}】提前 ${a.advance} 分钟`)
|
|
955
|
+
for (const s of a.slots) {
|
|
956
|
+
lines.push(` · ${s.wd} ${s.start}-${s.end}${s.place ? ' ' + s.place : ''}`)
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
const label = `${simulated ? '模拟' : '当前'} ${todayStr(simDate)} ${hm}(星期${WEEK_CN[day]})`
|
|
960
|
+
const hits = computeReminders(acts, simDate, hm)
|
|
961
|
+
if (hits.length) {
|
|
962
|
+
for (const h of hits) {
|
|
963
|
+
lines.push(`🔔 ${label} 会触发:「${h.inst.activity}」${h.inst.start}-${h.inst.end}${h.inst.place ? ' ' + h.inst.place : ''}(提前 ${h.inst.advance} 分钟)`)
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
else {
|
|
967
|
+
lines.push(`🔔 ${label} 不会触发任何提醒`)
|
|
968
|
+
}
|
|
969
|
+
// 下一次提醒(按当前时刻往后算)
|
|
970
|
+
const nowMin = hmToMin(nowHM(now))
|
|
971
|
+
let best = null
|
|
972
|
+
for (const inst of instances) {
|
|
973
|
+
const fireMin = inst.startMin - (inst.advance || 0)
|
|
974
|
+
let offset = (inst.day - nowDay + 7) % 7
|
|
975
|
+
if (offset === 0 && fireMin <= nowMin) offset = 7
|
|
976
|
+
const key = offset * 1440 + fireMin
|
|
977
|
+
if (!best || key < best.key) best = { key, inst, offset, fireMin }
|
|
978
|
+
}
|
|
979
|
+
if (best) {
|
|
980
|
+
const hh = String(Math.floor(best.fireMin / 60)).padStart(2, '0')
|
|
981
|
+
const mm = String(best.fireMin % 60).padStart(2, '0')
|
|
982
|
+
const when = best.offset === 0 ? '今天' : `星期${WEEK_CN[((nowDay - 1 + best.offset) % 7) + 1]}`
|
|
983
|
+
lines.push(`⏭ 下一次提醒:「${best.inst.activity}」${when} ${hh}:${mm}(活动 ${best.inst.start}-${best.inst.end}${best.inst.place ? ' ' + best.inst.place : ''})`)
|
|
984
|
+
}
|
|
985
|
+
lines.push(`💾 已订阅群:${(subs.get(ALL) || new Map()).size} 个`)
|
|
986
|
+
return lines.join('\n')
|
|
987
|
+
})
|
|
988
|
+
|
|
921
989
|
ctx.command('schedule.groups', '查看机器人已知的群')
|
|
922
990
|
.action(async () => {
|
|
923
991
|
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.
|
|
3
|
+
"version": "1.7.4",
|
|
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,5 @@
|
|
|
34
34
|
|
|
35
35
|
|
|
36
36
|
|
|
37
|
+
|
|
38
|
+
|