koishi-plugin-anime-schedule 1.1.4 → 1.2.0

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/lib/config.d.ts CHANGED
@@ -3,59 +3,68 @@ import type { DigestFormat, ImageLayout, PluginLocale, TimeZone, TitleStyle } fr
3
3
  export interface Config {
4
4
  timeZone: TimeZone;
5
5
  locale: PluginLocale;
6
+ /** 定时推送的总开关;具体时刻在 `schedule` */
6
7
  push: {
7
8
  dailyEnabled: boolean;
8
- dailyTime: string;
9
- dailyOffsetDays: number;
10
9
  nightEnabled: boolean;
11
- nightTime: string;
12
10
  weeklyEnabled: boolean;
13
- weeklyWeekday: 0 | 1 | 2 | 3 | 4 | 5 | 6;
14
- weeklyTime: string;
15
11
  seasonEnabled: boolean;
16
- seasonTime: string;
17
12
  updateReminderEnabled: boolean;
13
+ };
14
+ schedule: {
15
+ dailyTime: string;
16
+ /** 深夜档起止时间:开始于当天,结束于次日 */
17
+ nightRange: [string, string];
18
+ nightTime: string;
19
+ weeklyTime: string;
20
+ seasonTime: string;
21
+ weeklyWeekday: 0 | 1 | 2 | 3 | 4 | 5 | 6;
22
+ dailyOffsetDays: number;
23
+ /** 开播提醒的提前量(分钟) */
18
24
  updateLookaheadMinutes: number;
25
+ /** 开播提醒的检查间隔(分钟),不会超过提前量 */
19
26
  updatePollMinutes: number;
20
27
  };
21
- content: {
22
- /** 单次推送最多展示的作品数,0 表示不限制 */
28
+ range: {
29
+ /** 单个群或私聊最多订阅的番剧数量,0 表示不限制 */
30
+ maxPerChannel: number;
31
+ /** 单个番组表最多展示的作品数,0 表示不限制 */
23
32
  maxItems: number;
24
- /** 超长期连载番的话数阈值,0 表示不过滤 */
33
+ /** 当前话数达到该值的作品不展示,0 表示不过滤 */
25
34
  longRunningThreshold: number;
26
35
  };
27
36
  output: {
28
37
  format: DigestFormat;
29
38
  layout: ImageLayout;
30
- coverLimit: number;
31
39
  /** `anime.info` 按关键词查询时最多出几部,`0` 表示不限制 */
32
40
  infoKeywordLimit: number;
33
41
  showCover: boolean;
34
42
  showScore: boolean;
35
43
  useForward: boolean;
36
44
  };
37
- localize: {
38
- enabled: boolean;
39
- titleStyle: TitleStyle;
40
- /** 标题与封面的缓存天数 */
41
- cacheTtlDays: number;
42
- /** 评分与评价人数的缓存小时数 */
43
- scoreTtlHours: number;
44
- /** 播出状态(是否已完结)的缓存有效期,单位小时 */
45
- airingTtlHours: number;
46
- };
47
45
  render: {
48
46
  fontFamily: string;
47
+ /** 封面解码与磁盘缩略图的最大边长(像素) */
48
+ coverMaxEdge: number;
49
+ /** 单张番组表图最多加载几张封面,0 表示不限制 */
50
+ coverLimit: number;
49
51
  coverConcurrency: number;
52
+ /** 封面磁盘缓存天数,0 表示不写磁盘 */
50
53
  coverCacheDays: number;
51
54
  /** JPEG 编码质量(1-100) */
52
55
  jpegQuality: number;
53
56
  /** 超采样倍数:画布按「逻辑尺寸 × 该值」建立后再等比缩放,小字笔画更锐利,体积与耗时随之上升 */
54
57
  supersample: number;
55
58
  };
56
- subscription: {
57
- /** 单个群最多订阅的番剧数量,0 表示不限制 */
58
- maxPerChannel: number;
59
+ localize: {
60
+ enabled: boolean;
61
+ titleStyle: TitleStyle;
62
+ /** 标题与封面地址的缓存天数 */
63
+ cacheTtlDays: number;
64
+ /** 评分与评价人数的刷新间隔(小时) */
65
+ scoreTtlHours: number;
66
+ /** AniList 播出状态的缓存有效期,单位小时 */
67
+ airingTtlHours: number;
59
68
  };
60
69
  advanced: {
61
70
  requestTimeout: number;
package/lib/config.js CHANGED
@@ -24,89 +24,147 @@ exports.Config = koishi_1.Schema.intersect([
24
24
  koishi_1.Schema.const('Asia/Taipei').description('Asia/Taipei (UTC+8)'),
25
25
  koishi_1.Schema.const('UTC').description('UTC'),
26
26
  ])
27
- .description('时刻与日期换算时区')
27
+ .description('日期与时刻的换算时区')
28
28
  .default('Asia/Shanghai'),
29
29
  locale: koishi_1.Schema.union([
30
30
  koishi_1.Schema.const('zh-CN').description('简体中文'),
31
31
  koishi_1.Schema.const('ja-JP').description('日本語'),
32
32
  koishi_1.Schema.const('en-US').description('English'),
33
33
  ])
34
- .description('界面语言')
34
+ .description('界面文案语言,不影响标题')
35
35
  .default('zh-CN'),
36
- }),
36
+ }).description('基础'),
37
37
  koishi_1.Schema.object({
38
38
  push: koishi_1.Schema.object({
39
- dailyEnabled: koishi_1.Schema.boolean().description('每日更新表').default(true),
40
- dailyTime: koishi_1.Schema.string().pattern(TIME_PATTERN).description('推送时刻').default('08:00'),
39
+ dailyEnabled: koishi_1.Schema.boolean().description('开启后每天推送更新表').default(true),
40
+ nightEnabled: koishi_1.Schema.boolean().description('开启后推送深夜档更新表').default(true),
41
+ weeklyEnabled: koishi_1.Schema.boolean().description('开启后每周推送更新表').default(true),
42
+ seasonEnabled: koishi_1.Schema.boolean().description('开启后每季首日推送新番表').default(true),
43
+ updateReminderEnabled: koishi_1.Schema.boolean().description('开启后推送订阅开播提醒').default(true),
44
+ }),
45
+ }).description('推送'),
46
+ koishi_1.Schema.object({
47
+ schedule: koishi_1.Schema.object({
48
+ dailyTime: koishi_1.Schema.string()
49
+ .pattern(TIME_PATTERN)
50
+ .description('每日推送时刻(HH:mm)')
51
+ .default('08:00'),
52
+ nightRange: koishi_1.Schema.tuple([
53
+ koishi_1.Schema.string().pattern(TIME_PATTERN).required(),
54
+ koishi_1.Schema.string().pattern(TIME_PATTERN).required(),
55
+ ])
56
+ // tuple 的推断类型是可变长数组,这里收窄成固定两元组
57
+ .description('深夜档起止时间(HH:mm,开始→次日结束)')
58
+ .default([...constants_1.DEFAULT_NIGHT_RANGE]),
59
+ nightTime: koishi_1.Schema.string()
60
+ .pattern(TIME_PATTERN)
61
+ .description('深夜档推送时刻(HH:mm)')
62
+ .default('21:00'),
63
+ weeklyTime: koishi_1.Schema.string()
64
+ .pattern(TIME_PATTERN)
65
+ .description('周表推送时刻(HH:mm)')
66
+ .default('08:00'),
67
+ seasonTime: koishi_1.Schema.string()
68
+ .pattern(TIME_PATTERN)
69
+ .description('季度首日推送时刻(HH:mm)')
70
+ .default('08:00'),
71
+ weeklyWeekday: koishi_1.Schema.union(WEEKDAYS.map((item) => koishi_1.Schema.const(item.value).description(item.label)))
72
+ .description('周表推送星期')
73
+ .default(1),
41
74
  dailyOffsetDays: koishi_1.Schema.number()
42
75
  .min(constants_1.DAILY_OFFSET_MIN).max(constants_1.DAILY_OFFSET_MAX).step(1)
43
- .description('日期偏移,0 当天、-1 前一天、1 后一天')
76
+ .description('每日推送日期偏移,负数往前')
44
77
  .default(0),
45
- nightEnabled: koishi_1.Schema.boolean().description('深夜档,当晚 21:00 至次日 06:00').default(true),
46
- nightTime: koishi_1.Schema.string().pattern(TIME_PATTERN).description('推送时刻').default('21:00'),
47
- weeklyEnabled: koishi_1.Schema.boolean().description('本周更新表').default(true),
48
- weeklyWeekday: koishi_1.Schema.union(WEEKDAYS.map((item) => koishi_1.Schema.const(item.value).description(item.label)))
49
- .description('周表的推送星期')
50
- .default(1),
51
- weeklyTime: koishi_1.Schema.string().pattern(TIME_PATTERN).description('推送时刻').default('08:00'),
52
- seasonEnabled: koishi_1.Schema.boolean().description('本季新番表').default(true),
53
- seasonTime: koishi_1.Schema.string().pattern(TIME_PATTERN).description('季度首日的推送时刻').default('08:00'),
54
- updateReminderEnabled: koishi_1.Schema.boolean().description('订阅作品的开播提醒').default(true),
55
78
  updateLookaheadMinutes: koishi_1.Schema.number()
56
- .min(1).step(1)
57
- .description('提前多少分钟提醒')
79
+ .min(1).max(constants_1.MAX_UPDATE_LOOKAHEAD_MINUTES).step(1)
80
+ .description('开播提醒提前分钟数')
58
81
  .default(30),
59
82
  updatePollMinutes: koishi_1.Schema.number()
60
83
  .min(1).step(1)
61
- .description('检查间隔(分钟)')
84
+ .description('开播提醒检查间隔')
62
85
  .default(10),
63
86
  }),
64
- }).description('推送设置'),
87
+ }).description('时间'),
65
88
  koishi_1.Schema.object({
66
- content: koishi_1.Schema.object({
89
+ range: koishi_1.Schema.object({
90
+ maxPerChannel: koishi_1.Schema.number()
91
+ .min(0).step(1)
92
+ .description('单个会话订阅上限,0 不限')
93
+ .default(0),
67
94
  maxItems: koishi_1.Schema.number()
68
95
  .min(0).step(1)
69
- .description('单次推送最多显示多少部,0 不限制')
96
+ .description('单个番组表作品上限,0 不限')
70
97
  .default(0),
71
98
  longRunningThreshold: koishi_1.Schema.number()
72
99
  .min(0).step(1)
73
- .description('剔除长期连载番的话数阈值,0 不过滤')
100
+ .description('更新表过滤话数阈值,0 关闭')
74
101
  .default(0),
75
102
  }),
76
- }).description('推送内容'),
103
+ }).description('范围'),
77
104
  koishi_1.Schema.object({
78
105
  output: koishi_1.Schema.object({
79
106
  format: koishi_1.Schema.union([
80
- koishi_1.Schema.const('image').description('风格化图片'),
81
- koishi_1.Schema.const('text').description('纯文本'),
107
+ koishi_1.Schema.const('image').description('图片'),
108
+ koishi_1.Schema.const('text').description('文本'),
82
109
  ])
83
- .description('推送形态,图片渲染失败时自动改用文本')
110
+ .description('番组表与详情的输出形态')
84
111
  .default('image'),
85
112
  layout: koishi_1.Schema.union([
86
113
  koishi_1.Schema.const('table').description('时间表'),
87
114
  koishi_1.Schema.const('list').description('卡片列表'),
88
115
  ])
89
- .description('图片排版')
116
+ .description('番组表图片排版')
90
117
  .default('table'),
91
- coverLimit: koishi_1.Schema.number()
92
- .min(0)
93
- .description('单张图片最多加载多少张封面,0 不限制')
94
- .default(0),
95
- infoKeywordLimit: koishi_1.Schema.number()
96
- .min(0)
97
- .description('anime.info 按关键词查询番剧时显示数量上限,0 不限制')
98
- .default(20),
99
- showCover: koishi_1.Schema.boolean().description('显示封面').default(true),
100
- showScore: koishi_1.Schema.boolean().description('显示评分,评价不足 10 条时隐藏').default(true),
118
+ showCover: koishi_1.Schema.boolean().description('图片中显示封面').default(true),
119
+ showScore: koishi_1.Schema.boolean()
120
+ .description('显示 Bangumi 评分')
121
+ .default(true),
101
122
  useForward: koishi_1.Schema.boolean()
102
- .description('纯文本模式用合并转发,避免刷屏')
123
+ .description('多段文本使用合并转发')
103
124
  .default(true),
125
+ infoKeywordLimit: koishi_1.Schema.number()
126
+ .min(0).step(1)
127
+ .description('关键词详情最多显示几部,0 不限')
128
+ .default(20),
129
+ }),
130
+ }).description('输出'),
131
+ koishi_1.Schema.object({
132
+ render: koishi_1.Schema.object({
133
+ fontFamily: koishi_1.Schema.string()
134
+ .description('图片字体,留空自动选择')
135
+ .default(constants_1.DEFAULT_FONT_FAMILY),
136
+ coverMaxEdge: koishi_1.Schema.number()
137
+ .min(constants_1.COVER_MAX_EDGE_MIN).max(constants_1.COVER_MAX_EDGE_MAX).step(1)
138
+ .description('封面解码边长(像素)')
139
+ .default(constants_1.COVER_MAX_EDGE_DEFAULT),
140
+ coverLimit: koishi_1.Schema.number()
141
+ .min(0).step(1)
142
+ .description('单张图最多加载几张封面,0 不限')
143
+ .default(0),
144
+ coverConcurrency: koishi_1.Schema.number()
145
+ .min(1).max(constants_1.MAX_COVER_CONCURRENCY).step(1)
146
+ .description('封面下载并发数')
147
+ .default(constants_1.COVER_CONCURRENCY),
148
+ coverCacheDays: koishi_1.Schema.number()
149
+ .min(0).step(1)
150
+ .description('封面缓存天数,0 不缓存')
151
+ .default(21),
152
+ jpegQuality: koishi_1.Schema.number()
153
+ .min(1).max(100).step(1)
154
+ .role('slider')
155
+ .description('JPEG 编码质量(1–100)')
156
+ .default(constants_1.DEFAULT_JPEG_QUALITY),
157
+ supersample: koishi_1.Schema.number()
158
+ .min(1).max(constants_1.MAX_SUPERSAMPLE).step(0.01)
159
+ .role('slider')
160
+ .description('超采样倍数(1–5)')
161
+ .default(constants_1.DEFAULT_SUPERSAMPLE),
104
162
  }),
105
- }).description('输出设置'),
163
+ }).description('图片'),
106
164
  koishi_1.Schema.object({
107
165
  localize: koishi_1.Schema.object({
108
166
  enabled: koishi_1.Schema.boolean()
109
- .description('使用中文标题与评分')
167
+ .description('开启后使用中文标题与评分')
110
168
  .default(true),
111
169
  titleStyle: koishi_1.Schema.union([
112
170
  koishi_1.Schema.const('localized').description('仅中文'),
@@ -115,69 +173,60 @@ exports.Config = koishi_1.Schema.intersect([
115
173
  ])
116
174
  .description('标题展示方式')
117
175
  .default('localized'),
118
- scoreTtlHours: koishi_1.Schema.number()
119
- .min(1).step(1)
120
- .description('评分多久后台补取一次(小时),到期不阻塞构建')
121
- .default(constants_1.DEFAULT_SCORE_TTL_HOURS),
122
176
  cacheTtlDays: koishi_1.Schema.number()
123
177
  .min(1).step(1)
124
- .description('标题与封面的缓存天数')
178
+ .description('标题与封面地址缓存天数')
125
179
  .default(30),
180
+ scoreTtlHours: koishi_1.Schema.number()
181
+ .min(1).step(1)
182
+ .description('评分刷新间隔(小时)')
183
+ .default(constants_1.DEFAULT_SCORE_TTL_HOURS),
126
184
  airingTtlHours: koishi_1.Schema.number()
127
185
  .min(1).step(1)
128
- .description('是否已播完的缓存小时数')
186
+ .description('播出状态缓存(小时)')
129
187
  .default(6),
130
188
  }),
131
189
  }).description('本地化'),
132
- koishi_1.Schema.object({
133
- render: koishi_1.Schema.object({
134
- fontFamily: koishi_1.Schema.string()
135
- .description('字体族,留空则自动寻找系统中文字体')
136
- .default(constants_1.DEFAULT_FONT_FAMILY),
137
- coverConcurrency: koishi_1.Schema.number()
138
- .min(1)
139
- .description('封面下载并发数')
140
- .default(constants_1.COVER_CONCURRENCY),
141
- coverCacheDays: koishi_1.Schema.number()
142
- .min(0)
143
- .description('封面缓存天数,0 不写磁盘')
144
- .default(21),
145
- jpegQuality: koishi_1.Schema.number()
146
- .min(1).max(100).step(1)
147
- .description('编码质量')
148
- .default(constants_1.DEFAULT_JPEG_QUALITY),
149
- supersample: koishi_1.Schema.number()
150
- .min(1).max(constants_1.MAX_SUPERSAMPLE).step(1)
151
- .description('超采样倍数')
152
- .default(constants_1.DEFAULT_SUPERSAMPLE),
153
- }),
154
- }).description('图片'),
155
- koishi_1.Schema.object({
156
- subscription: koishi_1.Schema.object({
157
- maxPerChannel: koishi_1.Schema.number()
158
- .min(0).step(1)
159
- .description('单个群最多订阅多少部,0 不限制')
160
- .default(0),
161
- }),
162
- }).description('订阅'),
163
190
  koishi_1.Schema.object({
164
191
  advanced: koishi_1.Schema.object({
165
192
  requestTimeout: koishi_1.Schema.number()
166
- .min(1)
167
- .description('单次请求超时(秒)')
193
+ .min(1).max(constants_1.MAX_REQUEST_TIMEOUT_SECONDS)
194
+ .description('默认请求超时(秒)')
168
195
  .default(constants_1.LOCALIZE_TIMEOUT_SECONDS),
169
196
  retries: koishi_1.Schema.number()
170
- .min(0)
197
+ .min(0).max(constants_1.MAX_RETRIES).step(1)
171
198
  .description('请求失败重试次数')
172
199
  .default(2),
173
200
  debug: koishi_1.Schema.boolean()
174
- .description('输出调试日志')
201
+ .description('开启后输出调试日志')
175
202
  .default(false),
176
203
  }),
177
- }).description('其他'),
204
+ }).description('高级'),
178
205
  ]);
206
+ /** 校验深夜档范围:必须跨午夜,返回补零后的 [开始, 结束] */
207
+ function normalizeNightRange(value) {
208
+ if (!Array.isArray(value) || value.length !== 2)
209
+ return [...constants_1.DEFAULT_NIGHT_RANGE];
210
+ const start = typeof value[0] === 'string' ? (0, time_1.parseClock)(value[0]) : null;
211
+ const end = typeof value[1] === 'string' ? (0, time_1.parseClock)(value[1]) : null;
212
+ if (!start || !end)
213
+ return [...constants_1.DEFAULT_NIGHT_RANGE];
214
+ const startMinutes = start.hour * 60 + start.minute;
215
+ const endMinutes = end.hour * 60 + end.minute;
216
+ // 开始必须在中午之后、结束在次日中午之前,且确实跨过午夜;否则会得到当天或超长窗口
217
+ if (startMinutes < 12 * 60 || endMinutes >= 12 * 60 || startMinutes <= endMinutes) {
218
+ return [...constants_1.DEFAULT_NIGHT_RANGE];
219
+ }
220
+ const clock = (item) => (`${String(item.hour).padStart(2, '0')}:${String(item.minute).padStart(2, '0')}`);
221
+ return [clock(start), clock(end)];
222
+ }
179
223
  /** 把配置夹到安全区间:只保证类型正确且不小于最小值,不设人为上限 */
180
224
  function normalizeConfig(config) {
225
+ const legacy = config;
226
+ const legacyPush = legacy.push ?? {};
227
+ const legacyContent = legacy.content ?? {};
228
+ const legacySubscription = legacy.subscription ?? {};
229
+ const legacyOutput = legacy.output ?? {};
181
230
  /** 取整并夹到不小于 `min`(默认 0)。允许负值的字段不能走这个默认值 */
182
231
  const int = (value, fallback, min = 0) => {
183
232
  if (typeof value !== 'number' || !Number.isFinite(value))
@@ -190,60 +239,77 @@ function normalizeConfig(config) {
190
239
  return fallback;
191
240
  return Math.min(max, Math.max(min, Math.round(value)));
192
241
  };
242
+ /** 保留两位小数并夹到 `[min, max]`,用于超采样倍率等连续值 */
243
+ const decimal = (value, fallback, min, max) => {
244
+ if (typeof value !== 'number' || !Number.isFinite(value))
245
+ return fallback;
246
+ return Math.min(max, Math.max(min, Math.round(value * 100) / 100));
247
+ };
248
+ const bool = (value, fallback) => (typeof value === 'boolean' ? value : fallback);
193
249
  const time = (value, fallback) => (typeof value === 'string' && TIME_PATTERN.test(value) ? value : fallback);
194
250
  // 旧版本的 `both` 形态已移除:非 `text` 一律按图片处理
195
251
  const format = config.output?.format === 'text' ? 'text' : 'image';
196
- // 轮询间隔不能大于提前量:调度器每 poll 分钟检查一次 [now, now+lookahead] 窗口,
197
- // 间隔更大时两次检查之间会留下覆盖不到的空档,场次静默漏发
198
- const lookahead = int(config.push?.updateLookaheadMinutes, 30, 1);
199
- const poll = int(config.push?.updatePollMinutes, 10, 1);
252
+ const titleStyle = config.localize?.titleStyle === 'both' || config.localize?.titleStyle === 'original'
253
+ ? config.localize.titleStyle
254
+ : 'localized';
255
+ // 旧版字段若还在 yaml 里,优先取旧值:schema 会先把新字段填成默认值,
256
+ // 直接读新字段会把升级前的设置静默覆盖掉
257
+ const lookahead = Math.min(constants_1.MAX_UPDATE_LOOKAHEAD_MINUTES, int(legacyPush.updateLookaheadMinutes ?? config.schedule?.updateLookaheadMinutes, 30, 1));
258
+ const poll = int(legacyPush.updatePollMinutes ?? config.schedule?.updatePollMinutes, 10, 1);
200
259
  return {
201
260
  ...config,
202
261
  timeZone: (0, time_1.resolveTimeZone)(config.timeZone, 'Asia/Shanghai'),
203
262
  push: {
204
- ...config.push,
205
- dailyTime: time(config.push?.dailyTime, '08:00'),
206
- dailyOffsetDays: intBetween(config.push?.dailyOffsetDays, 0, constants_1.DAILY_OFFSET_MIN, constants_1.DAILY_OFFSET_MAX),
207
- weeklyWeekday: Math.max(0, Math.min(6, int(config.push?.weeklyWeekday, 1))),
208
- nightTime: time(config.push?.nightTime, '21:00'),
209
- weeklyTime: time(config.push?.weeklyTime, '08:00'),
210
- seasonTime: time(config.push?.seasonTime, '08:00'),
263
+ dailyEnabled: bool(config.push?.dailyEnabled, true),
264
+ nightEnabled: bool(config.push?.nightEnabled, true),
265
+ weeklyEnabled: bool(config.push?.weeklyEnabled, true),
266
+ seasonEnabled: bool(config.push?.seasonEnabled, true),
267
+ updateReminderEnabled: bool(config.push?.updateReminderEnabled, true),
268
+ },
269
+ schedule: {
270
+ dailyTime: time(legacyPush.dailyTime ?? config.schedule?.dailyTime, '08:00'),
271
+ nightRange: normalizeNightRange(config.schedule?.nightRange),
272
+ nightTime: time(legacyPush.nightTime ?? config.schedule?.nightTime, '21:00'),
273
+ weeklyTime: time(legacyPush.weeklyTime ?? config.schedule?.weeklyTime, '08:00'),
274
+ seasonTime: time(legacyPush.seasonTime ?? config.schedule?.seasonTime, '08:00'),
275
+ weeklyWeekday: Math.max(0, Math.min(6, int(legacyPush.weeklyWeekday ?? config.schedule?.weeklyWeekday, 1))),
276
+ dailyOffsetDays: intBetween(legacyPush.dailyOffsetDays ?? config.schedule?.dailyOffsetDays, 0, constants_1.DAILY_OFFSET_MIN, constants_1.DAILY_OFFSET_MAX),
211
277
  updateLookaheadMinutes: lookahead,
212
278
  updatePollMinutes: Math.min(poll, lookahead),
213
279
  },
214
- content: {
215
- maxItems: int(config.content?.maxItems, 0),
216
- longRunningThreshold: int(config.content?.longRunningThreshold, 0),
280
+ range: {
281
+ maxPerChannel: int(legacySubscription.maxPerChannel ?? config.range?.maxPerChannel, 0),
282
+ maxItems: int(legacyContent.maxItems ?? config.range?.maxItems, 0),
283
+ longRunningThreshold: int(legacyContent.longRunningThreshold ?? config.range?.longRunningThreshold, 0),
217
284
  },
218
285
  output: {
219
- ...config.output,
220
286
  format,
221
287
  layout: config.output?.layout === 'list' ? 'list' : 'table',
222
- coverLimit: int(config.output?.coverLimit, 0),
223
288
  infoKeywordLimit: int(config.output?.infoKeywordLimit, 20),
224
- },
225
- localize: {
226
- ...config.localize,
227
- cacheTtlDays: int(config.localize?.cacheTtlDays, 30, 1),
228
- scoreTtlHours: int(config.localize?.scoreTtlHours, constants_1.DEFAULT_SCORE_TTL_HOURS, 1),
229
- airingTtlHours: int(config.localize?.airingTtlHours, 6, 1),
289
+ showCover: bool(config.output?.showCover, true),
290
+ showScore: bool(config.output?.showScore, true),
291
+ useForward: bool(config.output?.useForward, true),
230
292
  },
231
293
  render: {
232
- ...config.render,
233
294
  fontFamily: config.render?.fontFamily?.trim() || constants_1.DEFAULT_FONT_FAMILY,
234
- coverConcurrency: int(config.render?.coverConcurrency, constants_1.COVER_CONCURRENCY, 1),
295
+ coverMaxEdge: Math.min(constants_1.COVER_MAX_EDGE_MAX, int(config.render?.coverMaxEdge, constants_1.COVER_MAX_EDGE_DEFAULT, constants_1.COVER_MAX_EDGE_MIN)),
296
+ coverLimit: int(legacyOutput.coverLimit ?? config.render?.coverLimit, 0),
297
+ coverConcurrency: Math.min(constants_1.MAX_COVER_CONCURRENCY, int(config.render?.coverConcurrency, constants_1.COVER_CONCURRENCY, 1)),
235
298
  coverCacheDays: int(config.render?.coverCacheDays, 21),
236
299
  jpegQuality: Math.min(100, int(config.render?.jpegQuality, constants_1.DEFAULT_JPEG_QUALITY, 1)),
237
- supersample: Math.min(constants_1.MAX_SUPERSAMPLE, int(config.render?.supersample, constants_1.DEFAULT_SUPERSAMPLE, 1)),
300
+ supersample: decimal(config.render?.supersample, constants_1.DEFAULT_SUPERSAMPLE, 1, constants_1.MAX_SUPERSAMPLE),
238
301
  },
239
- subscription: {
240
- ...config.subscription,
241
- maxPerChannel: int(config.subscription?.maxPerChannel, 0),
302
+ localize: {
303
+ enabled: bool(config.localize?.enabled, true),
304
+ titleStyle,
305
+ cacheTtlDays: int(config.localize?.cacheTtlDays, 30, 1),
306
+ scoreTtlHours: int(config.localize?.scoreTtlHours, constants_1.DEFAULT_SCORE_TTL_HOURS, 1),
307
+ airingTtlHours: int(config.localize?.airingTtlHours, 6, 1),
242
308
  },
243
309
  advanced: {
244
- ...config.advanced,
245
- requestTimeout: int(config.advanced?.requestTimeout, constants_1.LOCALIZE_TIMEOUT_SECONDS, 1),
246
- retries: int(config.advanced?.retries, 2),
310
+ requestTimeout: Math.min(constants_1.MAX_REQUEST_TIMEOUT_SECONDS, int(config.advanced?.requestTimeout, constants_1.LOCALIZE_TIMEOUT_SECONDS, 1)),
311
+ retries: Math.min(constants_1.MAX_RETRIES, int(config.advanced?.retries, 2)),
312
+ debug: bool(config.advanced?.debug, false),
247
313
  },
248
314
  };
249
315
  }
@@ -1,3 +1,4 @@
1
+ import { h } from 'koishi';
1
2
  import type { DigestKind, PluginLocale } from './types';
2
3
  /** 插件名,同时作为日志前缀与 User-Agent 主体 */
3
4
  export declare const PLUGIN_NAME = "anime-schedule";
@@ -25,6 +26,9 @@ export declare const ANILIST_MIN_INTERVAL_MS = 1200;
25
26
  * 429 是超限封禁、403 是 API 被临时停用,两种情况都沿用已有数据一段时间再试。
26
27
  */
27
28
  export declare const ANILIST_COOLDOWN_MS: number;
29
+ /** 标题 → AniList ID 的本地映射文件名与版本(只存数字 ID,不存状态/排期) */
30
+ export declare const ANILIST_ID_CACHE_FILE = "anilist-ids.json";
31
+ export declare const ANILIST_ID_CACHE_VERSION = 1;
28
32
  /**
29
33
  * bangumi-data 索引。
30
34
  *
@@ -58,9 +62,8 @@ export declare const IMAGE_LIST_TWO_COLUMN_AT = 26;
58
62
  /**
59
63
  * 「深夜番」的判定:本地时间 0 点到 6 点算作前一日的深夜档。
60
64
  *
61
- * 与 `DigestService` 的深夜档窗口终点(次日 06:00)保持一致——两处都表示「凌晨这一段的结束时刻」,
62
- * 改一处时另一处也要跟着改。这里的用途是统计与文案(`finish()` 里的「其中 N 部为深夜档」、
63
- * 时间轴的 24 小时制续写),不是窗口本身。
65
+ * 用于每日/周表的凌晨统计(`finish()` 里的「其中 N 部为深夜档」);深夜档自身的窗口
66
+ * 由 `schedule.nightRange` 决定,不再固定为 06:00 结束。
64
67
  */
65
68
  export declare const LATE_NIGHT_END_HOUR = 6;
66
69
  /** 本地化缓存的落盘文件名 */
@@ -125,14 +128,23 @@ export declare const LOCALIZE_CONCURRENCY = 6;
125
128
  * 而一条超时会把整次构建拖住这么久,所以默认压到 10 秒;嫌紧可以自行调大。
126
129
  */
127
130
  export declare const LOCALIZE_TIMEOUT_SECONDS = 10;
131
+ /** 单次请求超时的可选上限(秒),与配置项的 `.max()` 保持一致 */
132
+ export declare const MAX_REQUEST_TIMEOUT_SECONDS = 300;
133
+ /** 请求失败重试次数的可选上限,与配置项的 `.max()` 保持一致 */
134
+ export declare const MAX_RETRIES = 5;
128
135
  /** 并发拉取封面时的并发上限 */
129
136
  export declare const COVER_CONCURRENCY = 8;
137
+ /** 封面下载并发的可选上限,与配置项的 `.max()` 保持一致 */
138
+ export declare const MAX_COVER_CONCURRENCY = 32;
139
+ /** 封面解码/磁盘缩略图的最大边长(像素)默认值与可选范围 */
140
+ export declare const COVER_MAX_EDGE_DEFAULT = 650;
141
+ export declare const COVER_MAX_EDGE_MIN = 256;
142
+ export declare const COVER_MAX_EDGE_MAX = 2048;
130
143
  /** 封面下载超时与体积上限,避免个别大图拖垮整次渲染 */
131
144
  export declare const COVER_TIMEOUT_MS = 8000;
132
145
  export declare const COVER_MAX_BYTES: number;
133
- /** 封面磁盘缓存目录(相对于 ctx.baseDir)与有效期 */
146
+ /** 封面磁盘缓存目录(相对于 ctx.baseDir)与数量上限 */
134
147
  export declare const COVER_CACHE_DIR: string[];
135
- export declare const COVER_CACHE_TTL_MS: number;
136
148
  export declare const COVER_CACHE_MAX_FILES = 1200;
137
149
  /**
138
150
  * 内存里保留的解码后封面总量上限(按 RGBA 字节算)。
@@ -149,10 +161,12 @@ export declare const BOLD_FONT_CANDIDATES: string[];
149
161
  /**
150
162
  * JPEG 编码质量。
151
163
  *
152
- * 图片以文字与细线条为主,块状伪影比在照片上明显。取 100 为无损编码,文字边缘最锐利;
153
- * 体积比 92 约多三成,可调低换取更小体积。
164
+ * 图片以文字与细线条为主,块状伪影比在照片上明显;默认 90 兼顾清晰度与发送体积,
165
+ * 需要更高画质可在控制台用滑块调到 100。
154
166
  */
155
- export declare const DEFAULT_JPEG_QUALITY = 100;
167
+ export declare const DEFAULT_JPEG_QUALITY = 90;
168
+ /** 深夜档的默认起止时间:开始于当天,结束于次日 */
169
+ export declare const DEFAULT_NIGHT_RANGE: [string, string];
156
170
  /**
157
171
  * 超采样倍数。
158
172
  *
@@ -160,7 +174,7 @@ export declare const DEFAULT_JPEG_QUALITY = 100;
160
174
  * 得出边缘像素。清晰度主要取决于此:各版面最小字号仅 10~11px,1× 下一个字不足十几个
161
175
  * 像素,JPEG 质量再高也无法还原。
162
176
  *
163
- * 3 在密集的封面与小字上收益仍可见;5 是收益递减的上限。
177
+ * 2 更快、更省内存;3 在密集的封面与小字上收益仍可见;5 是收益递减的上限。
164
178
  */
165
179
  export declare const DEFAULT_SUPERSAMPLE = 3;
166
180
  /** 超采样倍数的可选上限,与配置项的 `.max()` 保持一致 */
@@ -173,6 +187,8 @@ export declare const MAX_SUPERSAMPLE = 5;
173
187
  */
174
188
  export declare const DAILY_OFFSET_MIN = -7;
175
189
  export declare const DAILY_OFFSET_MAX = 7;
190
+ /** 开播提醒提前量的可选上限(分钟),7 天;取数窗口会按该值动态放大 */
191
+ export declare const MAX_UPDATE_LOOKAHEAD_MINUTES: number;
176
192
  /**
177
193
  * 构建结果的复用窗口(毫秒)。
178
194
  *
@@ -183,8 +199,13 @@ export declare const DAILY_OFFSET_MAX = 7;
183
199
  export declare const BUILD_CACHE_TTL_MS: number;
184
200
  /** 构建结果同时留存几份(日/深夜/周/季 × 少量偏移),超出丢最早的一份 */
185
201
  export declare const BUILD_CACHE_MAX_ENTRIES = 16;
186
- /** 注册到 canvas 的字体族名,与 config.render.fontFamily 的默认值保持一致 */
187
- export declare const DEFAULT_FONT_FAMILY = "Anime Schedule Sans";
202
+ /**
203
+ * 默认字体配置:留空表示从系统字体中自动发现,不向用户暗示插件内置了专用字体。
204
+ * 实际注册时使用内部别名 `AUTO_FONT_ALIAS`。
205
+ */
206
+ export declare const DEFAULT_FONT_FAMILY = "";
207
+ /** 自动发现系统字体时注册到 canvas 的内部别名,不暴露给配置页 */
208
+ export declare const AUTO_FONT_ALIAS = "Anime Schedule Sans";
188
209
  /**
189
210
  * 图片版式常量。
190
211
  *
@@ -325,7 +346,7 @@ export declare const IMAGE_THEME: {
325
346
  export interface Messages {
326
347
  weekdayNames: string[];
327
348
  dailyHeader: (date: string) => string;
328
- nightHeader: (date: string) => string;
349
+ nightHeader: (date: string, start: string, end: string) => string;
329
350
  weeklyHeader: (start: string, end: string) => string;
330
351
  seasonHeader: (label: string) => string;
331
352
  subHeader: (count: number) => string;
@@ -339,7 +360,7 @@ export interface Messages {
339
360
  /** 每日表与订阅表里「当天」那一段的标题 */
340
361
  daytimeGroup: string;
341
362
  /** 深夜档推送里「今晚 21:00 起」那一段的标题 */
342
- tonightGroup: (date: string) => string;
363
+ tonightGroup: (date: string, start: string) => string;
343
364
  /** 订阅表里「次日凌晨」那一段的标题 */
344
365
  tomorrowDawnGroup: (date: string) => string;
345
366
  seasonLabel: (year: number, month: number) => string;
@@ -384,18 +405,18 @@ export declare const MESSAGES: Record<PluginLocale, Messages>;
384
405
  export declare function getMessages(locale: PluginLocale): Messages;
385
406
  /** 交互回复:完整句,结尾带句号 */
386
407
  export declare const RESPONSES: {
387
- readonly needGuild: "请在群聊中使用此指令。";
388
- readonly invalidKind: (value: string) => string;
389
- readonly invalidDigest: (value: string) => string;
390
- readonly invalidTid: (value: string) => string;
391
- readonly invalidIndex: (value: string) => string;
392
- readonly noSubscription: "本群还没有订阅任何番剧,先使用 `anime.search <关键词>` 找到作品,再用 `anime.sub <ID>` 订阅。";
408
+ readonly needSession: "无法确定当前会话,请从聊天窗口重试。";
409
+ readonly invalidKind: (value: string) => h;
410
+ readonly invalidDigest: (value: string) => h;
411
+ readonly invalidTid: (value: string) => h;
412
+ readonly invalidIndex: (value: string) => h;
413
+ readonly noSubscription: "本会话还没有订阅任何番剧,先使用 `anime.search <关键词>` 找到作品,再用 `anime.sub <ID>` 订阅。";
393
414
  readonly subscribeLimit: (limit: number) => string;
394
- readonly alreadySubscribed: (title: string) => string;
415
+ readonly alreadySubscribed: (title: string) => h;
395
416
  readonly subscribeFailed: "订阅失败,请稍后重试或检查后台日志。";
396
417
  readonly databaseFailed: "数据库操作失败,请检查后台日志。";
397
418
  readonly renderFailed: "图片渲染失败,已改用文本发送。";
398
- readonly emptySearch: (keyword: string) => string;
419
+ readonly emptySearch: (keyword: string) => h;
399
420
  readonly notFound: "未找到该作品,可能不在 bangumi-data 索引中。";
400
421
  };
401
422
  /** 日志里出现的固定短语 */