koishi-plugin-bilibili-notify 3.2.0-alpha.7 → 3.2.1-alpha.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/database.js CHANGED
@@ -1,9 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.name = void 0;
4
- exports.apply = apply;
5
- exports.name = "Database";
6
- function apply(ctx) {
1
+ export const name = "Database";
2
+ export function apply(ctx) {
7
3
  // 新增LoginBili表
8
4
  ctx.model.extend("loginBili", {
9
5
  id: "unsigned",
@@ -1,10 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const koishi_1 = require("koishi");
4
- const luxon_1 = require("luxon");
5
- const node_path_1 = require("node:path");
6
- const node_url_1 = require("node:url");
7
- const utils_1 = require("./utils");
1
+ import { Schema, Service } from "koishi";
2
+ import { DateTime } from "luxon";
3
+ import { resolve } from "node:path";
4
+ import { pathToFileURL } from "node:url";
5
+ import { withRetry } from "./utils";
8
6
  // 动态类型
9
7
  const DYNAMIC_TYPE_NONE = "DYNAMIC_TYPE_NONE";
10
8
  const DYNAMIC_TYPE_FORWARD = "DYNAMIC_TYPE_FORWARD";
@@ -22,7 +20,7 @@ const DYNAMIC_TYPE_LIVE_RCMD = "DYNAMIC_TYPE_LIVE_RCMD";
22
20
  const DYNAMIC_TYPE_UGC_SEASON = "DYNAMIC_TYPE_UGC_SEASON";
23
21
  // 内容卡片类型
24
22
  const ADDITIONAL_TYPE_RESERVE = "ADDITIONAL_TYPE_RESERVE";
25
- class GenerateImg extends koishi_1.Service {
23
+ class GenerateImg extends Service {
26
24
  static inject = ["puppeteer", "ba"];
27
25
  giConfig;
28
26
  constructor(ctx, config) {
@@ -54,7 +52,7 @@ class GenerateImg extends koishi_1.Service {
54
52
  data, username, userface, followerDisplay, liveStatus /*0未开播 1刚开播 2已开播 3停止直播*/, { cardColorStart = this.giConfig.cardColorStart, cardColorEnd = this.giConfig.cardColorEnd, cardBasePlateColor = this.giConfig.cardBasePlateColor, cardBasePlateBorder = this.giConfig.cardBasePlateBorder, } = {}) {
55
53
  const [titleStatus, liveTime, cover] = await this.getLiveStatus(data.live_time, liveStatus);
56
54
  // 加载字体
57
- const fontURL = (0, node_url_1.pathToFileURL)((0, node_path_1.resolve)(__dirname, "font/HYZhengYuan-75W.ttf"));
55
+ const fontURL = pathToFileURL(resolve(__dirname, "font/HYZhengYuan-75W.ttf"));
58
56
  // 卡片内容
59
57
  const html = /* html */ `
60
58
  <!DOCTYPE html>
@@ -209,7 +207,7 @@ class GenerateImg extends koishi_1.Service {
209
207
  </html>
210
208
  `;
211
209
  // 多次尝试生成图片
212
- return await (0, utils_1.withRetry)(() => this.imgHandler(html)).catch((e) => {
210
+ return await withRetry(() => this.imgHandler(html)).catch((e) => {
213
211
  // 已尝试三次
214
212
  throw new Error(`生成图片失败!错误: ${e.toString()}`);
215
213
  });
@@ -290,7 +288,7 @@ class GenerateImg extends koishi_1.Service {
290
288
  }
291
289
  // 图片
292
290
  let major = "";
293
- const arrowImg = (0, node_url_1.pathToFileURL)((0, node_path_1.resolve)(__dirname, "img/arrow.png"));
291
+ const arrowImg = pathToFileURL(resolve(__dirname, "img/arrow.png"));
294
292
  if (module_dynamic?.major?.opus?.pics) {
295
293
  if (module_dynamic.major.opus.pics.length === 1) {
296
294
  const height = module_dynamic.major.opus.pics[0].height;
@@ -566,7 +564,7 @@ class GenerateImg extends koishi_1.Service {
566
564
  // 获取动态主要内容
567
565
  const [main] = await getDynamicMajor(data, false);
568
566
  // 加载字体
569
- const fontURL = (0, node_url_1.pathToFileURL)((0, node_path_1.resolve)(__dirname, "font/HYZhengYuan-75W.ttf"));
567
+ const fontURL = pathToFileURL(resolve(__dirname, "font/HYZhengYuan-75W.ttf"));
570
568
  // 判断是否开启大字体模式
571
569
  let style;
572
570
  if (this.giConfig.enableLargeFont) {
@@ -1397,7 +1395,7 @@ class GenerateImg extends koishi_1.Service {
1397
1395
  </html>
1398
1396
  `;
1399
1397
  // 多次尝试生成图片
1400
- return await (0, utils_1.withRetry)(() => this.imgHandler(html)).catch((e) => {
1398
+ return await withRetry(() => this.imgHandler(html)).catch((e) => {
1401
1399
  // 已尝试三次
1402
1400
  throw new Error(`生成图片失败!错误: ${e.toString()}`);
1403
1401
  });
@@ -1436,11 +1434,11 @@ class GenerateImg extends koishi_1.Service {
1436
1434
  }
1437
1435
  async getTimeDifference(dateString) {
1438
1436
  // 将日期字符串转换为Date对象
1439
- const apiDateTime = luxon_1.DateTime.fromFormat(dateString, "yyyy-MM-dd HH:mm:ss", {
1437
+ const apiDateTime = DateTime.fromFormat(dateString, "yyyy-MM-dd HH:mm:ss", {
1440
1438
  zone: "UTC+8",
1441
1439
  });
1442
1440
  // 获取当前时间
1443
- const currentDateTime = luxon_1.DateTime.now();
1441
+ const currentDateTime = DateTime.now();
1444
1442
  // 计算时间差
1445
1443
  const diff = currentDateTime.diff(apiDateTime, [
1446
1444
  "years",
@@ -1482,24 +1480,24 @@ class GenerateImg extends koishi_1.Service {
1482
1480
  }
1483
1481
  }
1484
1482
  (function (GenerateImg) {
1485
- GenerateImg.Config = koishi_1.Schema.object({
1486
- filter: koishi_1.Schema.object({
1487
- enable: koishi_1.Schema.boolean(),
1488
- notify: koishi_1.Schema.boolean(),
1489
- regex: koishi_1.Schema.string(),
1490
- keywords: koishi_1.Schema.array(String),
1491
- forward: koishi_1.Schema.boolean(),
1492
- article: koishi_1.Schema.boolean(),
1483
+ GenerateImg.Config = Schema.object({
1484
+ filter: Schema.object({
1485
+ enable: Schema.boolean(),
1486
+ notify: Schema.boolean(),
1487
+ regex: Schema.string(),
1488
+ keywords: Schema.array(String),
1489
+ forward: Schema.boolean(),
1490
+ article: Schema.boolean(),
1493
1491
  }),
1494
- removeBorder: koishi_1.Schema.boolean(),
1495
- cardColorStart: koishi_1.Schema.string(),
1496
- cardColorEnd: koishi_1.Schema.string(),
1497
- cardBasePlateColor: koishi_1.Schema.string(),
1498
- cardBasePlateBorder: koishi_1.Schema.string(),
1499
- enableLargeFont: koishi_1.Schema.boolean(),
1500
- font: koishi_1.Schema.string(),
1501
- hideDesc: koishi_1.Schema.boolean(),
1502
- followerDisplay: koishi_1.Schema.boolean(),
1492
+ removeBorder: Schema.boolean(),
1493
+ cardColorStart: Schema.string(),
1494
+ cardColorEnd: Schema.string(),
1495
+ cardBasePlateColor: Schema.string(),
1496
+ cardBasePlateBorder: Schema.string(),
1497
+ enableLargeFont: Schema.boolean(),
1498
+ font: Schema.string(),
1499
+ hideDesc: Schema.boolean(),
1500
+ followerDisplay: Schema.boolean(),
1503
1501
  });
1504
1502
  })(GenerateImg || (GenerateImg = {}));
1505
- exports.default = GenerateImg;
1503
+ export default GenerateImg;
package/lib/index.d.ts CHANGED
@@ -35,6 +35,7 @@ export interface Config {
35
35
  live: boolean;
36
36
  liveGuardBuy: boolean;
37
37
  atAll: boolean;
38
+ bot: string;
38
39
  }>;
39
40
  platform: string;
40
41
  }>;
package/lib/index.js CHANGED
@@ -1,55 +1,15 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- var __importDefault = (this && this.__importDefault) || function (mod) {
36
- return (mod && mod.__esModule) ? mod : { "default": mod };
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.Config = exports.name = exports.inject = void 0;
40
- exports.apply = apply;
41
- const koishi_1 = require("koishi");
1
+ import { Schema, Service } from "koishi";
42
2
  // import plugins
43
- const comRegister_1 = __importDefault(require("./comRegister"));
44
- const Database = __importStar(require("./database"));
3
+ import ComRegister from "./comRegister";
4
+ import * as Database from "./database";
45
5
  // import Service
46
- const generateImg_1 = __importDefault(require("./generateImg"));
47
- const biliAPI_1 = __importDefault(require("./biliAPI"));
48
- const blive_1 = __importDefault(require("./blive"));
49
- exports.inject = ["puppeteer", "database", "notifier"];
50
- exports.name = "bilibili-notify";
6
+ import GenerateImg from "./generateImg";
7
+ import BiliAPI from "./biliAPI";
8
+ import BLive from "./blive";
9
+ export const inject = ["puppeteer", "database", "notifier"];
10
+ export const name = "bilibili-notify";
51
11
  let globalConfig;
52
- class ServerManager extends koishi_1.Service {
12
+ class ServerManager extends Service {
53
13
  // 服务
54
14
  servers = [];
55
15
  constructor(ctx) {
@@ -105,12 +65,12 @@ class ServerManager extends koishi_1.Service {
105
65
  // 注册插件
106
66
  try {
107
67
  // BA = BiliAPI
108
- const ba = this.ctx.plugin(biliAPI_1.default, {
68
+ const ba = this.ctx.plugin(BiliAPI, {
109
69
  userAgent: globalConfig.userAgent,
110
70
  key: globalConfig.key,
111
71
  });
112
72
  // GI = GenerateImg
113
- const gi = this.ctx.plugin(generateImg_1.default, {
73
+ const gi = this.ctx.plugin(GenerateImg, {
114
74
  filter: globalConfig.filter,
115
75
  removeBorder: globalConfig.removeBorder,
116
76
  cardColorStart: globalConfig.cardColorStart,
@@ -123,7 +83,7 @@ class ServerManager extends koishi_1.Service {
123
83
  followerDisplay: globalConfig.followerDisplay,
124
84
  });
125
85
  // CR = ComRegister
126
- const cr = this.ctx.plugin(comRegister_1.default, {
86
+ const cr = this.ctx.plugin(ComRegister, {
127
87
  sub: globalConfig.sub,
128
88
  master: globalConfig.master,
129
89
  liveDetectType: globalConfig.liveDetectType,
@@ -138,7 +98,7 @@ class ServerManager extends koishi_1.Service {
138
98
  dynamicDebugMode: globalConfig.dynamicDebugMode,
139
99
  });
140
100
  // BL = BLive
141
- const bl = this.ctx.plugin(blive_1.default);
101
+ const bl = this.ctx.plugin(BLive);
142
102
  // 添加服务
143
103
  this.servers.push(ba);
144
104
  this.servers.push(bl);
@@ -189,19 +149,14 @@ class ServerManager extends koishi_1.Service {
189
149
  });
190
150
  };
191
151
  }
192
- function apply(ctx, config) {
152
+ export function apply(ctx, config) {
193
153
  // 设置config
194
154
  globalConfig = config;
195
155
  // 设置提示
196
- ctx.notifier.create({
197
- type: "danger",
198
- content: "从3.1.0-alpha.0及以前版本升级到3.1.0-alpha.1及以后版本必定报错,请重新填写订阅配置中sub.target.channelArr的内容",
199
- });
200
156
  ctx.notifier.create({
201
157
  type: "warning",
202
158
  content: "请使用Auth插件创建超级管理员账号,没有权限将无法使用该插件提供的指令",
203
159
  });
204
- ctx.logger.warn("从3.1.0-alpha.0及以前版本升级到3.1.0-alpha.1版本必定报错,请重新填写订阅配置中sub.target.channelArr的内容");
205
160
  // load database
206
161
  ctx.plugin(Database);
207
162
  // Register ServerManager
@@ -214,23 +169,23 @@ function apply(ctx, config) {
214
169
  return next();
215
170
  });
216
171
  }
217
- exports.Config = koishi_1.Schema.object({
218
- require: koishi_1.Schema.object({}).description("必填设置"),
219
- key: koishi_1.Schema.string()
172
+ export const Config = Schema.object({
173
+ require: Schema.object({}).description("必填设置"),
174
+ key: Schema.string()
220
175
  .pattern(/^[0-9a-f]{32}$/)
221
176
  .role("secret")
222
177
  .required()
223
178
  .description("请输入一个32位小写字母的十六进制密钥(例如:9b8db7ae562b9864efefe06289cc5530),使用此密钥将你的B站登录信息存储在数据库中,请一定保存好此密钥。如果你忘记了此密钥,必须重新登录。你可以自行生成,或到这个网站生成:https://www.sexauth.com/"),
224
- master: koishi_1.Schema.intersect([
225
- koishi_1.Schema.object({
226
- enable: koishi_1.Schema.boolean()
179
+ master: Schema.intersect([
180
+ Schema.object({
181
+ enable: Schema.boolean()
227
182
  .default(false)
228
183
  .description("是否开启主人账号功能,如果您的机器人没有私聊权限请不要开启此功能。开启后如果机器人运行错误会向您进行报告"),
229
184
  }).description("主人账号"),
230
- koishi_1.Schema.union([
231
- koishi_1.Schema.object({
232
- enable: koishi_1.Schema.const(true).required(),
233
- platform: koishi_1.Schema.union([
185
+ Schema.union([
186
+ Schema.object({
187
+ enable: Schema.const(true).required(),
188
+ platform: Schema.union([
234
189
  "qq",
235
190
  "qqguild",
236
191
  "onebot",
@@ -241,163 +196,165 @@ exports.Config = koishi_1.Schema.object({
241
196
  "chronocat",
242
197
  "lark",
243
198
  ]).description("请选择您的私人机器人平台,目前支持QQ、QQ群、OneBot、Discord、RedBot、Telegram、Satori、ChronoCat、Lark。从2.0版本开始,只能在一个平台下使用本插件"),
244
- masterAccount: koishi_1.Schema.string()
199
+ masterAccount: Schema.string()
245
200
  .role("secret")
246
201
  .required()
247
202
  .description("主人账号,在Q群使用可直接使用QQ号,若在其他平台使用,请使用inspect插件获取自身ID"),
248
- masterAccountGuildId: koishi_1.Schema.string()
203
+ masterAccountGuildId: Schema.string()
249
204
  .role("secret")
250
205
  .description("主人账号所在的群组ID,只有在QQ频道、Discord这样的环境才需要填写,请使用inspect插件获取群组ID"),
251
206
  }),
252
- koishi_1.Schema.object({}),
207
+ Schema.object({}),
253
208
  ]),
254
209
  ]),
255
- basicSettings: koishi_1.Schema.object({}).description("基本设置"),
256
- userAgent: koishi_1.Schema.string()
210
+ basicSettings: Schema.object({}).description("基本设置"),
211
+ userAgent: Schema.string()
257
212
  .required()
258
213
  .description("设置请求头User-Agen,请求出现-352时可以尝试修改,UA获取方法可参考:https://blog.csdn.net/qq_44503987/article/details/104929111"),
259
- subTitle: koishi_1.Schema.object({}).description("订阅配置"),
260
- sub: koishi_1.Schema.array(koishi_1.Schema.object({
261
- name: koishi_1.Schema.string().description("订阅用户昵称,只是给你自己看的(相当于备注),可填可不填"),
262
- uid: koishi_1.Schema.string().required().description("订阅用户UID"),
263
- dynamic: koishi_1.Schema.boolean().default(false).description("是否订阅用户动态"),
264
- live: koishi_1.Schema.boolean().default(false).description("是否订阅用户直播"),
265
- target: koishi_1.Schema.array(koishi_1.Schema.object({
266
- platform: koishi_1.Schema.string()
214
+ subTitle: Schema.object({}).description("订阅配置"),
215
+ sub: Schema.array(Schema.object({
216
+ name: Schema.string().description("订阅用户昵称,只是给你自己看的(相当于备注),可填可不填"),
217
+ uid: Schema.string().required().description("订阅用户UID"),
218
+ dynamic: Schema.boolean().default(false).description("是否订阅用户动态"),
219
+ live: Schema.boolean().default(false).description("是否订阅用户直播"),
220
+ target: Schema.array(Schema.object({
221
+ platform: Schema.string()
267
222
  .required()
268
223
  .description("推送平台,例如onebot、qq、discord"),
269
- channelArr: koishi_1.Schema.array(koishi_1.Schema.object({
270
- channelId: koishi_1.Schema.string().required().description("频道/群组号"),
271
- dynamic: koishi_1.Schema.boolean()
224
+ channelArr: Schema.array(Schema.object({
225
+ channelId: Schema.string().required().description("频道/群组号"),
226
+ dynamic: Schema.boolean()
272
227
  .default(false)
273
228
  .description("该频道/群组是否推送动态信息"),
274
- live: koishi_1.Schema.boolean()
229
+ live: Schema.boolean()
275
230
  .default(false)
276
231
  .description("该频道/群组是否推送直播通知"),
277
- liveGuardBuy: koishi_1.Schema.boolean()
232
+ liveGuardBuy: Schema.boolean()
278
233
  .default(false)
279
234
  .description("该频道/群组是否推送上舰消息"),
280
- atAll: koishi_1.Schema.boolean()
235
+ atAll: Schema.boolean()
281
236
  .default(false)
282
237
  .description("推送开播通知时是否艾特全体成员"),
238
+ bot: Schema.string()
239
+ .description("若您有多个相同平台机器人,可在此填写当前群聊执行推送的机器人账号。不填则默认第一个")
283
240
  }))
284
241
  .role("table")
285
242
  .required()
286
243
  .description("需推送的频道/群组详细设置"),
287
244
  })).description("订阅用户需要发送的平台和频道/群组信息(一个平台下可以推送多个频道/群组)"),
288
- card: koishi_1.Schema.intersect([
289
- koishi_1.Schema.object({
290
- enable: koishi_1.Schema.boolean()
245
+ card: Schema.intersect([
246
+ Schema.object({
247
+ enable: Schema.boolean()
291
248
  .default(false)
292
249
  .description("是否开启自定义卡片颜色"),
293
250
  }),
294
- koishi_1.Schema.union([
295
- koishi_1.Schema.object({
296
- enable: koishi_1.Schema.const(true).required(),
297
- cardColorStart: koishi_1.Schema.string()
251
+ Schema.union([
252
+ Schema.object({
253
+ enable: Schema.const(true).required(),
254
+ cardColorStart: Schema.string()
298
255
  .pattern(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/)
299
256
  .description("推送卡片的开始渐变背景色,请填入16进制颜色代码,参考网站:https://webkul.github.io/coolhue/"),
300
- cardColorEnd: koishi_1.Schema.string()
257
+ cardColorEnd: Schema.string()
301
258
  .pattern(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/)
302
259
  .description("推送卡片的结束渐变背景色,请填入16进制颜色代码,参考网站:https://colorate.azurewebsites.net/"),
303
- cardBasePlateColor: koishi_1.Schema.string()
260
+ cardBasePlateColor: Schema.string()
304
261
  .pattern(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/)
305
262
  .description("推送卡片底板颜色,请填入16进制颜色代码"),
306
- cardBasePlateBorder: koishi_1.Schema.string()
263
+ cardBasePlateBorder: Schema.string()
307
264
  .pattern(/\d*\.?\d+(?:px|em|rem|%|vh|vw|vmin|vmax)/)
308
265
  .description("推送卡片底板边框宽度,请填入css单位,例如1px,12.5rem,100%"),
309
266
  }),
310
- koishi_1.Schema.object({}),
267
+ Schema.object({}),
311
268
  ]),
312
269
  ]),
313
270
  }).collapse())
314
271
  .collapse()
315
272
  .description("输入订阅信息,自定义订阅内容; uid: 订阅用户UID,dynamic: 是否需要订阅动态,live: 是否需要订阅直播"),
316
- dynamic: koishi_1.Schema.object({}).description("动态推送设置"),
317
- dynamicUrl: koishi_1.Schema.boolean()
273
+ dynamic: Schema.object({}).description("动态推送设置"),
274
+ dynamicUrl: Schema.boolean()
318
275
  .default(false)
319
276
  .description("发送动态时是否同时发送链接。注意:如果使用的是QQ官方机器人不能开启此项!"),
320
- pushImgsInDynamic: koishi_1.Schema.boolean()
277
+ pushImgsInDynamic: Schema.boolean()
321
278
  .default(false)
322
279
  .description("是否推送动态中的图片,默认不开启。开启后会单独推送动态中的图片,该功能容易导致QQ风控"),
323
- live: koishi_1.Schema.object({}).description("直播推送设置"),
324
- liveDetectType: koishi_1.Schema.union([
325
- koishi_1.Schema.const("WS").description("使用WebSocket连接到B站消息服务器进行直播检测,推荐使用"),
326
- koishi_1.Schema.const("API").description("通过轮询API发送请求监测直播状态,此模式理论可无限订阅,但容易产生其他问题,功能没有WS模式全面").experimental(),
280
+ live: Schema.object({}).description("直播推送设置"),
281
+ liveDetectType: Schema.union([
282
+ Schema.const("WS").description("使用WebSocket连接到B站消息服务器进行直播检测,推荐使用"),
283
+ Schema.const("API").description("通过轮询API发送请求监测直播状态,此模式理论可无限订阅,但容易产生其他问题,功能没有WS模式全面").experimental(),
327
284
  ])
328
285
  .role("radio")
329
286
  .default("WS")
330
287
  .description("直播检测方式,WS为连接到B站消息服务器,API为通过轮询发送请求监测,默认使用WS检测"),
331
- restartPush: koishi_1.Schema.boolean()
288
+ restartPush: Schema.boolean()
332
289
  .default(true)
333
290
  .description("插件重启后,如果订阅的主播正在直播,是否进行一次推送,默认开启"),
334
- pushTime: koishi_1.Schema.number()
291
+ pushTime: Schema.number()
335
292
  .min(0)
336
293
  .max(12)
337
294
  .step(0.5)
338
295
  .default(1)
339
296
  .description("设定间隔多长时间推送一次直播状态,单位为小时,默认为一小时"),
340
- customLiveStart: koishi_1.Schema.string()
297
+ customLiveStart: Schema.string()
341
298
  .default("-name开播啦,当前粉丝数:-follower\\n-link")
342
299
  .description("自定义开播提示语,-name代表UP昵称,-follower代表当前粉丝数,-link代表直播间链接(如果使用的是QQ官方机器人,请不要使用),\\n为换行。例如-name开播啦,会发送为xxxUP开播啦"),
343
- customLive: koishi_1.Schema.string()
300
+ customLive: Schema.string()
344
301
  .default("-name正在直播,目前已播-time,累计观看人数:-watched\\n-link")
345
302
  .description("自定义直播中提示语,-name代表UP昵称,-time代表开播时长,-watched代表累计观看人数,-link代表直播间链接(如果使用的是QQ官方机器人,请不要使用),\\n为换行。例如-name正在直播,会发送为xxxUP正在直播xxx"),
346
- customLiveEnd: koishi_1.Schema.string()
303
+ customLiveEnd: Schema.string()
347
304
  .default("-name下播啦,本次直播了-time,粉丝数变化-follower_change")
348
305
  .description("自定义下播提示语,-name代表UP昵称,-follower_change代表本场直播粉丝数变,-time代表开播时长,\\n为换行。例如-name下播啦,本次直播了-time,会发送为xxxUP下播啦,直播时长为xx小时xx分钟xx秒"),
349
- followerDisplay: koishi_1.Schema.boolean()
306
+ followerDisplay: Schema.boolean()
350
307
  .default(true)
351
308
  .description("粉丝数变化和累积观看本场直播的人数是否显示在推送卡片中"),
352
- hideDesc: koishi_1.Schema.boolean()
309
+ hideDesc: Schema.boolean()
353
310
  .default(false)
354
311
  .description("是否隐藏UP主直播间简介,开启后推送的直播卡片将不再展示简介"),
355
- style: koishi_1.Schema.object({}).description("美化设置"),
356
- removeBorder: koishi_1.Schema.boolean().default(false).description("移除推送卡片边框"),
357
- cardColorStart: koishi_1.Schema.string()
312
+ style: Schema.object({}).description("美化设置"),
313
+ removeBorder: Schema.boolean().default(false).description("移除推送卡片边框"),
314
+ cardColorStart: Schema.string()
358
315
  .pattern(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/)
359
316
  .default("#F38AB5")
360
317
  .description("推送卡片的开始渐变背景色,请填入16进制颜色代码,参考网站:https://webkul.github.io/coolhue/"),
361
- cardColorEnd: koishi_1.Schema.string()
318
+ cardColorEnd: Schema.string()
362
319
  .pattern(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/)
363
320
  .default("#F9CCDF")
364
321
  .description("推送卡片的结束渐变背景色,请填入16进制颜色代码,参考网站:https://colorate.azurewebsites.net/"),
365
- cardBasePlateColor: koishi_1.Schema.string()
322
+ cardBasePlateColor: Schema.string()
366
323
  .pattern(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/)
367
324
  .default("#FFF5EE")
368
325
  .description("推送卡片底板颜色,请填入16进制颜色代码"),
369
- cardBasePlateBorder: koishi_1.Schema.string()
326
+ cardBasePlateBorder: Schema.string()
370
327
  .pattern(/\d*\.?\d+(?:px|em|rem|%|vh|vw|vmin|vmax)/)
371
328
  .default("15px")
372
329
  .description("推送卡片底板边框宽度,请填入css单位,例如1px,12.5rem,100%"),
373
- enableLargeFont: koishi_1.Schema.boolean()
330
+ enableLargeFont: Schema.boolean()
374
331
  .default(false)
375
332
  .description("是否开启动态推送卡片大字体模式,默认为小字体。小字体更漂亮,但阅读比较吃力,大字体更易阅读,但相对没这么好看"),
376
- font: koishi_1.Schema.string().description("推送卡片的字体样式,如果你想用你自己的字体可以在此填写,例如:Microsoft YaHei"),
377
- filter: koishi_1.Schema.intersect([
378
- koishi_1.Schema.object({
379
- enable: koishi_1.Schema.boolean()
333
+ font: Schema.string().description("推送卡片的字体样式,如果你想用你自己的字体可以在此填写,例如:Microsoft YaHei"),
334
+ filter: Schema.intersect([
335
+ Schema.object({
336
+ enable: Schema.boolean()
380
337
  .default(false)
381
338
  .description("是否开启动态屏蔽功能"),
382
339
  }).description("屏蔽设置"),
383
- koishi_1.Schema.union([
384
- koishi_1.Schema.object({
385
- enable: koishi_1.Schema.const(true).required().experimental(),
386
- notify: koishi_1.Schema.boolean()
340
+ Schema.union([
341
+ Schema.object({
342
+ enable: Schema.const(true).required().experimental(),
343
+ notify: Schema.boolean()
387
344
  .default(false)
388
345
  .description("动态被屏蔽是否发送提示"),
389
- regex: koishi_1.Schema.string().description("正则表达式屏蔽"),
390
- keywords: koishi_1.Schema.array(String).description("关键字屏蔽,一个关键字为一项"),
391
- forward: koishi_1.Schema.boolean()
346
+ regex: Schema.string().description("正则表达式屏蔽"),
347
+ keywords: Schema.array(String).description("关键字屏蔽,一个关键字为一项"),
348
+ forward: Schema.boolean()
392
349
  .default(false)
393
350
  .description("是否屏蔽转发动态"),
394
- article: koishi_1.Schema.boolean().default(false).description("是否屏蔽专栏"),
351
+ article: Schema.boolean().default(false).description("是否屏蔽专栏"),
395
352
  }),
396
- koishi_1.Schema.object({}),
353
+ Schema.object({}),
397
354
  ]),
398
355
  ]),
399
- debug: koishi_1.Schema.object({}).description("调试设置"),
400
- dynamicDebugMode: koishi_1.Schema.boolean()
356
+ debug: Schema.object({}).description("调试设置"),
357
+ dynamicDebugMode: Schema.boolean()
401
358
  .default(false)
402
359
  .description("动态调试模式,开启后会在控制台输出动态推送的详细信息,用于调试"),
403
360
  });
@@ -11,6 +11,7 @@ export type Channel = {
11
11
  live: boolean;
12
12
  liveGuardBuy: boolean;
13
13
  atAll: boolean;
14
+ bot: string;
14
15
  };
15
16
  export type ChannelArr = Array<Channel>;
16
17
  export type TargetItem = {
package/lib/type/index.js CHANGED
@@ -1,18 +1,15 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PushType = exports.LiveType = void 0;
4
- var LiveType;
1
+ export var LiveType;
5
2
  (function (LiveType) {
6
3
  LiveType[LiveType["NotLiveBroadcast"] = 0] = "NotLiveBroadcast";
7
4
  LiveType[LiveType["StartBroadcasting"] = 1] = "StartBroadcasting";
8
5
  LiveType[LiveType["LiveBroadcast"] = 2] = "LiveBroadcast";
9
6
  LiveType[LiveType["StopBroadcast"] = 3] = "StopBroadcast";
10
7
  LiveType[LiveType["FirstLiveBroadcast"] = 4] = "FirstLiveBroadcast";
11
- })(LiveType || (exports.LiveType = LiveType = {}));
12
- var PushType;
8
+ })(LiveType || (LiveType = {}));
9
+ export var PushType;
13
10
  (function (PushType) {
14
11
  PushType[PushType["Live"] = 0] = "Live";
15
12
  PushType[PushType["Dynamic"] = 1] = "Dynamic";
16
13
  PushType[PushType["StartBroadcasting"] = 2] = "StartBroadcasting";
17
14
  PushType[PushType["LiveGuardBuy"] = 3] = "LiveGuardBuy";
18
- })(PushType || (exports.PushType = PushType = {}));
15
+ })(PushType || (PushType = {}));
@@ -1,9 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Retry = Retry;
4
- exports.withLock = withLock;
5
- exports.withRetry = withRetry;
6
- function Retry(options = { attempts: 3 }) {
1
+ export function Retry(options = { attempts: 3 }) {
7
2
  return (
8
3
  // biome-ignore lint/complexity/noBannedTypes: <explanation>
9
4
  target, propertyKey,
@@ -35,7 +30,7 @@ function Retry(options = { attempts: 3 }) {
35
30
  * @param {Function} fn - 需要包装的原始函数
36
31
  * @returns {Function} 带锁功能的函数
37
32
  */
38
- function withLock(fn) {
33
+ export function withLock(fn) {
39
34
  // 判断是否是异步函数
40
35
  const isAsync = fn.constructor.name === "AsyncFunction";
41
36
  // 定义锁标志
@@ -86,7 +81,7 @@ function withLock(fn) {
86
81
  }
87
82
  };
88
83
  }
89
- async function withRetry(fn, maxAttempts = 3, delayMs = 1000) {
84
+ export async function withRetry(fn, maxAttempts = 3, delayMs = 1000) {
90
85
  let attempt = 0;
91
86
  while (attempt < maxAttempts) {
92
87
  try {
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": "3.2.0-alpha.7",
4
+ "version": "3.2.1-alpha.1",
5
5
  "contributors": [
6
6
  "Akokko <admin@akokko.com>"
7
7
  ],
@@ -30,6 +30,7 @@
30
30
  "axios": "^1.7.9",
31
31
  "axios-cookiejar-support": "^5.0.5",
32
32
  "blive-message-listener": "^0.5.0",
33
+ "cacheable-lookup": "^7.0.0",
33
34
  "cron": "^4.3.0",
34
35
  "jsdom": "^24.1.3",
35
36
  "luxon": "^3.5.0",
package/readme.md CHANGED
@@ -256,6 +256,8 @@ uid为必填参数,为要推送的UP主的UID,index为可选参数,为要
256
256
  - ver 3.2.0-alpha.5 修复:直播检测 `WS` 模式下,直播中推送卡片 `累计观看人数` 位置错误显示为 `粉丝数变化` 、转发动态的留言文字不显示; 优化:直播检测 `API` 模式下,直播推送语 `-watched` 固定显示为 `API模式无法获取`;
257
257
  - ver 3.2.0-alpha.6 优化:调整配置项;
258
258
  - ver 3.2.0-alpha.7 修复:自 `3.1.7` 版本 `pushImagesInDynamic` 功能失效;
259
+ - ver 3.2.1-alpha.0 新增:多个相同平台bot可以选择某个群聊/频道指定机器人发送; 优化:直播检测 `WS` 模式下播后仍推送; 修复:打开 `pushImagesInDynamic` 功能时,如果发送的动态里没有图片则会报错 `TypeError: Cannot read properties of null (reading 'opus')`
260
+ - ver 3.2.1-alpha.1 调整:将项目构建产物调整为 `esm`;
259
261
 
260
262
  ## 交流群
261
263
 
@@ -1,6 +0,0 @@
1
- interface RetryOptions {
2
- attempts: number;
3
- onFailure?: (error: Error, attempts: number) => Promise<void> | void;
4
- }
5
- declare function Retry(options?: RetryOptions): MethodDecorator;
6
- export default Retry;