koishi-plugin-anime-schedule 1.1.5 → 1.2.1

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,22 +3,31 @@ 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: {
28
+ range: {
29
+ /** 单个群或私聊最多订阅的番剧数量,0 表示不限制 */
30
+ maxPerChannel: number;
22
31
  /** 单个番组表最多展示的作品数,0 表示不限制 */
23
32
  maxItems: number;
24
33
  /** 当前话数达到该值的作品不展示,0 表示不过滤 */
@@ -27,35 +36,35 @@ export interface Config {
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
- /** AniList 播出状态的缓存有效期,单位小时 */
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
@@ -31,155 +31,202 @@ exports.Config = koishi_1.Schema.intersect([
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
- }).description('基本'),
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
- nightEnabled: koishi_1.Schema.boolean().description('深夜档(21:00–06:00)').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
- dailyTime: koishi_1.Schema.string().pattern(TIME_PATTERN).description('每日推送时刻(HH:mm)').default('08:00'),
45
- nightTime: koishi_1.Schema.string().pattern(TIME_PATTERN).description('深夜档推送时刻(HH:mm)').default('21:00'),
46
- weeklyTime: koishi_1.Schema.string().pattern(TIME_PATTERN).description('周表推送时刻(HH:mm)').default('08:00'),
47
- seasonTime: koishi_1.Schema.string().pattern(TIME_PATTERN).description('季度首日推送时刻(HH:mm)').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'),
48
71
  weeklyWeekday: koishi_1.Schema.union(WEEKDAYS.map((item) => koishi_1.Schema.const(item.value).description(item.label)))
49
72
  .description('周表推送星期')
50
73
  .default(1),
51
74
  dailyOffsetDays: koishi_1.Schema.number()
52
75
  .min(constants_1.DAILY_OFFSET_MIN).max(constants_1.DAILY_OFFSET_MAX).step(1)
53
- .description('定时每日表的日期偏移:0 今天,-1 昨天,1 明天')
76
+ .description('每日推送日期偏移,负数往前')
54
77
  .default(0),
55
78
  updateLookaheadMinutes: koishi_1.Schema.number()
56
- .min(1).step(1)
79
+ .min(1).max(constants_1.MAX_UPDATE_LOOKAHEAD_MINUTES).step(1)
57
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
- subscription: koishi_1.Schema.object({
89
+ range: koishi_1.Schema.object({
67
90
  maxPerChannel: koishi_1.Schema.number()
68
91
  .min(0).step(1)
69
- .description('单个群或私聊的订阅上限,0 不限制')
92
+ .description('单个会话订阅上限,0 不限')
70
93
  .default(0),
71
- }),
72
- }).description('订阅'),
73
- koishi_1.Schema.object({
74
- content: koishi_1.Schema.object({
75
94
  maxItems: koishi_1.Schema.number()
76
95
  .min(0).step(1)
77
- .description('单个番组表最多显示几部,0 不限制')
96
+ .description('单个番组表作品上限,0 不限')
78
97
  .default(0),
79
98
  longRunningThreshold: koishi_1.Schema.number()
80
99
  .min(0).step(1)
81
- .description('更新表中当前话数达到该值的作品不显示,0 不限制')
100
+ .description('更新表过滤话数阈值,0 关闭')
82
101
  .default(0),
83
102
  }),
84
- }).description('番组表内容'),
103
+ }).description('范围'),
85
104
  koishi_1.Schema.object({
86
105
  output: koishi_1.Schema.object({
87
106
  format: koishi_1.Schema.union([
88
107
  koishi_1.Schema.const('image').description('图片'),
89
108
  koishi_1.Schema.const('text').description('文本'),
90
109
  ])
91
- .description('番组表与详情的输出形态;图片失败时自动改用文本')
110
+ .description('番组表与详情的输出形态')
92
111
  .default('image'),
93
112
  layout: koishi_1.Schema.union([
94
113
  koishi_1.Schema.const('table').description('时间表'),
95
114
  koishi_1.Schema.const('list').description('卡片列表'),
96
115
  ])
97
- .description('番组表图片的排版')
116
+ .description('番组表图片排版')
98
117
  .default('table'),
99
- showCover: koishi_1.Schema.boolean().description('番组表图片中显示封面').default(true),
118
+ showCover: koishi_1.Schema.boolean().description('图片中显示封面').default(true),
100
119
  showScore: koishi_1.Schema.boolean()
101
- .description('番组表与搜索结果中显示 Bangumi 评分;需开启本地化,评价不足 10 条时隐藏')
120
+ .description('显示 Bangumi 评分')
102
121
  .default(true),
103
122
  useForward: koishi_1.Schema.boolean()
104
- .description('多段文本使用合并转发(群聊且适配器支持时)')
123
+ .description('多段文本使用合并转发')
105
124
  .default(true),
106
- coverLimit: koishi_1.Schema.number()
107
- .min(0)
108
- .description('单张番组表图最多加载几张封面,0 不限制')
109
- .default(0),
110
125
  infoKeywordLimit: koishi_1.Schema.number()
111
- .min(0)
112
- .description('anime.info 关键词查询最多显示几部,0 不限制')
126
+ .min(0).step(1)
127
+ .description('关键词详情最多显示几部,0 不限')
113
128
  .default(20),
114
129
  }),
115
130
  }).description('输出'),
116
131
  koishi_1.Schema.object({
117
132
  render: koishi_1.Schema.object({
118
133
  fontFamily: koishi_1.Schema.string()
119
- .description('图片字体;默认自动加载系统中文字体,也可填写本机已安装的字体')
134
+ .description('图片字体,留空自动选择')
120
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),
121
144
  coverConcurrency: koishi_1.Schema.number()
122
- .min(1)
145
+ .min(1).max(constants_1.MAX_COVER_CONCURRENCY).step(1)
123
146
  .description('封面下载并发数')
124
147
  .default(constants_1.COVER_CONCURRENCY),
125
148
  coverCacheDays: koishi_1.Schema.number()
126
- .min(0)
127
- .description('封面磁盘缓存天数,0 不写磁盘')
149
+ .min(0).step(1)
150
+ .description('封面缓存天数,0 不缓存')
128
151
  .default(21),
129
152
  jpegQuality: koishi_1.Schema.number()
130
153
  .min(1).max(100).step(1)
131
- .description('JPEG 质量(1–100),越高越清晰、体积越大')
154
+ .role('slider')
155
+ .description('JPEG 编码质量(1–100)')
132
156
  .default(constants_1.DEFAULT_JPEG_QUALITY),
133
157
  supersample: koishi_1.Schema.number()
134
- .min(1).max(constants_1.MAX_SUPERSAMPLE).step(1)
135
- .description('超采样倍数(1–5),越高越清晰、耗时与体积越大')
158
+ .min(1).max(constants_1.MAX_SUPERSAMPLE).step(0.01)
159
+ .role('slider')
160
+ .description('超采样倍数(1–5)')
136
161
  .default(constants_1.DEFAULT_SUPERSAMPLE),
137
162
  }),
138
163
  }).description('图片'),
139
164
  koishi_1.Schema.object({
140
165
  localize: koishi_1.Schema.object({
141
166
  enabled: koishi_1.Schema.boolean()
142
- .description('优先使用中文标题与 Bangumi 评分')
167
+ .description('开启后使用中文标题与评分')
143
168
  .default(true),
144
169
  titleStyle: koishi_1.Schema.union([
145
170
  koishi_1.Schema.const('localized').description('仅中文'),
146
171
  koishi_1.Schema.const('both').description('中文(日文原名)'),
147
172
  koishi_1.Schema.const('original').description('仅日文原名'),
148
173
  ])
149
- .description('本地化开启时的标题展示方式')
174
+ .description('标题展示方式')
150
175
  .default('localized'),
151
176
  cacheTtlDays: koishi_1.Schema.number()
152
177
  .min(1).step(1)
153
- .description('标题与封面地址的缓存天数')
178
+ .description('标题与封面地址缓存天数')
154
179
  .default(30),
155
180
  scoreTtlHours: koishi_1.Schema.number()
156
181
  .min(1).step(1)
157
- .description('评分与评价人数的刷新间隔(小时)')
182
+ .description('评分刷新间隔(小时)')
158
183
  .default(constants_1.DEFAULT_SCORE_TTL_HOURS),
159
184
  airingTtlHours: koishi_1.Schema.number()
160
185
  .min(1).step(1)
161
- .description('AniList 播出状态缓存(小时)')
186
+ .description('播出状态缓存(小时)')
162
187
  .default(6),
163
188
  }),
164
189
  }).description('本地化'),
165
190
  koishi_1.Schema.object({
166
191
  advanced: koishi_1.Schema.object({
167
192
  requestTimeout: koishi_1.Schema.number()
168
- .min(1)
193
+ .min(1).max(constants_1.MAX_REQUEST_TIMEOUT_SECONDS)
169
194
  .description('默认请求超时(秒)')
170
195
  .default(constants_1.LOCALIZE_TIMEOUT_SECONDS),
171
196
  retries: koishi_1.Schema.number()
172
- .min(0)
173
- .description('请求失败后的默认重试次数')
197
+ .min(0).max(constants_1.MAX_RETRIES).step(1)
198
+ .description('请求失败重试次数')
174
199
  .default(2),
175
200
  debug: koishi_1.Schema.boolean()
176
- .description('输出调试日志')
201
+ .description('开启后输出调试日志')
177
202
  .default(false),
178
203
  }),
179
204
  }).description('高级'),
180
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
+ }
181
223
  /** 把配置夹到安全区间:只保证类型正确且不小于最小值,不设人为上限 */
182
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 ?? {};
183
230
  /** 取整并夹到不小于 `min`(默认 0)。允许负值的字段不能走这个默认值 */
184
231
  const int = (value, fallback, min = 0) => {
185
232
  if (typeof value !== 'number' || !Number.isFinite(value))
@@ -192,60 +239,77 @@ function normalizeConfig(config) {
192
239
  return fallback;
193
240
  return Math.min(max, Math.max(min, Math.round(value)));
194
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);
195
249
  const time = (value, fallback) => (typeof value === 'string' && TIME_PATTERN.test(value) ? value : fallback);
196
250
  // 旧版本的 `both` 形态已移除:非 `text` 一律按图片处理
197
251
  const format = config.output?.format === 'text' ? 'text' : 'image';
198
- // 轮询间隔不能大于提前量:调度器每 poll 分钟检查一次 [now, now+lookahead] 窗口,
199
- // 间隔更大时两次检查之间会留下覆盖不到的空档,场次静默漏发
200
- const lookahead = int(config.push?.updateLookaheadMinutes, 30, 1);
201
- 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);
202
259
  return {
203
260
  ...config,
204
261
  timeZone: (0, time_1.resolveTimeZone)(config.timeZone, 'Asia/Shanghai'),
205
262
  push: {
206
- ...config.push,
207
- dailyTime: time(config.push?.dailyTime, '08:00'),
208
- dailyOffsetDays: intBetween(config.push?.dailyOffsetDays, 0, constants_1.DAILY_OFFSET_MIN, constants_1.DAILY_OFFSET_MAX),
209
- weeklyWeekday: Math.max(0, Math.min(6, int(config.push?.weeklyWeekday, 1))),
210
- nightTime: time(config.push?.nightTime, '21:00'),
211
- weeklyTime: time(config.push?.weeklyTime, '08:00'),
212
- 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),
213
277
  updateLookaheadMinutes: lookahead,
214
278
  updatePollMinutes: Math.min(poll, lookahead),
215
279
  },
216
- content: {
217
- maxItems: int(config.content?.maxItems, 0),
218
- 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),
219
284
  },
220
285
  output: {
221
- ...config.output,
222
286
  format,
223
287
  layout: config.output?.layout === 'list' ? 'list' : 'table',
224
- coverLimit: int(config.output?.coverLimit, 0),
225
288
  infoKeywordLimit: int(config.output?.infoKeywordLimit, 20),
226
- },
227
- localize: {
228
- ...config.localize,
229
- cacheTtlDays: int(config.localize?.cacheTtlDays, 30, 1),
230
- scoreTtlHours: int(config.localize?.scoreTtlHours, constants_1.DEFAULT_SCORE_TTL_HOURS, 1),
231
- 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),
232
292
  },
233
293
  render: {
234
- ...config.render,
235
294
  fontFamily: config.render?.fontFamily?.trim() || constants_1.DEFAULT_FONT_FAMILY,
236
- 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)),
237
298
  coverCacheDays: int(config.render?.coverCacheDays, 21),
238
299
  jpegQuality: Math.min(100, int(config.render?.jpegQuality, constants_1.DEFAULT_JPEG_QUALITY, 1)),
239
- 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),
240
301
  },
241
- subscription: {
242
- ...config.subscription,
243
- 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),
244
308
  },
245
309
  advanced: {
246
- ...config.advanced,
247
- requestTimeout: int(config.advanced?.requestTimeout, constants_1.LOCALIZE_TIMEOUT_SECONDS, 1),
248
- 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),
249
313
  },
250
314
  };
251
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,8 +128,18 @@ 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;
@@ -148,10 +161,12 @@ export declare const BOLD_FONT_CANDIDATES: string[];
148
161
  /**
149
162
  * JPEG 编码质量。
150
163
  *
151
- * 图片以文字与细线条为主,块状伪影比在照片上明显。取 100 为无损编码,文字边缘最锐利;
152
- * 体积比 92 约多三成,可调低换取更小体积。
164
+ * 图片以文字与细线条为主,块状伪影比在照片上明显;默认 90 兼顾清晰度与发送体积,
165
+ * 需要更高画质可在控制台用滑块调到 100。
153
166
  */
154
- 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];
155
170
  /**
156
171
  * 超采样倍数。
157
172
  *
@@ -159,7 +174,7 @@ export declare const DEFAULT_JPEG_QUALITY = 100;
159
174
  * 得出边缘像素。清晰度主要取决于此:各版面最小字号仅 10~11px,1× 下一个字不足十几个
160
175
  * 像素,JPEG 质量再高也无法还原。
161
176
  *
162
- * 3 在密集的封面与小字上收益仍可见;5 是收益递减的上限。
177
+ * 2 更快、更省内存;3 在密集的封面与小字上收益仍可见;5 是收益递减的上限。
163
178
  */
164
179
  export declare const DEFAULT_SUPERSAMPLE = 3;
165
180
  /** 超采样倍数的可选上限,与配置项的 `.max()` 保持一致 */
@@ -172,6 +187,8 @@ export declare const MAX_SUPERSAMPLE = 5;
172
187
  */
173
188
  export declare const DAILY_OFFSET_MIN = -7;
174
189
  export declare const DAILY_OFFSET_MAX = 7;
190
+ /** 开播提醒提前量的可选上限(分钟),7 天;取数窗口会按该值动态放大 */
191
+ export declare const MAX_UPDATE_LOOKAHEAD_MINUTES: number;
175
192
  /**
176
193
  * 构建结果的复用窗口(毫秒)。
177
194
  *
@@ -182,8 +199,13 @@ export declare const DAILY_OFFSET_MAX = 7;
182
199
  export declare const BUILD_CACHE_TTL_MS: number;
183
200
  /** 构建结果同时留存几份(日/深夜/周/季 × 少量偏移),超出丢最早的一份 */
184
201
  export declare const BUILD_CACHE_MAX_ENTRIES = 16;
185
- /** 默认字体别名;实际字体文件由 registerFonts 从系统字体中加载 */
186
- 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";
187
209
  /**
188
210
  * 图片版式常量。
189
211
  *
@@ -324,7 +346,7 @@ export declare const IMAGE_THEME: {
324
346
  export interface Messages {
325
347
  weekdayNames: string[];
326
348
  dailyHeader: (date: string) => string;
327
- nightHeader: (date: string) => string;
349
+ nightHeader: (date: string, start: string, end: string) => string;
328
350
  weeklyHeader: (start: string, end: string) => string;
329
351
  seasonHeader: (label: string) => string;
330
352
  subHeader: (count: number) => string;
@@ -338,7 +360,7 @@ export interface Messages {
338
360
  /** 每日表与订阅表里「当天」那一段的标题 */
339
361
  daytimeGroup: string;
340
362
  /** 深夜档推送里「今晚 21:00 起」那一段的标题 */
341
- tonightGroup: (date: string) => string;
363
+ tonightGroup: (date: string, start: string) => string;
342
364
  /** 订阅表里「次日凌晨」那一段的标题 */
343
365
  tomorrowDawnGroup: (date: string) => string;
344
366
  seasonLabel: (year: number, month: number) => string;
@@ -383,18 +405,18 @@ export declare const MESSAGES: Record<PluginLocale, Messages>;
383
405
  export declare function getMessages(locale: PluginLocale): Messages;
384
406
  /** 交互回复:完整句,结尾带句号 */
385
407
  export declare const RESPONSES: {
386
- readonly needGuild: "请在群聊中使用此指令。";
387
- readonly invalidKind: (value: string) => string;
388
- readonly invalidDigest: (value: string) => string;
389
- readonly invalidTid: (value: string) => string;
390
- readonly invalidIndex: (value: string) => string;
391
- 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>` 订阅。";
392
414
  readonly subscribeLimit: (limit: number) => string;
393
- readonly alreadySubscribed: (title: string) => string;
415
+ readonly alreadySubscribed: (title: string) => h;
394
416
  readonly subscribeFailed: "订阅失败,请稍后重试或检查后台日志。";
395
417
  readonly databaseFailed: "数据库操作失败,请检查后台日志。";
396
418
  readonly renderFailed: "图片渲染失败,已改用文本发送。";
397
- readonly emptySearch: (keyword: string) => string;
419
+ readonly emptySearch: (keyword: string) => h;
398
420
  readonly notFound: "未找到该作品,可能不在 bangumi-data 索引中。";
399
421
  };
400
422
  /** 日志里出现的固定短语 */