koishi-plugin-bilibili-notify 0.0.1 → 0.1.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.
@@ -3,9 +3,27 @@ declare class ComRegister {
3
3
  static inject: string[];
4
4
  logger: Logger;
5
5
  config: ComRegister.Config;
6
+ id: number;
7
+ sub: {
8
+ id: number;
9
+ uid: string;
10
+ room_id: string;
11
+ dynamic: number;
12
+ video: 1;
13
+ live: number;
14
+ time: Date;
15
+ };
16
+ subManager: {
17
+ uid: string;
18
+ roomId: string;
19
+ live: boolean;
20
+ dynamic: boolean;
21
+ liveDispose: Function;
22
+ dynamicDispose: Function;
23
+ }[];
6
24
  constructor(ctx: Context, config: ComRegister.Config);
7
- dynamicDetect(ctx: Context, session: Session, uid: string, dispose: Function): () => Promise<"账号未登录" | "未知错误">;
8
- liveDetect(ctx: Context, session: Session, roomId: string, dispose: Function): () => Promise<void>;
25
+ dynamicDetect(ctx: Context, session: Session, uid: string): () => Promise<"账号未登录" | "未知错误">;
26
+ liveDetect(ctx: Context, session: Session, roomId: string): () => Promise<void>;
9
27
  checkIfNeedSub(comNeed: boolean, subType: string, session: Session, data?: any): Promise<boolean>;
10
28
  }
11
29
  declare namespace ComRegister {
@@ -13,9 +13,12 @@ var LiveType;
13
13
  LiveType[LiveType["LiveBroadcast"] = 2] = "LiveBroadcast";
14
14
  })(LiveType || (LiveType = {}));
15
15
  class ComRegister {
16
- static inject = ['biliAPI', 'gimg', 'wbi'];
16
+ static inject = ['biliAPI', 'gimg', 'wbi', 'database'];
17
17
  logger;
18
18
  config;
19
+ id = 1;
20
+ sub;
21
+ subManager = [];
19
22
  constructor(ctx, config) {
20
23
  this.logger = ctx.logger('commandRegister');
21
24
  this.config = config;
@@ -67,6 +70,13 @@ class ComRegister {
67
70
  const [pic] = await ctx.gimg.generateDynamicImg(data.items[index]);
68
71
  return pic;
69
72
  });
73
+ ctx.command('test')
74
+ .subcommand('.subm')
75
+ .usage('查看订阅对象状态')
76
+ .example('test subm')
77
+ .action(() => {
78
+ console.log(this.subManager);
79
+ });
70
80
  ctx.command('bili', 'bili-notify插件相关指令')
71
81
  .subcommand('.login', '登录B站之后才可以进行之后的操作')
72
82
  .usage('使用二维码登录,登录B站之后才可以进行之后的操作')
@@ -121,18 +131,61 @@ class ComRegister {
121
131
  }
122
132
  }, 1000);
123
133
  });
134
+ ctx.command('bili')
135
+ .subcommand('.unsub <uid:string>')
136
+ .usage('取消订阅')
137
+ .example('bili unsub 用户UID')
138
+ .action(({ session }, uid) => {
139
+ if (!uid)
140
+ return '用户UID不能为空';
141
+ // 定义是否存在
142
+ let exist = false;
143
+ this.subManager.forEach((sub, i) => {
144
+ if (sub.uid === uid) {
145
+ // 执行dispose方法,销毁定时器
146
+ this.subManager[i].dynamicDispose();
147
+ this.subManager[i].liveDispose();
148
+ // 将该订阅对象从订阅管理对象中移除
149
+ this.subManager = this.subManager.splice(i, i);
150
+ // 发送成功通知
151
+ session.send('已取消订阅该用户');
152
+ // 将存在flag设置为true
153
+ exist = true;
154
+ }
155
+ });
156
+ // 未订阅该用户,无需取消订阅
157
+ !exist && session.send('未订阅该用户,无需取消订阅');
158
+ });
159
+ ctx.command('bili')
160
+ .subcommand('.show')
161
+ .usage('展示订阅对象')
162
+ .example('bili show')
163
+ .action(async ({ session }) => {
164
+ let table = ``;
165
+ this.subManager.forEach(sub => {
166
+ table += 'UID:' + sub.uid + ' RoomID:' + sub.roomId + '\n';
167
+ });
168
+ !table && session.send('没有订阅任何UP');
169
+ table && session.send(table);
170
+ });
124
171
  ctx.command('bili')
125
172
  .subcommand('.sub <mid:string> [groupid:string]')
126
173
  .option('live', '-l')
127
174
  .option('dynamic', '-d')
128
175
  .usage('订阅用户动态和直播通知,若需要订阅直播请加上-l,需要订阅动态则加上-d。若没有加任何参数,之后会向你单独询问,<>中为必选参数,[]中为可选参数,目标群号若不填,则默认为当前群聊')
129
- .example('bili sub 用户uid 目标QQ群号(可选) -l -d')
176
+ .example('bili sub 用户uid 目标QQ群号(暂不支持) -l -d')
130
177
  .action(async ({ session, options }, mid, groupid) => {
131
178
  this.logger.info('调用bili.sub指令');
132
179
  // 检查必选参数是否有值
133
180
  if (mid === undefined) {
134
181
  return '请输入用户uid';
135
182
  }
183
+ // 判断要订阅的用户是否已经存在于订阅管理对象中
184
+ this.subManager && this.subManager.forEach((sub) => {
185
+ // 已订阅该用户
186
+ if (sub.uid === mid)
187
+ return session.send('已订阅该用户,请勿重复订阅');
188
+ });
136
189
  // 定义是否需要直播通知,动态订阅,视频推送
137
190
  let liveMsg, dynamicMsg;
138
191
  // 获取用户信息
@@ -163,7 +216,37 @@ class ComRegister {
163
216
  liveMsg = await this.checkIfNeedSub(options.live, '直播', session, data);
164
217
  // 判断是否需要订阅动态
165
218
  dynamicMsg = await this.checkIfNeedSub(options.dynamic, '动态', session);
166
- // console.log(liveMsg, dynamicMsg, videoMsg);
219
+ // 构造订阅对象
220
+ this.sub = {
221
+ id: this.id,
222
+ uid: mid,
223
+ room_id: data.live_room.roomid.toString(),
224
+ dynamic: dynamicMsg ? 1 : 0,
225
+ video: 1,
226
+ live: liveMsg ? 1 : 0,
227
+ time: new Date()
228
+ };
229
+ // 保存到数据库中
230
+ await ctx.database.upsert('bilibili', [this.sub]);
231
+ // 让id自增
232
+ this.id++;
233
+ // 开始订阅
234
+ // 保存新订阅对象
235
+ this.subManager.push({
236
+ uid: mid,
237
+ roomId: data.live_room.roomid.toString(),
238
+ live: liveMsg,
239
+ dynamic: dynamicMsg,
240
+ liveDispose: null,
241
+ dynamicDispose: null
242
+ });
243
+ // 需要订阅直播
244
+ if (liveMsg)
245
+ await session.execute(`bili live ${data.live_room.roomid}`);
246
+ // 需要订阅动态
247
+ if (dynamicMsg)
248
+ await session.execute(`bili dynamic ${mid}`);
249
+ // 发送订阅成功通知
167
250
  });
168
251
  ctx.command('bili')
169
252
  .subcommand('.dynamic <uid:string>')
@@ -171,23 +254,63 @@ class ComRegister {
171
254
  .example('bili dynamic 1')
172
255
  .action(async ({ session }, uid) => {
173
256
  this.logger.info('调用bili.dynamic指令');
174
- let dispose;
257
+ // 如果uid为空则返回
258
+ if (!uid) {
259
+ await session.send('用户uid不能为空');
260
+ return;
261
+ }
262
+ // 定义订阅对象索引
263
+ let index;
264
+ // 定义要订阅的对象是否存在于订阅管理对象中
265
+ let exist;
266
+ // 保存到订阅管理对象
267
+ this.subManager.forEach((sub, i) => {
268
+ if (sub.uid === uid) {
269
+ exist = true;
270
+ index = i;
271
+ }
272
+ });
273
+ // 不存在则直接返回
274
+ if (!exist) {
275
+ session.send('请勿直接调用该指令');
276
+ return;
277
+ }
175
278
  // 开始循环检测
176
- dispose = ctx.setInterval(this.dynamicDetect(ctx, session, uid, dispose), 60000);
279
+ const dispose = ctx.setInterval(this.dynamicDetect(ctx, session, uid), 60000);
280
+ // 将销毁函数保存到订阅管理对象
281
+ this.subManager[index].dynamicDispose = dispose;
177
282
  });
178
283
  ctx.command('bili')
179
284
  .subcommand('.live <roomId:string>')
180
285
  .usage('订阅主播开播通知')
181
286
  .example('bili live 732')
182
287
  .action(async ({ session }, roomId) => {
288
+ this.logger.info('调用bili.live指令');
289
+ // 如果room_id为空则返回
183
290
  if (!roomId) {
184
- await session.send('请输入需要订阅主播的房间号');
291
+ await session.send('订阅主播房间号不能为空');
292
+ return;
293
+ }
294
+ // 定义订阅对象索引
295
+ let index;
296
+ // 定义要订阅的对象是否存在于订阅管理对象中
297
+ let exist;
298
+ // 保存到订阅管理对象
299
+ this.subManager.forEach((sub, i) => {
300
+ if (sub.roomId === roomId) {
301
+ exist = true;
302
+ index = i;
303
+ }
304
+ });
305
+ // 要订阅的对象不在订阅管理对象中,直接返回
306
+ if (!exist) {
307
+ await session.send('请勿直接调用该指令');
185
308
  return;
186
309
  }
187
- this.logger.info('调用bili.live指令');
188
- let dispose;
189
310
  // 开始循环检测
190
- dispose = ctx.setInterval(this.liveDetect(ctx, session, roomId, dispose), 5000);
311
+ const dispose = ctx.setInterval(this.liveDetect(ctx, session, roomId), 5000);
312
+ // 保存销毁函数
313
+ this.subManager[index].liveDispose = dispose;
191
314
  });
192
315
  ctx.command('bili')
193
316
  .subcommand('.status <roomId:string>')
@@ -206,18 +329,18 @@ class ComRegister {
206
329
  session.send('未找到该房间!');
207
330
  }
208
331
  else {
209
- console.log(content);
210
332
  session.send('未知错误,请呼叫管理员检查问题!');
211
333
  }
212
334
  return;
213
335
  }
214
- const string = await ctx.gimg.generateLiveImg(data, userData, data.live_status === 1 ?
215
- LiveType.StartBroadcasting :
216
- LiveType.NotLiveBroadcast);
336
+ let liveTime = (new Date(data.live_time).getTime()) / 1000;
337
+ const string = await ctx.gimg.generateLiveImg(data, userData, data.live_status !== 1 ?
338
+ LiveType.NotLiveBroadcast :
339
+ liveTime < Date.now() ? LiveType.LiveBroadcast : LiveType.StartBroadcasting);
217
340
  session.send(string);
218
341
  });
219
342
  }
220
- dynamicDetect(ctx, session, uid, dispose) {
343
+ dynamicDetect(ctx, session, uid) {
221
344
  let firstSubscription = true;
222
345
  let timePoint;
223
346
  return async () => {
@@ -228,8 +351,7 @@ class ComRegister {
228
351
  // 发送订阅消息通知
229
352
  session.send(`订阅${userData.info.uname}动态通知!`);
230
353
  // 设置第一次的时间点
231
- timePoint = (await ctx.biliAPI.getTimeNow()).data.now;
232
- console.log(timePoint);
354
+ timePoint = Date.now();
233
355
  // 设置第一次为false
234
356
  firstSubscription = false;
235
357
  return;
@@ -256,16 +378,25 @@ class ComRegister {
256
378
  continue;
257
379
  // 寻找发布时间比时间点时间更晚的动态
258
380
  if (items[num].modules.module_author.pub_ts > timePoint) {
259
- // 将时间点设置为这条动态的发布时间
260
- timePoint = items[num].modules.module_author.pub_ts;
381
+ // 如果这是遍历的最后一条,将时间点设置为这条动态的发布时间
382
+ /* if (num === 1) timePoint = items[num].modules.module_author.pub_ts
383
+ if (num === 0) {
384
+ timePoint = items[num].modules.module_author.pub_ts
385
+ } */
386
+ switch (num) {
387
+ // 如果是置顶动态,则跳过
388
+ case 0: if (items[num].modules.module_tag)
389
+ continue;
390
+ case 1: timePoint = items[num].modules.module_author.pub_ts;
391
+ }
261
392
  // 推送该条动态
262
- const [pic, _] = await ctx.gimg.generateDynamicImg(items[num]);
393
+ const [pic] = await ctx.gimg.generateDynamicImg(items[num]);
263
394
  session.send(pic);
264
395
  }
265
396
  }
266
397
  };
267
398
  }
268
- liveDetect(ctx, session, roomId, dispose) {
399
+ liveDetect(ctx, session, roomId) {
269
400
  let firstSubscription = true;
270
401
  let timer = 0;
271
402
  let open = false;
@@ -286,10 +417,9 @@ class ComRegister {
286
417
  session.send('未找到该房间!');
287
418
  }
288
419
  else {
289
- console.log(content);
290
420
  session.send('未知错误,请呼叫管理员检查问题!');
291
421
  }
292
- dispose();
422
+ // dispose
293
423
  return;
294
424
  }
295
425
  if (firstSubscription) {
@@ -337,7 +467,6 @@ class ComRegister {
337
467
  uData = userData;
338
468
  // 发送直播通知
339
469
  await session.send(await ctx.gimg.generateLiveImg(data, uData, LiveType.StartBroadcasting));
340
- await session.send(`https://live.bilibili.com/${roomId}`);
341
470
  }
342
471
  else { // 还在直播
343
472
  if (this.config.pushTime > 0) {
@@ -350,7 +479,6 @@ class ComRegister {
350
479
  session.send(await ctx
351
480
  .gimg
352
481
  .generateLiveImg(data, uData, LiveType.LiveBroadcast));
353
- await session.send(`https://live.bilibili.com/${roomId}`);
354
482
  }
355
483
  }
356
484
  // 否则继续循环
@@ -12,13 +12,13 @@ declare class GenerateImg extends Service {
12
12
  generateLiveImg(data: any, userData: any, liveStatus: number): Promise<string>;
13
13
  generateDynamicImg(data: any): Promise<string[]>;
14
14
  getLiveStatus(time: string, liveStatus: number): [string, string, boolean];
15
- getTimeDifference(dateString: string): void;
15
+ getTimeDifference(dateString: string): string;
16
16
  unixTimestampToString(timestamp: number): string;
17
17
  }
18
18
  declare namespace GenerateImg {
19
19
  interface Config {
20
- pushCardColorStart: string;
21
- pushCardColorEnd: string;
20
+ cardColorStart: string;
21
+ cardColorEnd: string;
22
22
  }
23
23
  const Config: Schema<Config>;
24
24
  }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const koishi_1 = require("koishi");
4
+ // 动态类型
4
5
  const DYNAMIC_TYPE_NONE = 'DYNAMIC_TYPE_NONE';
5
6
  const DYNAMIC_TYPE_FORWARD = 'DYNAMIC_TYPE_FORWARD';
6
7
  const DYNAMIC_TYPE_AV = 'DYNAMIC_TYPE_AV';
@@ -23,8 +24,18 @@ const DYNAMIC_TYPE_LIVE_RCMD = 'DYNAMIC_TYPE_LIVE_RCMD';
23
24
  const DYNAMIC_TYPE_BANNER = 'DYNAMIC_TYPE_BANNER';
24
25
  const DYNAMIC_TYPE_UGC_SEASON = 'DYNAMIC_TYPE_UGC_SEASON';
25
26
  const DYNAMIC_TYPE_SUBSCRIPTION_NEW = 'DYNAMIC_TYPE_SUBSCRIPTION_NEW';
27
+ // 内容卡片类型
28
+ const ADDITIONAL_TYPE_NONE = 'ADDITIONAL_TYPE_NONE';
29
+ const ADDITIONAL_TYPE_PGC = 'ADDITIONAL_TYPE_PGC';
30
+ const ADDITIONAL_TYPE_GOODS = 'ADDITIONAL_TYPE_GOODS';
31
+ const ADDITIONAL_TYPE_VOTE = 'ADDITIONAL_TYPE_VOTE';
32
+ const ADDITIONAL_TYPE_COMMON = 'ADDITIONAL_TYPE_COMMON';
33
+ const ADDITIONAL_TYPE_MATCH = 'ADDITIONAL_TYPE_MATCH';
34
+ const ADDITIONAL_TYPE_UP_RCMD = 'ADDITIONAL_TYPE_UP_RCMD';
35
+ const ADDITIONAL_TYPE_UGC = 'ADDITIONAL_TYPE_UGC';
36
+ const ADDITIONAL_TYPE_RESERVE = 'ADDITIONAL_TYPE_RESERVE';
26
37
  class GenerateImg extends koishi_1.Service {
27
- static inject = ['puppeteer'];
38
+ static inject = ['puppeteer', 'biliAPI'];
28
39
  config;
29
40
  constructor(ctx, config) {
30
41
  super(ctx, 'gimg');
@@ -56,7 +67,7 @@ class GenerateImg extends koishi_1.Service {
56
67
  .background {
57
68
  width: 770px;
58
69
  height: auto;
59
- background: linear-gradient(to right bottom, ${this.config.pushCardColorStart}, ${this.config.pushCardColorEnd});
70
+ background: linear-gradient(to right bottom, ${this.config.cardColorStart}, ${this.config.cardColorEnd});
60
71
  overflow: hidden;
61
72
  }
62
73
 
@@ -131,6 +142,7 @@ class GenerateImg extends koishi_1.Service {
131
142
  .card-link {
132
143
  text-decoration: none;
133
144
  font-size: 20px;
145
+ margin-top: 10px;
134
146
  margin-bottom: 10px;
135
147
  }
136
148
  </style>
@@ -169,6 +181,7 @@ class GenerateImg extends koishi_1.Service {
169
181
  const avatarUrl = module_author.face;
170
182
  const upName = module_author.name;
171
183
  let pubTime = this.unixTimestampToString(module_author.pub_ts);
184
+ // dynamicCard
172
185
  let dynamicCardUrl;
173
186
  let dynamicCardId;
174
187
  let dynamicCardColor;
@@ -184,135 +197,273 @@ class GenerateImg extends koishi_1.Service {
184
197
  const like = module_stat.like.count;
185
198
  // TOPIC
186
199
  const topic = data.modules.module_dynamic.topic ? data.modules.module_dynamic.topic.name : '';
187
- // Main content
188
- let main = '';
189
- // Link
190
- let link = '';
191
- // 判断动态类型
192
- switch (data.type) {
193
- case DYNAMIC_TYPE_WORD:
194
- case DYNAMIC_TYPE_DRAW: {
195
- // DYNAMIC_TYPE_DRAW 带图动态 DYNAMIC_TYPE_WORD 带图动态
196
- const module_dynamic = data.modules.module_dynamic;
197
- const richText = module_dynamic.desc.rich_text_nodes.reduce((accumulator, currentValue) => {
198
- if (currentValue.emoji) {
199
- return accumulator + `<img style="width:22px; height:22px;" src="${currentValue.emoji.icon_url}"/>`;
200
- }
201
- else {
202
- return accumulator + currentValue.text;
200
+ async function getDynamicMajor(dynamicMajorData, forward) {
201
+ // 定义返回值
202
+ let main = '';
203
+ let link = '';
204
+ // 定义forward类型返回值
205
+ let forwardInfo;
206
+ // 最基本的图文处理
207
+ function basicDynamic() {
208
+ const module_dynamic = dynamicMajorData.modules.module_dynamic;
209
+ if (module_dynamic.desc) {
210
+ const richText = module_dynamic.desc.rich_text_nodes.reduce((accumulator, currentValue) => {
211
+ if (currentValue.emoji) {
212
+ return accumulator + `<img style="width:22px; height:22px;" src="${currentValue.emoji.icon_url}"/>`;
213
+ }
214
+ else {
215
+ return accumulator + currentValue.text;
216
+ }
217
+ }, '');
218
+ // 查找\n
219
+ const text = richText.replace(/\n/g, '<br>');
220
+ // 拼接字符串
221
+ if (text) {
222
+ main += `
223
+ <div class="card-details">
224
+ ${text}
225
+ </div>
226
+ `;
203
227
  }
204
- }, '');
205
- // 查找\n
206
- const text = richText.replace(/\n/g, '<br>');
228
+ }
229
+ // 图片
207
230
  let major = '';
208
- if (module_dynamic.major) {
231
+ if (module_dynamic.major && module_dynamic.major.draw) {
209
232
  if (module_dynamic.major.draw.items.length === 1) {
210
- major = `<img class="single-photo-item" src="${module_dynamic.major.draw.items[0].src}"/>`;
233
+ major += `<img class="single-photo-item" src="${module_dynamic.major.draw.items[0].src}"/>`;
234
+ }
235
+ else if (module_dynamic.major.draw.items.length === 4) {
236
+ major += module_dynamic.major.draw.items.reduce((acc, cV) => {
237
+ return acc + `<img class="four-photo-item" src="${cV.src}"/>`;
238
+ }, '');
211
239
  }
212
240
  else {
213
- major = module_dynamic.major.draw.items.reduce((acc, cV) => {
241
+ major += module_dynamic.major.draw.items.reduce((acc, cV) => {
214
242
  return acc + `<img class="photo-item" src="${cV.src}"/>`;
215
243
  }, '');
216
244
  }
245
+ main += `
246
+ <div class="card-major">
247
+ ${major}
248
+ </div>
249
+ `;
217
250
  }
218
- main = `
219
- <div class="card-details">
220
- ${text}
221
- </div>
222
- <div class="card-major">
223
- ${major}
224
- </div>
225
- `;
226
- link = `请将$替换为. www$bilibili$com/opus/${data.id_str}`;
227
- break;
228
251
  }
229
- case DYNAMIC_TYPE_AV: { // 投稿新视频
230
- const archive = data.modules.module_dynamic.major.archive;
231
- if (archive.badge.text === '投稿视频') {
232
- pubTime = `${pubTime} · 投稿了视频`;
233
- }
234
- main = `
235
- <div class="card-video">
236
- <div class="video-cover">
237
- <img src="${archive.cover}"
238
- alt="">
239
- <div class="cover-mask"></div>
240
- <span>${archive.duration_text}</span>
241
- </div>
242
- <div class="video-info">
243
- <div class="video-info-header">
244
- <div class="video-title">
245
- ${archive.title}
252
+ // 判断动态类型
253
+ switch (dynamicMajorData.type) {
254
+ case DYNAMIC_TYPE_WORD:
255
+ case DYNAMIC_TYPE_DRAW:
256
+ case DYNAMIC_TYPE_FORWARD: {
257
+ // DYNAMIC_TYPE_DRAW 带图动态 DYNAMIC_TYPE_WORD 文字动态 DYNAMIC_TYPE_FORWARD 转发动态
258
+ basicDynamic();
259
+ // 转发动态
260
+ if (dynamicMajorData.type === DYNAMIC_TYPE_FORWARD) {
261
+ // User info
262
+ const forward_module_author = dynamicMajorData.orig.modules.module_author;
263
+ const forwardUserAvatarUrl = forward_module_author.face;
264
+ const forwardUserName = forward_module_author.name;
265
+ // 获取转发的动态
266
+ const [forwardMain, _, forwardInfo] = await getDynamicMajor(dynamicMajorData.orig, true);
267
+ // 拼接main
268
+ main += `
269
+ <div class="card-forward">
270
+ <div class="forward-userinfo">
271
+ <img class="forward-avatar" src="${forwardUserAvatarUrl}" alt="">
272
+ <span class="forward-username">${forwardUserName} ${forwardInfo}</span>
246
273
  </div>
247
- <div class="video-introduction">
248
- ${archive.desc}
274
+ <div class="forward-main">
275
+ ${forwardMain}
249
276
  </div>
250
277
  </div>
251
- <div class="video-stat">
252
- <div class="video-stat-item">
253
- <svg style="width: 16px; height: 16px;" xmlns="http://www.w3.org/2000/svg"
254
- xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 16 16" width="16"
255
- height="16">
256
- <path
257
- d="M8 3.3320333333333334C6.321186666666667 3.3320333333333334 4.855333333333333 3.4174399999999996 3.820593333333333 3.5013466666666666C3.1014733333333333 3.5596599999999996 2.5440733333333334 4.109013333333333 2.48 4.821693333333333C2.4040466666666664 5.666533333333334 2.333333333333333 6.780666666666666 2.333333333333333 7.998666666666666C2.333333333333333 9.216733333333334 2.4040466666666664 10.330866666666665 2.48 11.175699999999999C2.5440733333333334 11.888366666666666 3.1014733333333333 12.437733333333334 3.820593333333333 12.496066666666666C4.855333333333333 12.579933333333333 6.321186666666667 12.665333333333333 8 12.665333333333333C9.678999999999998 12.665333333333333 11.144933333333334 12.579933333333333 12.179733333333333 12.496033333333333C12.898733333333332 12.4377 13.456 11.888533333333331 13.520066666666667 11.176033333333333C13.595999999999998 10.331533333333333 13.666666666666666 9.217633333333332 13.666666666666666 7.998666666666666C13.666666666666666 6.779766666666667 13.595999999999998 5.665846666666667 13.520066666666667 4.821366666666666C13.456 4.108866666666666 12.898733333333332 3.55968 12.179733333333333 3.5013666666666663C11.144933333333334 3.417453333333333 9.678999999999998 3.3320333333333334 8 3.3320333333333334zM3.7397666666666667 2.50462C4.794879999999999 2.41906 6.288386666666666 2.3320333333333334 8 2.3320333333333334C9.7118 2.3320333333333334 11.2054 2.4190733333333334 12.260533333333331 2.5046399999999998C13.458733333333331 2.6018133333333333 14.407866666666665 3.5285199999999994 14.516066666666667 4.73182C14.593933333333332 5.597933333333334 14.666666666666666 6.7427 14.666666666666666 7.998666666666666C14.666666666666666 9.2547 14.593933333333332 10.399466666666665 14.516066666666667 11.2656C14.407866666666665 12.468866666666665 13.458733333333331 13.395566666666667 12.260533333333331 13.492766666666665C11.2054 13.578333333333333 9.7118 13.665333333333333 8 13.665333333333333C6.288386666666666 13.665333333333333 4.794879999999999 13.578333333333333 3.7397666666666667 13.492799999999999C2.541373333333333 13.395599999999998 1.5922066666666668 12.468633333333333 1.4840200000000001 11.265266666666665C1.4061199999999998 10.3988 1.3333333333333333 9.253866666666667 1.3333333333333333 7.998666666666666C1.3333333333333333 6.743533333333333 1.4061199999999998 5.598579999999999 1.4840200000000001 4.732153333333333C1.5922066666666668 3.5287466666666667 2.541373333333333 2.601793333333333 3.7397666666666667 2.50462z"
258
- fill="currentColor"></path>
259
- <path
260
- d="M9.8092 7.3125C10.338433333333333 7.618066666666666 10.338433333333333 8.382 9.809166666666666 8.687533333333333L7.690799999999999 9.910599999999999C7.161566666666666 10.216133333333332 6.5 9.8342 6.500006666666666 9.223066666666666L6.500006666666666 6.776999999999999C6.500006666666666 6.165873333333334 7.161566666666666 5.783913333333333 7.690799999999999 6.089479999999999L9.8092 7.3125z"
261
- fill="currentColor"></path>
262
- </svg>
263
- <span>${archive.stat.play}</span>
278
+ `;
279
+ }
280
+ // 判断是否有附加信息
281
+ if (dynamicMajorData.modules.module_dynamic.additional) {
282
+ const additional = dynamicMajorData.modules.module_dynamic.additional;
283
+ // 有附加信息,判断类型
284
+ switch (additional.type) {
285
+ case ADDITIONAL_TYPE_RESERVE: { // 预约信息
286
+ const reserve = additional.reserve;
287
+ // 定义按钮
288
+ let button;
289
+ // 判断按钮类型
290
+ if (reserve.button.uncheck.text === '已结束') {
291
+ button = `
292
+ <button class="reserve-button-end">
293
+ <span>${reserve.button.uncheck.text}</span>
294
+ </button>
295
+ `;
296
+ }
297
+ else {
298
+ button = `
299
+ <button class="reserve-button-ing">
300
+ <svg class="bili-dyn-card-reserve__action__icon" style="width: 16px; height: 16px;"
301
+ xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
302
+ viewBox="0 0 16 16" width="16" height="16">
303
+ <path
304
+ d="M3.0000133333333334 6.999199999999999C3.0000133333333334 4.23776 5.2385866666666665 1.9991866666666667 8 1.9991866666666667C10.761433333333333 1.9991866666666667 13 4.23776 13 6.999199999999999L13 9.860933333333332C13 9.923533333333333 13.024899999999999 9.983633333333334 13.069199999999999 10.027933333333333L13.588366666666666 10.5471C14.389533333333333 11.348299999999998 13.914133333333334 12.734533333333333 12.754199999999999 12.8183C11.535999999999998 12.906233333333333 9.818933333333334 12.999199999999998 8 12.999199999999998C6.181073333333334 12.999199999999998 4.464026666666666 12.906233333333333 3.2458266666666664 12.8183C2.0859066666666664 12.734533333333333 1.61046 11.348299999999998 2.4116466666666665 10.547133333333333L2.93084 10.027933333333333C2.975133333333333 9.983633333333334 3.0000133333333334 9.923533333333333 3.0000133333333334 9.860933333333332L3.0000133333333334 6.999199999999999zM8 2.9991866666666667C5.790873333333334 2.9991866666666667 4.000013333333333 4.790046666666666 4.000013333333333 6.999199999999999L4.000013333333333 9.860933333333332C4.000013333333333 10.1888 3.8697733333333333 10.5032 3.6379466666666667 10.735033333333334L3.1187466666666666 11.254233333333334C2.911966666666667 11.461 3.0317600000000002 11.800199999999998 3.317833333333333 11.820899999999998C4.5211266666666665 11.907766666666667 6.212726666666666 11.999199999999998 8 11.999199999999998C9.787266666666666 11.999199999999998 11.4789 11.907733333333333 12.682199999999998 11.820899999999998C12.968233333333332 11.800199999999998 13.088033333333332 11.461 12.881266666666665 11.254233333333334L12.362066666666665 10.735033333333334C12.130233333333333 10.5032 12 10.1888 12 9.860933333333332L12 6.999199999999999C12 4.790046666666666 10.209166666666667 2.9991866666666667 8 2.9991866666666667z"
305
+ fill="currentColor"></path>
306
+ <path
307
+ d="M8.720066666666666 2.0260466666666668C8.720066666666666 2.42372 8.397666666666666 2.746093333333333 8 2.746093333333333C7.602333333333332 2.746093333333333 7.279933333333333 2.42372 7.279933333333333 2.0260466666666668C7.279933333333333 1.6283666666666667 7.602333333333332 1.3059866666666666 8 1.3059866666666666C8.397666666666666 1.3059866666666666 8.720066666666666 1.6283666666666667 8.720066666666666 2.0260466666666668z"
308
+ fill="currentColor"></path>
309
+ <path
310
+ d="M6.791266666666666 12.499199999999998C6.791266666666666 13.173966666666667 7.335266666666667 13.715866666666665 8 13.715866666666665C8.664766666666665 13.715866666666665 9.208733333333333 13.173966666666667 9.208733333333333 12.499199999999998L10.208733333333333 12.499199999999998C10.208733333333333 13.720566666666667 9.2227 14.715866666666665 8 14.715866666666665C6.777346666666666 14.715866666666665 5.791273333333333 13.720566666666667 5.791273333333333 12.499199999999998L6.791266666666666 12.499199999999998z"
311
+ fill="currentColor"></path>
312
+ </svg>
313
+ <span>${reserve.button.uncheck.text}</span>
314
+ </button>
315
+ `;
316
+ }
317
+ main += `
318
+ <div class="card-reserve">
319
+ <div class="reserve-main">
320
+ <div class="reserve-title">
321
+ ${reserve.title}
322
+ </div>
323
+ <div class="reserve-desc">
324
+ <div class="reserve-info">
325
+ <span class="reserve-time">${reserve.desc1.text}</span>
326
+ <span class="reserve-num">${reserve.desc2.text}</span>
327
+ </div>
328
+ <div class="reserve-prize">
329
+ <svg class="bili-dyn-card-reserve__lottery__icon"
330
+ style="width: 16px; height: 16px;" xmlns="http://www.w3.org/2000/svg"
331
+ xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 16 16" width="16"
332
+ height="16">
333
+ <path
334
+ d="M2.99998 7.785666666666666C3.2761266666666664 7.785666666666666 3.49998 8.0095 3.49998 8.285666666666666L3.49998 12.285666666666666C3.49998 12.719566666666667 3.8517599999999996 13.071333333333332 4.285693333333333 13.071333333333332L11.714266666666667 13.071333333333332C12.1482 13.071333333333332 12.5 12.719566666666667 12.5 12.285666666666666L12.5 8.285666666666666C12.5 8.0095 12.723833333333333 7.785666666666666 13 7.785666666666666C13.276133333333334 7.785666666666666 13.5 8.0095 13.5 8.285666666666666L13.5 12.285666666666666C13.5 13.271866666666668 12.7005 14.071333333333332 11.714266666666667 14.071333333333332L4.285693333333333 14.071333333333332C3.2994733333333333 14.071333333333332 2.49998 13.271866666666668 2.49998 12.285666666666666L2.49998 8.285666666666666C2.49998 8.0095 2.7238399999999996 7.785666666666666 2.99998 7.785666666666666z"
335
+ fill="currentColor"></path>
336
+ <path
337
+ d="M1.9285533333333333 5.857139999999999C1.9285533333333333 5.107613333333333 2.5361666666666665 4.5 3.285693333333333 4.5L12.714266666666667 4.5C13.463799999999999 4.5 14.071399999999999 5.107613333333333 14.071399999999999 5.857139999999999L14.071399999999999 7.134066666666667C14.071399999999999 7.793799999999999 13.590066666666667 8.373766666666667 12.905000000000001 8.4432C12.058933333333332 8.528966666666665 10.470166666666666 8.642866666666666 8 8.642866666666666C5.529819999999999 8.642866666666666 3.9410399999999997 8.528966666666665 3.09498 8.4432C2.4099066666666666 8.373766666666667 1.9285533333333333 7.793799999999999 1.9285533333333333 7.134066666666667L1.9285533333333333 5.857139999999999zM3.285693333333333 5.5C3.088453333333333 5.5 2.9285533333333333 5.6599 2.9285533333333333 5.857139999999999L2.9285533333333333 7.134066666666667C2.9285533333333333 7.3082 3.0432666666666663 7.432833333333333 3.1958066666666665 7.4483C4.00544 7.530366666666667 5.560420000000001 7.6428666666666665 8 7.6428666666666665C10.439566666666666 7.6428666666666665 11.994533333333333 7.530366666666667 12.804133333333333 7.4483C12.9567 7.432833333333333 13.071399999999999 7.3082 13.071399999999999 7.134066666666667L13.071399999999999 5.857139999999999C13.071399999999999 5.6599 12.911499999999998 5.5 12.714266666666667 5.5L3.285693333333333 5.5z"
338
+ fill="currentColor"></path>
339
+ <path
340
+ d="M4.357126666666666 3.5714733333333335C4.357126666666666 2.506353333333333 5.220573333333333 1.6429066666666667 6.285693333333333 1.6429066666666667C7.350833333333332 1.6429066666666667 8.214266666666667 2.506353333333333 8.214266666666667 3.5714733333333335L8.214266666666667 5.500046666666666L6.285693333333333 5.500046666666666C5.220573333333333 5.500046666666666 4.357126666666666 4.636593333333333 4.357126666666666 3.5714733333333335zM6.285693333333333 2.6429066666666667C5.77286 2.6429066666666667 5.357126666666667 3.0586399999999996 5.357126666666667 3.5714733333333335C5.357126666666667 4.084313333333333 5.77286 4.500046666666666 6.285693333333333 4.500046666666666L7.214266666666667 4.500046666666666L7.214266666666667 3.5714733333333335C7.214266666666667 3.0586399999999996 6.798533333333333 2.6429066666666667 6.285693333333333 2.6429066666666667z"
341
+ fill="currentColor"></path>
342
+ <path
343
+ d="M7.785666666666666 3.5714733333333335C7.785666666666666 2.506353333333333 8.649133333333332 1.6429066666666667 9.714266666666667 1.6429066666666667C10.779399999999999 1.6429066666666667 11.642866666666666 2.506353333333333 11.642866666666666 3.5714733333333335C11.642866666666666 4.636593333333333 10.779399999999999 5.500046666666666 9.714266666666667 5.500046666666666L7.785666666666666 5.500046666666666L7.785666666666666 3.5714733333333335zM9.714266666666667 2.6429066666666667C9.201433333333332 2.6429066666666667 8.785666666666666 3.0586399999999996 8.785666666666666 3.5714733333333335L8.785666666666666 4.500046666666666L9.714266666666667 4.500046666666666C10.2271 4.500046666666666 10.642866666666666 4.084313333333333 10.642866666666666 3.5714733333333335C10.642866666666666 3.0586399999999996 10.2271 2.6429066666666667 9.714266666666667 2.6429066666666667z"
344
+ fill="currentColor"></path>
345
+ <path
346
+ d="M8 3.7856466666666666C8.276133333333332 3.7856466666666666 8.5 4.009499999999999 8.5 4.285646666666667L8.5 13.142800000000001C8.5 13.418933333333332 8.276133333333332 13.642800000000001 8 13.642800000000001C7.723833333333333 13.642800000000001 7.5 13.418933333333332 7.5 13.142800000000001L7.5 4.285646666666667C7.5 4.009499999999999 7.723833333333333 3.7856466666666666 8 3.7856466666666666z"
347
+ fill="currentColor"></path>
348
+ </svg>
349
+ <span>${reserve.desc3.text}</span>
350
+ <svg style="width: 12px; height: 12px;" xmlns="http://www.w3.org/2000/svg"
351
+ xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 12 12" width="12"
352
+ height="12">
353
+ <path
354
+ d="M4.359835 1.609835C4.21339 1.756285 4.21339 1.99372 4.359835 2.140165L8.0429 5.823225C8.140525 5.920875 8.140525 6.079125 8.0429 6.176775L4.359835 9.859825C4.21339 10.006275 4.21339 10.243725 4.359835 10.390175C4.506285 10.5366 4.743725 10.5366 4.89017 10.390175L8.573225 6.7071C8.96375 6.316575 8.96375 5.683425 8.573225 5.2929L4.89017 1.609835C4.743725 1.46339 4.506285 1.46339 4.359835 1.609835z"
355
+ fill="currentColor"></path>
356
+ </svg>
357
+ </div>
358
+ </div>
359
+ </div>
360
+ <div class="reserve-button">
361
+ ${button}
362
+ </div>
363
+ </div>
364
+ `;
365
+ }
366
+ }
367
+ }
368
+ link += `请将$替换为. www$bilibili$com/opus/${dynamicMajorData.id_str}`;
369
+ break;
370
+ }
371
+ case DYNAMIC_TYPE_AV: { // 投稿新视频
372
+ // 处理文字
373
+ basicDynamic();
374
+ const archive = dynamicMajorData.modules.module_dynamic.major.archive;
375
+ if (archive.badge.text === '投稿视频') {
376
+ if (forward) {
377
+ forwardInfo = '投稿了视频';
378
+ }
379
+ else {
380
+ pubTime = `${pubTime} · 投稿了视频`;
381
+ }
382
+ }
383
+ main += `
384
+ <div class="card-video">
385
+ <div class="video-cover">
386
+ <img src="${archive.cover}"
387
+ alt="">
388
+ <div class="cover-mask"></div>
389
+ <span>${archive.duration_text}</span>
390
+ </div>
391
+ <div class="video-info">
392
+ <div class="video-info-header">
393
+ <div class="video-title">
394
+ ${archive.title}
395
+ </div>
396
+ <div class="video-introduction">
397
+ ${archive.desc}
398
+ </div>
264
399
  </div>
265
- <div class="video-stat-item">
266
- <svg style="width: 16px; height: 16px;" xmlns="http://www.w3.org/2000/svg"
267
- xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 16 16" width="16"
268
- height="16">
269
- <path
270
- d="M8 3.3320333333333334C6.321186666666667 3.3320333333333334 4.855333333333333 3.4174399999999996 3.820593333333333 3.5013466666666666C3.1014733333333333 3.5596599999999996 2.5440733333333334 4.109013333333333 2.48 4.821693333333333C2.4040466666666664 5.666533333333334 2.333333333333333 6.780666666666666 2.333333333333333 7.998666666666666C2.333333333333333 9.216733333333334 2.4040466666666664 10.330866666666665 2.48 11.175699999999999C2.5440733333333334 11.888366666666666 3.1014733333333333 12.437733333333334 3.820593333333333 12.496066666666666C4.855333333333333 12.579933333333333 6.321186666666667 12.665333333333333 8 12.665333333333333C9.678999999999998 12.665333333333333 11.144933333333334 12.579933333333333 12.179733333333333 12.496033333333333C12.898733333333332 12.4377 13.456 11.888533333333331 13.520066666666667 11.176033333333333C13.595999999999998 10.331533333333333 13.666666666666666 9.217633333333332 13.666666666666666 7.998666666666666C13.666666666666666 6.779766666666667 13.595999999999998 5.665846666666667 13.520066666666667 4.821366666666666C13.456 4.108866666666666 12.898733333333332 3.55968 12.179733333333333 3.5013666666666663C11.144933333333334 3.417453333333333 9.678999999999998 3.3320333333333334 8 3.3320333333333334zM3.7397666666666667 2.50462C4.794879999999999 2.41906 6.288386666666666 2.3320333333333334 8 2.3320333333333334C9.7118 2.3320333333333334 11.2054 2.4190733333333334 12.260533333333331 2.5046399999999998C13.458733333333331 2.6018133333333333 14.407866666666665 3.5285199999999994 14.516066666666667 4.73182C14.593933333333332 5.597933333333334 14.666666666666666 6.7427 14.666666666666666 7.998666666666666C14.666666666666666 9.2547 14.593933333333332 10.399466666666665 14.516066666666667 11.2656C14.407866666666665 12.468866666666665 13.458733333333331 13.395566666666667 12.260533333333331 13.492766666666665C11.2054 13.578333333333333 9.7118 13.665333333333333 8 13.665333333333333C6.288386666666666 13.665333333333333 4.794879999999999 13.578333333333333 3.7397666666666667 13.492799999999999C2.541373333333333 13.395599999999998 1.5922066666666668 12.468633333333333 1.4840200000000001 11.265266666666665C1.4061199999999998 10.3988 1.3333333333333333 9.253866666666667 1.3333333333333333 7.998666666666666C1.3333333333333333 6.743533333333333 1.4061199999999998 5.598579999999999 1.4840200000000001 4.732153333333333C1.5922066666666668 3.5287466666666667 2.541373333333333 2.601793333333333 3.7397666666666667 2.50462z"
271
- fill="currentColor"></path>
272
- <path
273
- d="M10.583333333333332 7.166666666666666L6.583333333333333 7.166666666666666C6.307193333333332 7.166666666666666 6.083333333333333 6.942799999999999 6.083333333333333 6.666666666666666C6.083333333333333 6.390526666666666 6.307193333333332 6.166666666666666 6.583333333333333 6.166666666666666L10.583333333333332 6.166666666666666C10.859466666666666 6.166666666666666 11.083333333333332 6.390526666666666 11.083333333333332 6.666666666666666C11.083333333333332 6.942799999999999 10.859466666666666 7.166666666666666 10.583333333333332 7.166666666666666z"
274
- fill="currentColor"></path>
275
- <path
276
- d="M11.583333333333332 9.833333333333332L7.583333333333333 9.833333333333332C7.3072 9.833333333333332 7.083333333333333 9.609466666666666 7.083333333333333 9.333333333333332C7.083333333333333 9.0572 7.3072 8.833333333333332 7.583333333333333 8.833333333333332L11.583333333333332 8.833333333333332C11.859466666666666 8.833333333333332 12.083333333333332 9.0572 12.083333333333332 9.333333333333332C12.083333333333332 9.609466666666666 11.859466666666666 9.833333333333332 11.583333333333332 9.833333333333332z"
277
- fill="currentColor"></path>
278
- <path
279
- d="M5.25 6.666666666666666C5.25 6.942799999999999 5.02614 7.166666666666666 4.75 7.166666666666666L4.416666666666666 7.166666666666666C4.140526666666666 7.166666666666666 3.9166666666666665 6.942799999999999 3.9166666666666665 6.666666666666666C3.9166666666666665 6.390526666666666 4.140526666666666 6.166666666666666 4.416666666666666 6.166666666666666L4.75 6.166666666666666C5.02614 6.166666666666666 5.25 6.390526666666666 5.25 6.666666666666666z"
280
- fill="currentColor"></path>
281
- <path
282
- d="M6.25 9.333333333333332C6.25 9.609466666666666 6.02614 9.833333333333332 5.75 9.833333333333332L5.416666666666666 9.833333333333332C5.140526666666666 9.833333333333332 4.916666666666666 9.609466666666666 4.916666666666666 9.333333333333332C4.916666666666666 9.0572 5.140526666666666 8.833333333333332 5.416666666666666 8.833333333333332L5.75 8.833333333333332C6.02614 8.833333333333332 6.25 9.0572 6.25 9.333333333333332z"
283
- fill="currentColor"></path>
284
- </svg>
285
- <span>${archive.stat.danmaku}</span>
400
+ <div class="video-stat">
401
+ <div class="video-stat-item">
402
+ <svg style="width: 16px; height: 16px;" xmlns="http://www.w3.org/2000/svg"
403
+ xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 16 16" width="16"
404
+ height="16">
405
+ <path
406
+ d="M8 3.3320333333333334C6.321186666666667 3.3320333333333334 4.855333333333333 3.4174399999999996 3.820593333333333 3.5013466666666666C3.1014733333333333 3.5596599999999996 2.5440733333333334 4.109013333333333 2.48 4.821693333333333C2.4040466666666664 5.666533333333334 2.333333333333333 6.780666666666666 2.333333333333333 7.998666666666666C2.333333333333333 9.216733333333334 2.4040466666666664 10.330866666666665 2.48 11.175699999999999C2.5440733333333334 11.888366666666666 3.1014733333333333 12.437733333333334 3.820593333333333 12.496066666666666C4.855333333333333 12.579933333333333 6.321186666666667 12.665333333333333 8 12.665333333333333C9.678999999999998 12.665333333333333 11.144933333333334 12.579933333333333 12.179733333333333 12.496033333333333C12.898733333333332 12.4377 13.456 11.888533333333331 13.520066666666667 11.176033333333333C13.595999999999998 10.331533333333333 13.666666666666666 9.217633333333332 13.666666666666666 7.998666666666666C13.666666666666666 6.779766666666667 13.595999999999998 5.665846666666667 13.520066666666667 4.821366666666666C13.456 4.108866666666666 12.898733333333332 3.55968 12.179733333333333 3.5013666666666663C11.144933333333334 3.417453333333333 9.678999999999998 3.3320333333333334 8 3.3320333333333334zM3.7397666666666667 2.50462C4.794879999999999 2.41906 6.288386666666666 2.3320333333333334 8 2.3320333333333334C9.7118 2.3320333333333334 11.2054 2.4190733333333334 12.260533333333331 2.5046399999999998C13.458733333333331 2.6018133333333333 14.407866666666665 3.5285199999999994 14.516066666666667 4.73182C14.593933333333332 5.597933333333334 14.666666666666666 6.7427 14.666666666666666 7.998666666666666C14.666666666666666 9.2547 14.593933333333332 10.399466666666665 14.516066666666667 11.2656C14.407866666666665 12.468866666666665 13.458733333333331 13.395566666666667 12.260533333333331 13.492766666666665C11.2054 13.578333333333333 9.7118 13.665333333333333 8 13.665333333333333C6.288386666666666 13.665333333333333 4.794879999999999 13.578333333333333 3.7397666666666667 13.492799999999999C2.541373333333333 13.395599999999998 1.5922066666666668 12.468633333333333 1.4840200000000001 11.265266666666665C1.4061199999999998 10.3988 1.3333333333333333 9.253866666666667 1.3333333333333333 7.998666666666666C1.3333333333333333 6.743533333333333 1.4061199999999998 5.598579999999999 1.4840200000000001 4.732153333333333C1.5922066666666668 3.5287466666666667 2.541373333333333 2.601793333333333 3.7397666666666667 2.50462z"
407
+ fill="currentColor"></path>
408
+ <path
409
+ d="M9.8092 7.3125C10.338433333333333 7.618066666666666 10.338433333333333 8.382 9.809166666666666 8.687533333333333L7.690799999999999 9.910599999999999C7.161566666666666 10.216133333333332 6.5 9.8342 6.500006666666666 9.223066666666666L6.500006666666666 6.776999999999999C6.500006666666666 6.165873333333334 7.161566666666666 5.783913333333333 7.690799999999999 6.089479999999999L9.8092 7.3125z"
410
+ fill="currentColor"></path>
411
+ </svg>
412
+ <span>${archive.stat.play}</span>
413
+ </div>
414
+ <div class="video-stat-item">
415
+ <svg style="width: 16px; height: 16px;" xmlns="http://www.w3.org/2000/svg"
416
+ xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 16 16" width="16"
417
+ height="16">
418
+ <path
419
+ d="M8 3.3320333333333334C6.321186666666667 3.3320333333333334 4.855333333333333 3.4174399999999996 3.820593333333333 3.5013466666666666C3.1014733333333333 3.5596599999999996 2.5440733333333334 4.109013333333333 2.48 4.821693333333333C2.4040466666666664 5.666533333333334 2.333333333333333 6.780666666666666 2.333333333333333 7.998666666666666C2.333333333333333 9.216733333333334 2.4040466666666664 10.330866666666665 2.48 11.175699999999999C2.5440733333333334 11.888366666666666 3.1014733333333333 12.437733333333334 3.820593333333333 12.496066666666666C4.855333333333333 12.579933333333333 6.321186666666667 12.665333333333333 8 12.665333333333333C9.678999999999998 12.665333333333333 11.144933333333334 12.579933333333333 12.179733333333333 12.496033333333333C12.898733333333332 12.4377 13.456 11.888533333333331 13.520066666666667 11.176033333333333C13.595999999999998 10.331533333333333 13.666666666666666 9.217633333333332 13.666666666666666 7.998666666666666C13.666666666666666 6.779766666666667 13.595999999999998 5.665846666666667 13.520066666666667 4.821366666666666C13.456 4.108866666666666 12.898733333333332 3.55968 12.179733333333333 3.5013666666666663C11.144933333333334 3.417453333333333 9.678999999999998 3.3320333333333334 8 3.3320333333333334zM3.7397666666666667 2.50462C4.794879999999999 2.41906 6.288386666666666 2.3320333333333334 8 2.3320333333333334C9.7118 2.3320333333333334 11.2054 2.4190733333333334 12.260533333333331 2.5046399999999998C13.458733333333331 2.6018133333333333 14.407866666666665 3.5285199999999994 14.516066666666667 4.73182C14.593933333333332 5.597933333333334 14.666666666666666 6.7427 14.666666666666666 7.998666666666666C14.666666666666666 9.2547 14.593933333333332 10.399466666666665 14.516066666666667 11.2656C14.407866666666665 12.468866666666665 13.458733333333331 13.395566666666667 12.260533333333331 13.492766666666665C11.2054 13.578333333333333 9.7118 13.665333333333333 8 13.665333333333333C6.288386666666666 13.665333333333333 4.794879999999999 13.578333333333333 3.7397666666666667 13.492799999999999C2.541373333333333 13.395599999999998 1.5922066666666668 12.468633333333333 1.4840200000000001 11.265266666666665C1.4061199999999998 10.3988 1.3333333333333333 9.253866666666667 1.3333333333333333 7.998666666666666C1.3333333333333333 6.743533333333333 1.4061199999999998 5.598579999999999 1.4840200000000001 4.732153333333333C1.5922066666666668 3.5287466666666667 2.541373333333333 2.601793333333333 3.7397666666666667 2.50462z"
420
+ fill="currentColor"></path>
421
+ <path
422
+ d="M10.583333333333332 7.166666666666666L6.583333333333333 7.166666666666666C6.307193333333332 7.166666666666666 6.083333333333333 6.942799999999999 6.083333333333333 6.666666666666666C6.083333333333333 6.390526666666666 6.307193333333332 6.166666666666666 6.583333333333333 6.166666666666666L10.583333333333332 6.166666666666666C10.859466666666666 6.166666666666666 11.083333333333332 6.390526666666666 11.083333333333332 6.666666666666666C11.083333333333332 6.942799999999999 10.859466666666666 7.166666666666666 10.583333333333332 7.166666666666666z"
423
+ fill="currentColor"></path>
424
+ <path
425
+ d="M11.583333333333332 9.833333333333332L7.583333333333333 9.833333333333332C7.3072 9.833333333333332 7.083333333333333 9.609466666666666 7.083333333333333 9.333333333333332C7.083333333333333 9.0572 7.3072 8.833333333333332 7.583333333333333 8.833333333333332L11.583333333333332 8.833333333333332C11.859466666666666 8.833333333333332 12.083333333333332 9.0572 12.083333333333332 9.333333333333332C12.083333333333332 9.609466666666666 11.859466666666666 9.833333333333332 11.583333333333332 9.833333333333332z"
426
+ fill="currentColor"></path>
427
+ <path
428
+ d="M5.25 6.666666666666666C5.25 6.942799999999999 5.02614 7.166666666666666 4.75 7.166666666666666L4.416666666666666 7.166666666666666C4.140526666666666 7.166666666666666 3.9166666666666665 6.942799999999999 3.9166666666666665 6.666666666666666C3.9166666666666665 6.390526666666666 4.140526666666666 6.166666666666666 4.416666666666666 6.166666666666666L4.75 6.166666666666666C5.02614 6.166666666666666 5.25 6.390526666666666 5.25 6.666666666666666z"
429
+ fill="currentColor"></path>
430
+ <path
431
+ d="M6.25 9.333333333333332C6.25 9.609466666666666 6.02614 9.833333333333332 5.75 9.833333333333332L5.416666666666666 9.833333333333332C5.140526666666666 9.833333333333332 4.916666666666666 9.609466666666666 4.916666666666666 9.333333333333332C4.916666666666666 9.0572 5.140526666666666 8.833333333333332 5.416666666666666 8.833333333333332L5.75 8.833333333333332C6.02614 8.833333333333332 6.25 9.0572 6.25 9.333333333333332z"
432
+ fill="currentColor"></path>
433
+ </svg>
434
+ <span>${archive.stat.danmaku}</span>
435
+ </div>
286
436
  </div>
287
437
  </div>
288
438
  </div>
289
- </div>
290
- `;
291
- link = `请将$替换为. www$bilibili$com/video/${archive.bvid}`;
292
- break;
293
- }
294
- case DYNAMIC_TYPE_FORWARD: return [`${upName}转发了一条动态,我暂时无法渲染,请自行查看`, link];
295
- case DYNAMIC_TYPE_LIVE: return [`${upName}发起了直播预约,我暂时无法渲染,请自行查看`, link];
296
- case DYNAMIC_TYPE_MEDIALIST: return [`${upName}分享了收藏夹,我暂时无法渲染,请自行查看`, link];
297
- case DYNAMIC_TYPE_PGC: return [`${upName}发布了剧集(番剧、电影、纪录片),我暂时无法渲染,请自行查看`, link];
298
- case DYNAMIC_TYPE_ARTICLE: return [`${upName}投稿了新专栏,我暂时无法渲染,请自行查看`, link];
299
- case DYNAMIC_TYPE_MUSIC: return [`${upName}发行了新歌,我暂时无法渲染,请自行查看`, link];
300
- case DYNAMIC_TYPE_COMMON_SQUARE: return [`${upName}发布了装扮|剧集|点评|普通分享,我暂时无法渲染,请自行查看`, link];
301
- case DYNAMIC_TYPE_COURSES_SEASON: return [`${upName}发布了新课程,我暂时无法渲染,请自行查看`, link];
302
- case DYNAMIC_TYPE_UGC_SEASON: return [`${upName}更新了合集,我暂时无法渲染,请自行查看`, link];
303
- case DYNAMIC_TYPE_NONE: return [`${upName}发布了一条无效动态`, link];
304
- // 直播开播,不做处理
305
- case DYNAMIC_TYPE_LIVE_RCMD: return ['', ''];
306
- case DYNAMIC_TYPE_SUBSCRIPTION_NEW:
307
- case DYNAMIC_TYPE_BANNER:
308
- case DYNAMIC_TYPE_SUBSCRIPTION:
309
- case DYNAMIC_TYPE_APPLET:
310
- case DYNAMIC_TYPE_AD:
311
- case DYNAMIC_TYPE_COURSES_BATCH:
312
- case DYNAMIC_TYPE_COURSES:
313
- case DYNAMIC_TYPE_COMMON_VERTICAL:
314
- default: `${upName}发布了一条我无法识别的动态,请自行查看`;
439
+ `;
440
+ link = `请将$替换为. www$bilibili$com/video/${archive.bvid}`;
441
+ break;
442
+ }
443
+ case DYNAMIC_TYPE_LIVE: return [`${upName}发起了直播预约,我暂时无法渲染,请自行查看`, link];
444
+ case DYNAMIC_TYPE_MEDIALIST: return [`${upName}分享了收藏夹,我暂时无法渲染,请自行查看`, link];
445
+ case DYNAMIC_TYPE_PGC: return [`${upName}发布了剧集(番剧、电影、纪录片),我暂时无法渲染,请自行查看`, link];
446
+ case DYNAMIC_TYPE_ARTICLE: return [`${upName}投稿了新专栏,我暂时无法渲染,请自行查看`, link];
447
+ case DYNAMIC_TYPE_MUSIC: return [`${upName}发行了新歌,我暂时无法渲染,请自行查看`, link];
448
+ case DYNAMIC_TYPE_COMMON_SQUARE: return [`${upName}发布了装扮|剧集|点评|普通分享,我暂时无法渲染,请自行查看`, link];
449
+ case DYNAMIC_TYPE_COURSES_SEASON: return [`${upName}发布了新课程,我暂时无法渲染,请自行查看`, link];
450
+ case DYNAMIC_TYPE_UGC_SEASON: return [`${upName}更新了合集,我暂时无法渲染,请自行查看`, link];
451
+ case DYNAMIC_TYPE_NONE: return [`${upName}发布了一条无效动态`, link];
452
+ // 直播开播,不做处理
453
+ case DYNAMIC_TYPE_LIVE_RCMD: return ['', ''];
454
+ case DYNAMIC_TYPE_SUBSCRIPTION_NEW:
455
+ case DYNAMIC_TYPE_BANNER:
456
+ case DYNAMIC_TYPE_SUBSCRIPTION:
457
+ case DYNAMIC_TYPE_APPLET:
458
+ case DYNAMIC_TYPE_AD:
459
+ case DYNAMIC_TYPE_COURSES_BATCH:
460
+ case DYNAMIC_TYPE_COURSES:
461
+ case DYNAMIC_TYPE_COMMON_VERTICAL:
462
+ default: return [`${upName}发布了一条我无法识别的动态,请自行查看`, ''];
463
+ }
464
+ return [main, link, forwardInfo];
315
465
  }
466
+ const [main, link] = await getDynamicMajor(data, false);
316
467
  const pic = await this.ctx.puppeteer.render(`
317
468
  <!DOCTYPE html>
318
469
  <html>
@@ -334,7 +485,7 @@ class GenerateImg extends koishi_1.Service {
334
485
  .background {
335
486
  width: 770px;
336
487
  height: auto;
337
- background: linear-gradient(to right bottom, ${this.config.pushCardColorStart}, ${this.config.pushCardColorEnd});
488
+ background: linear-gradient(to right bottom, ${this.config.cardColorStart}, ${this.config.cardColorEnd});
338
489
  overflow: hidden;
339
490
  }
340
491
 
@@ -451,11 +602,19 @@ class GenerateImg extends koishi_1.Service {
451
602
  }
452
603
 
453
604
  .card .card-major .single-photo-item {
454
- max-width: 280px;
455
- max-height: 280px
605
+ max-width: 500px;
456
606
  border-radius: 10px;
457
607
  overflow: hidden;
458
608
  }
609
+
610
+ .card .card-major .four-photo-item {
611
+ width: 170px;
612
+ height: 170px;
613
+ object-fit: cover;
614
+ border-radius: 10px;
615
+ overflow: hidden;
616
+ flex-basis: 20%; /* or any value less than 50% */
617
+ }
459
618
 
460
619
  .card .card-stat {
461
620
  display: flex;
@@ -476,6 +635,7 @@ class GenerateImg extends koishi_1.Service {
476
635
  display: flex;
477
636
  overflow: hidden;
478
637
  border-radius: 5px 0 0 5px;
638
+ margin-top: 10px;
479
639
  height: 132px;
480
640
  }
481
641
 
@@ -515,6 +675,7 @@ class GenerateImg extends koishi_1.Service {
515
675
  border-left: none;
516
676
  border-radius: 0 5px 5px 0;
517
677
  padding: 12px 16px 10px;
678
+ background-color: #fff;
518
679
  }
519
680
 
520
681
  .card .video-info-header .video-title {
@@ -547,6 +708,87 @@ class GenerateImg extends koishi_1.Service {
547
708
  align-items: center;
548
709
  gap: 3px;
549
710
  }
711
+
712
+ .card .card-forward {
713
+ margin: 0 -15px 0 -85px;
714
+ padding: 12px 15px 14px 85px;
715
+ background-color: #F6F7F8;
716
+ }
717
+
718
+ .card-forward .forward-userinfo {
719
+ display: flex;
720
+ align-items: center;
721
+ gap: 5px;
722
+ height: 30px;
723
+ }
724
+
725
+ .forward-userinfo img {
726
+ width: 20px;
727
+ height: 20px;
728
+ border-radius: 50%;
729
+ }
730
+
731
+ .forward-userinfo span {
732
+ color: #61666D;
733
+ font-size: 15px;
734
+ }
735
+
736
+ .card .card-reserve {
737
+ display: flex;
738
+ justify-content: space-between;
739
+ align-items: center;
740
+ padding: 10px 20px 10px 20px;
741
+ margin-top: 10px;
742
+ border-radius: 10px;
743
+ background-color: #F6F7F8;
744
+ }
745
+
746
+ .card-reserve .reserve-title {
747
+ font-size: 14px;
748
+ color: #18191C;
749
+ }
750
+
751
+ .card-reserve .reserve-desc {
752
+ margin-top: 7px;
753
+ font-size: 12px;
754
+ color: #9499A0;
755
+ }
756
+
757
+ .reserve-info .reserve-time {
758
+ margin-right: 7px;
759
+ }
760
+
761
+ .card-reserve .reserve-prize {
762
+ display: flex;
763
+ align-items: center;
764
+ margin-top: 3px;
765
+ gap: 3px;
766
+ color: #00AEEC;
767
+ }
768
+
769
+ .card .card-reserve .reserve-button button {
770
+ border: none;
771
+ height: 30px;
772
+ width: 72px;
773
+ font-size: 13px;
774
+ border-radius: 7px;
775
+ }
776
+
777
+ .card .card-reserve .reserve-button .reserve-button-end {
778
+ display: flex;
779
+ align-items: center;
780
+ justify-content: center;
781
+ color: #9499A0;
782
+ background-color: #E3E5E7;
783
+ }
784
+
785
+ .card .card-reserve .reserve-button .reserve-button-ing {
786
+ display: flex;
787
+ align-items: center;
788
+ justify-content: center;
789
+ color: #FFF;
790
+ background-color: #00A0D8;
791
+ }
550
792
  </style>
551
793
  </head>
552
794
 
@@ -657,27 +899,25 @@ class GenerateImg extends koishi_1.Service {
657
899
  // 获取Unix时间戳(以毫秒为单位)
658
900
  const unixTime = date.getTime();
659
901
  // 获取当前Unix时间戳
660
- this.ctx.biliAPI.getTimeNow().then(content => {
661
- const now = content.now;
662
- // 计算时间差(以秒为单位)
663
- const differenceInSeconds = Math.floor((now - unixTime) / 1000);
664
- // 获取yyyy:MM:dd HH:mm:ss
665
- const days = Math.floor(differenceInSeconds / (24 * 60 * 60));
666
- const hours = Math.floor((differenceInSeconds % (24 * 60 * 60)) / (60 * 60));
667
- const minutes = Math.floor((differenceInSeconds % (60 * 60)) / 60);
668
- const seconds = differenceInSeconds % 60;
669
- // 返回格式化的字符串
670
- return days ?
671
- `${days} 天 ${hours}小时${minutes.toString().padStart(2, '0')}分钟${seconds.toString().padStart(2, '0')}秒` :
672
- `${hours}小时${minutes.toString().padStart(2, '0')}分钟${seconds.toString().padStart(2, '0')}秒`;
673
- });
902
+ const now = Date.now();
903
+ // 计算时间差(以秒为单位)
904
+ const differenceInSeconds = Math.floor((now - unixTime) / 1000);
905
+ // 获取yyyy:MM:dd HH:mm:ss
906
+ const days = Math.floor(differenceInSeconds / (24 * 60 * 60));
907
+ const hours = Math.floor((differenceInSeconds % (24 * 60 * 60)) / (60 * 60));
908
+ const minutes = Math.floor((differenceInSeconds % (60 * 60)) / 60);
909
+ const seconds = differenceInSeconds % 60;
910
+ // 返回格式化的字符串
911
+ return days ?
912
+ `${days} 天 ${hours}小时${minutes.toString().padStart(2, '0')}分钟${seconds.toString().padStart(2, '0')}秒` :
913
+ `${hours}小时${minutes.toString().padStart(2, '0')}分钟${seconds.toString().padStart(2, '0')}秒`;
674
914
  }
675
915
  unixTimestampToString(timestamp) {
676
916
  const date = new Date(timestamp * 1000);
677
917
  const year = date.getFullYear();
678
918
  const month = ("0" + (date.getMonth() + 1)).slice(-2);
679
919
  const day = ("0" + date.getDate()).slice(-2);
680
- const hours = ("0" + date.getHours()).slice(-2);
920
+ const hours = ("0" + (date.getHours())).slice(-2);
681
921
  const minutes = ("0" + date.getMinutes()).slice(-2);
682
922
  const seconds = ("0" + date.getSeconds()).slice(-2);
683
923
  return `${year}年${month}月${day}日 ${hours}:${minutes}:${seconds}`;
@@ -685,11 +925,11 @@ class GenerateImg extends koishi_1.Service {
685
925
  }
686
926
  (function (GenerateImg) {
687
927
  GenerateImg.Config = koishi_1.Schema.object({
688
- pushCardColorStart: koishi_1.Schema.string()
928
+ cardColorStart: koishi_1.Schema.string()
689
929
  .pattern(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/)
690
930
  .default('#F38AB5')
691
931
  .description('推送卡片的开始渐变背景色,请填入16进制颜色代码,参考网站:https://webkul.github.io/coolhue/'),
692
- pushCardColorEnd: koishi_1.Schema.string()
932
+ cardColorEnd: koishi_1.Schema.string()
693
933
  .pattern(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/)
694
934
  .default('#F9CCDF')
695
935
  .description('推送卡片的结束渐变背景色,请填入16进制颜色代码,参考网站:https://colorate.azurewebsites.net/')
package/lib/index.d.ts CHANGED
@@ -2,8 +2,9 @@ import { Context, Schema } from 'koishi';
2
2
  export declare const name = "bilibili-notify";
3
3
  export interface Config {
4
4
  pushTime: number;
5
- pushCardColorStart: string;
6
- pushCardColorEnd: string;
5
+ cardColorStart: string;
6
+ cardColorEnd: string;
7
+ key: string;
7
8
  }
8
9
  export declare const Config: Schema<Config>;
9
10
  export declare function apply(ctx: Context, config: Config): void;
package/lib/index.js CHANGED
@@ -45,22 +45,27 @@ exports.Config = koishi_1.Schema.object({
45
45
  .step(1)
46
46
  .role('slider')
47
47
  .default(1)
48
- .description('设定隔多长时间推送一次直播状态,单位为半小时'),
49
- pushCardColorStart: koishi_1.Schema.string()
48
+ .description('设定隔多长时间推送一次直播状态,单位为半小时,默认为半小时'),
49
+ cardColorStart: koishi_1.Schema.string()
50
50
  .pattern(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/)
51
51
  .default('#F38AB5')
52
52
  .description('推送卡片的开始渐变背景色,请填入16进制颜色代码,参考网站:https://webkul.github.io/coolhue/'),
53
- pushCardColorEnd: koishi_1.Schema.string()
53
+ cardColorEnd: koishi_1.Schema.string()
54
54
  .pattern(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/)
55
55
  .default('#F9CCDF')
56
- .description('推送卡片的结束渐变背景色,请填入16进制颜色代码,参考网站:https://colorate.azurewebsites.net/')
56
+ .description('推送卡片的结束渐变背景色,请填入16进制颜色代码,参考网站:https://colorate.azurewebsites.net/'),
57
+ key: koishi_1.Schema.string()
58
+ .pattern(/^[0-9a-f]{32}$/)
59
+ .role('secret')
60
+ .required()
61
+ .description('请输入一个32位小写字母的十六进制密钥(例如:9b8db7ae562b9864efefe06289cc5530),使用此密钥将你的B站登录信息存储在数据库中,请一定保存好此密钥。如果你忘记了此密钥,必须重新登录。你可以自行生成,或到这个网站生成:https://www.sexauth.com/')
57
62
  });
58
63
  function apply(ctx, config) {
59
64
  // load database
60
65
  ctx.plugin(Database);
61
66
  // Regist server
62
- ctx.plugin(wbi_1.default);
63
- ctx.plugin(generateImg_1.default, { pushCardColorStart: config.pushCardColorStart, pushCardColorEnd: config.pushCardColorEnd });
67
+ ctx.plugin(wbi_1.default, { key: config.key });
68
+ ctx.plugin(generateImg_1.default, { cardColorStart: config.cardColorStart, cardColorEnd: config.cardColorEnd });
64
69
  ctx.plugin(biliAPI_1.default);
65
70
  // load plugin
66
71
  ctx.plugin(comRegister_1.default, { pushTime: config.pushTime });
package/lib/wbi.d.ts CHANGED
@@ -1,13 +1,13 @@
1
- import { Context, Service } from "koishi";
1
+ import { Context, Schema, Service } from "koishi";
2
2
  declare module 'koishi' {
3
3
  interface Context {
4
4
  wbi: Wbi;
5
5
  }
6
6
  }
7
7
  declare class Wbi extends Service {
8
- key: string;
8
+ config: Wbi.Config;
9
9
  mixinKeyEncTab: number[];
10
- constructor(ctx: Context);
10
+ constructor(ctx: Context, config: Wbi.Config);
11
11
  protected start(): void | Promise<void>;
12
12
  getMixinKey: (orig: any) => string;
13
13
  encWbi(params: any, img_key: any, sub_key: any): string;
@@ -19,4 +19,10 @@ declare class Wbi extends Service {
19
19
  encrypt(text: string, secretKey?: string): string;
20
20
  decrypt(text: string, secretKey?: string): string;
21
21
  }
22
+ declare namespace Wbi {
23
+ interface Config {
24
+ key: string;
25
+ }
26
+ const Config: Schema<Config>;
27
+ }
22
28
  export default Wbi;
package/lib/wbi.js CHANGED
@@ -7,15 +7,16 @@ const koishi_1 = require("koishi");
7
7
  const md5_1 = __importDefault(require("md5"));
8
8
  const crypto_1 = __importDefault(require("crypto"));
9
9
  class Wbi extends koishi_1.Service {
10
- key = '36e9cdb0934c27949003b3644b593e42';
10
+ config;
11
11
  mixinKeyEncTab = [
12
12
  46, 47, 18, 2, 53, 8, 23, 32, 15, 50, 10, 31, 58, 3, 45, 35, 27, 43, 5, 49,
13
13
  33, 9, 42, 19, 29, 28, 14, 39, 12, 38, 41, 13, 37, 48, 7, 16, 24, 55, 40,
14
14
  61, 26, 17, 0, 1, 60, 51, 30, 4, 22, 25, 54, 21, 56, 59, 6, 63, 57, 62, 11,
15
15
  36, 20, 34, 44, 52
16
16
  ];
17
- constructor(ctx) {
17
+ constructor(ctx, config) {
18
18
  super(ctx, 'wbi');
19
+ this.config = config;
19
20
  }
20
21
  start() {
21
22
  this.logger.info('wbi已被注册到Context中');
@@ -61,7 +62,7 @@ class Wbi extends koishi_1.Service {
61
62
  }
62
63
  encrypt(text, secretKey) {
63
64
  const iv = crypto_1.default.randomBytes(16);
64
- const cipher = crypto_1.default.createCipheriv('aes-256-cbc', Buffer.from(this.key), iv);
65
+ const cipher = crypto_1.default.createCipheriv('aes-256-cbc', Buffer.from(this.config.key), iv);
65
66
  const encrypted = Buffer.concat([cipher.update(text), cipher.final()]);
66
67
  return iv.toString('hex') + ':' + encrypted.toString('hex');
67
68
  }
@@ -69,9 +70,16 @@ class Wbi extends koishi_1.Service {
69
70
  let textParts = text.split(':');
70
71
  let iv = Buffer.from(textParts.shift(), 'hex');
71
72
  let encryptedText = Buffer.from(textParts.join(':'), 'hex');
72
- let decipher = crypto_1.default.createDecipheriv('aes-256-cbc', Buffer.from(this.key), iv);
73
+ let decipher = crypto_1.default.createDecipheriv('aes-256-cbc', Buffer.from(this.config.key), iv);
73
74
  let decrypted = Buffer.concat([decipher.update(encryptedText), decipher.final()]);
74
75
  return decrypted.toString();
75
76
  }
76
77
  }
78
+ (function (Wbi) {
79
+ Wbi.Config = koishi_1.Schema.object({
80
+ key: koishi_1.Schema.string()
81
+ .pattern(/^[0-9a-f]{32}$/)
82
+ .required()
83
+ });
84
+ })(Wbi || (Wbi = {}));
77
85
  exports.default = Wbi;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-bilibili-notify",
3
3
  "description": "Koishi bilibili notify plugin",
4
- "version": "0.0.1",
4
+ "version": "0.1.1",
5
5
  "contributors": [
6
6
  "Akokko <admin@akokko.com>"
7
7
  ],