koishi-plugin-bilibili-notify 3.0.1 → 3.0.2

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.
@@ -16,7 +16,6 @@ declare class ComRegister {
16
16
  loginDBData: FlatPick<LoginBili, "dynamic_group_id">;
17
17
  privateBot: Bot<Context>;
18
18
  dynamicDispose: () => void;
19
- liveDispose: () => void;
20
19
  sendMsgFunc: (bot: Bot<Context, any>, channelId: string, content: any) => Promise<void>;
21
20
  constructor(ctx: Context, config: ComRegister.Config);
22
21
  init(config: ComRegister.Config): Promise<void>;
@@ -16,7 +16,7 @@ const type_1 = require("./type");
16
16
  // import { Segment, useDefault } from "segmentit";
17
17
  class ComRegister {
18
18
  // 必须服务
19
- static inject = ["ba", "gi", "database", "bl", "sm"];
19
+ static inject = ["ba", "gi", "database", "bl", "sm", "cron"];
20
20
  // 定义数组:QQ相关bot
21
21
  qqRelatedBotList = [
22
22
  "qq",
@@ -47,8 +47,6 @@ class ComRegister {
47
47
  privateBot;
48
48
  // 动态检测销毁函数
49
49
  dynamicDispose;
50
- // 直播检测销毁函数
51
- liveDispose;
52
50
  // 发送消息方式
53
51
  sendMsgFunc;
54
52
  // 构造函数
@@ -328,6 +326,15 @@ class ComRegister {
328
326
  this.checkIfDynamicDetectIsNeeded();
329
327
  // 在控制台中显示订阅对象
330
328
  this.updateSubNotifier();
329
+ // 注册插件销毁函数
330
+ this.ctx.on("dispose", () => {
331
+ // 销毁登录定时器
332
+ if (this.loginTimer)
333
+ this.loginTimer();
334
+ // 销毁动态监测
335
+ if (this.dynamicDispose)
336
+ this.dynamicDispose();
337
+ });
331
338
  // logger
332
339
  this.logger.info("插件初始化完毕!");
333
340
  }
@@ -765,7 +772,8 @@ class ComRegister {
765
772
  // 检查更新的动态
766
773
  for (const item of items) {
767
774
  // 动态ID如果一致则结束循环
768
- if (item.id_str === dynamicIdStr1st || item.id_str === dynamicIdStr2nd) {
775
+ if (item.id_str === dynamicIdStr1st ||
776
+ item.id_str === dynamicIdStr2nd) {
769
777
  // logger
770
778
  this.logger.info("动态ID与上次检测第一条一致,结束循环");
771
779
  this.logger.info("动态检测结束");
@@ -1435,12 +1443,9 @@ class ComRegister {
1435
1443
  }
1436
1444
  enableDynamicDetect() {
1437
1445
  // 开始动态监测
1438
- if (this.config.dynamicDebugMode) {
1439
- this.dynamicDispose = this.ctx.setInterval(this.debug_dynamicDetect(), this.config.dynamicLoopTime * 1000);
1440
- }
1441
- else {
1442
- this.dynamicDispose = this.ctx.setInterval(this.dynamicDetect(), this.config.dynamicLoopTime * 1000);
1443
- }
1446
+ this.dynamicDispose = this.ctx.cron("*/2 * * * *", this.config.dynamicDebugMode
1447
+ ? this.debug_dynamicDetect()
1448
+ : this.dynamicDetect());
1444
1449
  }
1445
1450
  async checkIfIsLogin() {
1446
1451
  if ((await this.ctx.database.get("loginBili", 1)).length !== 0) {
package/lib/index.js CHANGED
@@ -46,7 +46,7 @@ const Database = __importStar(require("./database"));
46
46
  const generateImg_1 = __importDefault(require("./generateImg"));
47
47
  const biliAPI_1 = __importDefault(require("./biliAPI"));
48
48
  const blive_1 = __importDefault(require("./blive"));
49
- exports.inject = ["puppeteer", "database", "notifier"];
49
+ exports.inject = ["puppeteer", "database", "notifier", "cron"];
50
50
  exports.name = "bilibili-notify";
51
51
  let globalConfig;
52
52
  class ServerManager extends koishi_1.Service {
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.0.1",
4
+ "version": "3.0.2",
5
5
  "contributors": [
6
6
  "Akokko <admin@akokko.com>"
7
7
  ],
@@ -44,6 +44,7 @@
44
44
  "@types/qrcode": "^1.5.5",
45
45
  "@types/tough-cookie": "^4.0.5",
46
46
  "globals": "^15.14.0",
47
+ "koishi-plugin-cron": "^3.1.0",
47
48
  "koishi-plugin-puppeteer": "^3.9.0"
48
49
  },
49
50
  "koishi": {
package/readme.md CHANGED
@@ -217,6 +217,7 @@
217
217
  - ver 3.0.1-alpha.1 新增:直播提示语换行符,配置项 `sub.name` 为可选项; 修复:debug模式下动态监测5S一次; 优化:加载订阅
218
218
  - ver 3.0.1-alpha.2 优化:改进错误提示,改进订阅加载方式
219
219
  - ver 3.0.1 修复:动态推送过程中,如果上一次请求的第一条动态被删除,可能导致动态重复推送(本次修复并不能完全保障不重复推送,如果第一条和第二条都被删除则可能会出现重复推送); 新增:配置项 `subTimeout` 设置订阅超时时间
220
+ - ver 3.0.2 优化:动态监测,新增依赖服务cron
220
221
 
221
222
  ## 交流群
222
223