koishi-plugin-ll-schedule 1.7.10 → 1.7.11
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 +24 -5
- package/package.json +2 -1
package/index.js
CHANGED
|
@@ -368,6 +368,16 @@ const DEFAULT_REMIND_TPL = [
|
|
|
368
368
|
'{{/next}}',
|
|
369
369
|
].join('\n')
|
|
370
370
|
|
|
371
|
+
// 选取实际使用的提醒模板:
|
|
372
|
+
// 自定义模板必须包含 {activity} 变量,否则一律用默认模板
|
|
373
|
+
// (防止有人把模板写成一段固定文案,导致所有提醒发出来长得一模一样)
|
|
374
|
+
function resolveRemindTemplate(custom) {
|
|
375
|
+
const tpl = String(custom || '').trim()
|
|
376
|
+
if (!tpl) return DEFAULT_REMIND_TPL
|
|
377
|
+
if (!tpl.includes('{activity}')) return DEFAULT_REMIND_TPL
|
|
378
|
+
return tpl
|
|
379
|
+
}
|
|
380
|
+
|
|
371
381
|
// 渲染提醒模板:{变量} 替换;含空变量的整行自动删除;{{#key}}...{{/key}} 条件块(变量为空则整块删除)
|
|
372
382
|
function renderRemindTemplate(tpl, vars) {
|
|
373
383
|
let out = String(tpl || DEFAULT_REMIND_TPL)
|
|
@@ -388,7 +398,7 @@ function renderRemindTemplate(tpl, vars) {
|
|
|
388
398
|
return kept.join('\n').replace(/\n{3,}/g, '\n\n').trim()
|
|
389
399
|
}
|
|
390
400
|
|
|
391
|
-
exports._test = { parseTimes, todayDay, parseDays, dayMatches, parseScheduleBlocks, parseScheduleRows, summarizeRows, computeFires, renderText, renderPushTemplate, hmToMin, parseActivities, expandInstances, findNextInstance, findNextFromNow, computeReminders, renderRemindTemplate, DEFAULT_REMIND_TPL, buildMd, buildTextFromMd }
|
|
401
|
+
exports._test = { parseTimes, todayDay, parseDays, dayMatches, parseScheduleBlocks, parseScheduleRows, summarizeRows, computeFires, renderText, renderPushTemplate, hmToMin, parseActivities, expandInstances, findNextInstance, findNextFromNow, computeReminders, renderRemindTemplate, resolveRemindTemplate, DEFAULT_REMIND_TPL, buildMd, buildTextFromMd }
|
|
392
402
|
|
|
393
403
|
// ===== 配置 Schema =====
|
|
394
404
|
|
|
@@ -843,7 +853,7 @@ function apply(ctx, config) {
|
|
|
843
853
|
|
|
844
854
|
// 渲染并发送一条活动提醒
|
|
845
855
|
async function sendReminder(inst, next, now, hm) {
|
|
846
|
-
const text = renderRemindTemplate(config.remindTemplate, makeRemindVars(inst, next, now, hm))
|
|
856
|
+
const text = renderRemindTemplate(resolveRemindTemplate(config.remindTemplate), makeRemindVars(inst, next, now, hm))
|
|
847
857
|
if (!text) return
|
|
848
858
|
logger.info(`[schedule] 活动提醒「${inst.activity}」开始于 ${inst.start}(提前 ${inst.advance} 分钟)`)
|
|
849
859
|
await sendToSubscribers(text, { markdown: !!config.remindMarkdown })
|
|
@@ -1002,6 +1012,10 @@ function apply(ctx, config) {
|
|
|
1002
1012
|
}
|
|
1003
1013
|
}
|
|
1004
1014
|
const label = `${simulated ? '模拟' : '当前'} ${todayStr(simDate)} ${hm}(星期${WEEK_CN[day]})`
|
|
1015
|
+
const tplSrc = String(config.remindTemplate || '').trim()
|
|
1016
|
+
const tplUsed = resolveRemindTemplate(config.remindTemplate)
|
|
1017
|
+
lines.push(`📝 提醒模板:${!tplSrc ? '(默认)' : (tplUsed === DEFAULT_REMIND_TPL ? '⚠️ 自定义模板里没有 {activity} 变量,已被忽略、正在用默认模板' : '(自定义)')}`)
|
|
1018
|
+
for (const l of tplUsed.split('\n')) lines.push(` ${l}`)
|
|
1005
1019
|
const hits = computeReminders(acts, simDate, hm)
|
|
1006
1020
|
if (hits.length) {
|
|
1007
1021
|
for (const h of hits) {
|
|
@@ -1071,7 +1085,7 @@ function apply(ctx, config) {
|
|
|
1071
1085
|
// 下一场:按"现在"往后算,并排除自己
|
|
1072
1086
|
const next = findNextFromNow(instances.filter(i => i !== inst), now, hm)
|
|
1073
1087
|
|
|
1074
|
-
const text = renderRemindTemplate(config.remindTemplate, makeRemindVars(inst, next, now, hm))
|
|
1088
|
+
const text = renderRemindTemplate(resolveRemindTemplate(config.remindTemplate), makeRemindVars(inst, next, now, hm))
|
|
1075
1089
|
const bot = (ctx.bots || []).find(b => b.sid === session.bot?.sid)
|
|
1076
1090
|
if (!bot || !session.guildId) return '❌ 只能在群里测试'
|
|
1077
1091
|
await sendOne(bot, String(session.guildId), text, { markdown: !!config.remindMarkdown })
|
|
@@ -1225,8 +1239,13 @@ function apply(ctx, config) {
|
|
|
1225
1239
|
return lines.join('\n')
|
|
1226
1240
|
})
|
|
1227
1241
|
|
|
1228
|
-
logger.info('[schedule] 命令已注册: schedule / schedule.list / schedule.groups / schedule.test / ' +
|
|
1229
|
-
`"
|
|
1242
|
+
logger.info('[schedule] 命令已注册: schedule / schedule.list / schedule.debug / schedule.groups / schedule.test / ' +
|
|
1243
|
+
`"剑灵提醒订阅" / "取消剑灵订阅" / 订阅列表 / 我的ID`)
|
|
1244
|
+
|
|
1245
|
+
// 启动检查:自定义提醒模板若不含 {activity} 变量,会被忽略(否则所有提醒内容会长得一样)
|
|
1246
|
+
if (config.remindTemplate && String(config.remindTemplate).trim() && !String(config.remindTemplate).includes('{activity}')) {
|
|
1247
|
+
logger.warn('[schedule] 自定义提醒模板里没有 {activity} 变量 → 已自动忽略它、改用默认模板')
|
|
1248
|
+
}
|
|
1230
1249
|
|
|
1231
1250
|
Promise.all([loadKnownGroups(), loadSubs()])
|
|
1232
1251
|
.then(() => migrateToAll())
|
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.11",
|
|
4
4
|
"description": "BNS activity reminder: one activity table, one-click subscribe, auto reminders with time/place/next-up, QQ official markdown card support",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
|
@@ -20,3 +20,4 @@
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
|
|
23
|
+
|