koishi-plugin-bilibili-notify 1.3.6-alpha.0 → 1.3.6-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/biliAPI.js CHANGED
@@ -3,8 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ /* eslint-disable @typescript-eslint/no-unused-vars */
7
+ /* eslint-disable @typescript-eslint/no-unsafe-function-type */
6
8
  /* eslint-disable @typescript-eslint/no-namespace */
7
- /* eslint-disable @typescript-eslint/ban-types */
8
9
  /* eslint-disable @typescript-eslint/no-explicit-any */
9
10
  const koishi_1 = require("koishi");
10
11
  const axios_1 = __importDefault(require("axios"));
@@ -154,7 +155,8 @@ class BiliAPI extends koishi_1.Service {
154
155
  throw new Error('网络异常,本次请求失败!');
155
156
  }
156
157
  }
157
- disposeNotifier() { this.loginNotifier && this.loginNotifier.dispose(); }
158
+ disposeNotifier() { if (this.loginNotifier)
159
+ this.loginNotifier.dispose(); }
158
160
  getRandomUserAgent() {
159
161
  const userAgents = [
160
162
  'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36',
@@ -271,7 +273,8 @@ class BiliAPI extends koishi_1.Service {
271
273
  }
272
274
  enableRefreshCookiesDetect() {
273
275
  // 判断之前是否启动检测
274
- this.refreshCookieTimer && this.refreshCookieTimer();
276
+ if (this.refreshCookieTimer)
277
+ this.refreshCookieTimer();
275
278
  // Open scheduled tasks and check if token need refresh
276
279
  this.refreshCookieTimer = this.ctx.setInterval(async () => {
277
280
  // 从数据库获取登录信息
@@ -32,6 +32,7 @@ declare class ComRegister {
32
32
  getTheCorrespondingBotBasedOnTheSession(session: Session): Bot<Context, any>;
33
33
  sendPrivateMsg(bot: Bot<Context>, content: string): Promise<void>;
34
34
  sendPrivateMsgAndRebootService(ctx: Context, bot: Bot<Context>): Promise<void>;
35
+ sendPrivateMsgAndStopService(ctx: Context, bot: Bot<Context>): Promise<void>;
35
36
  sendMsg(targets: Array<string>, bot: Bot<Context>, content: any): Promise<void>;
36
37
  dynamicDetect(ctx: Context, bot: Bot<Context>, uid: string, guildId: Array<string>): () => Promise<void>;
37
38
  debug_dynamicDetect(ctx: Context, bot: Bot<Context>, uid: string, guildId: Array<string>): () => Promise<void>;
@@ -4,13 +4,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const jsx_runtime_1 = require("@satorijs/element/jsx-runtime");
7
+ /* eslint-disable @typescript-eslint/no-unused-vars */
8
+ /* eslint-disable @typescript-eslint/no-unsafe-function-type */
7
9
  /* eslint-disable @typescript-eslint/no-namespace */
8
10
  /* eslint-disable @typescript-eslint/no-explicit-any */
9
- /* eslint-disable @typescript-eslint/ban-types */
10
11
  const koishi_1 = require("koishi");
11
12
  // 导入qrcode
12
13
  const qrcode_1 = __importDefault(require("qrcode"));
13
- const jimp_1 = __importDefault(require("jimp"));
14
+ const jimp_1 = require("jimp");
14
15
  var LiveType;
15
16
  (function (LiveType) {
16
17
  LiveType[LiveType["NotLiveBroadcast"] = 0] = "NotLiveBroadcast";
@@ -261,7 +262,8 @@ class ComRegister {
261
262
  await session.send(koishi_1.h.image(buffer, 'image/png'));
262
263
  });
263
264
  // 检查之前是否存在登录定时器
264
- this.loginTimer && this.loginTimer();
265
+ if (this.loginTimer)
266
+ this.loginTimer();
265
267
  // 设置flag
266
268
  let flag = true;
267
269
  // 发起登录请求检查登录状态
@@ -364,7 +366,8 @@ class ComRegister {
364
366
  }
365
367
  }));
366
368
  // 未订阅该用户,无需取消订阅
367
- !exist && session.send('未订阅该用户,无需取消订阅');
369
+ if (!exist)
370
+ session.send('未订阅该用户,无需取消订阅');
368
371
  });
369
372
  biliCom
370
373
  .subcommand('.show', '展示订阅对象')
@@ -708,7 +711,7 @@ class ComRegister {
708
711
  // 获得对应bot
709
712
  const bot = this.getTheCorrespondingBotBasedOnTheSession(session)
710
713
  // 发送提示消息,重启服务
711
- await this.sendPrivateMsgAndRebootService(ctx, bot, '测试biliAPI等服务自动重启功能')
714
+ await this.sendPrivateMsgAndStopService(ctx, bot, '测试biliAPI等服务自动重启功能')
712
715
  }) */
713
716
  /* biliCom
714
717
  .subcommand('.sendall', '测试给机器人加入的所有群发送消息', { hidden: true })
@@ -812,6 +815,16 @@ class ComRegister {
812
815
  await ctx.sm.disposePlugin();
813
816
  }
814
817
  }
818
+ async sendPrivateMsgAndStopService(ctx, bot) {
819
+ // 发送消息
820
+ await this.sendPrivateMsg(bot, '插件发生未知错误,请检查机器人状态后使用指令 sys start 启动插件');
821
+ // logger
822
+ this.logger.error('插件发生未知错误,请检查机器人状态后使用指令 sys start 启动插件');
823
+ // 关闭插件
824
+ await ctx.sm.disposePlugin();
825
+ // 结束
826
+ return;
827
+ }
815
828
  async sendMsg(targets, bot, content) {
816
829
  // 定义需要发送的数组
817
830
  let sendArr = [];
@@ -946,18 +959,22 @@ class ComRegister {
946
959
  return updatePoint(num);
947
960
  if (e.message === '出现关键词,屏蔽该动态') {
948
961
  // 如果需要发送才发送
949
- this.config.filter.notify && await this.sendMsg(guildId, bot, `${upName}发布了一条含有屏蔽关键字的动态`);
962
+ if (this.config.filter.notify) {
963
+ await this.sendMsg(guildId, bot, `${upName}发布了一条含有屏蔽关键字的动态`);
964
+ }
950
965
  return updatePoint(num);
951
966
  }
952
967
  if (e.message === '已屏蔽转发动态') {
953
- this.config.filter.notify && await this.sendMsg(guildId, bot, `${upName}发布了一条转发动态,已屏蔽`);
968
+ if (this.config.filter.notify) {
969
+ await this.sendMsg(guildId, bot, `${upName}发布了一条转发动态,已屏蔽`);
970
+ }
954
971
  return updatePoint(num);
955
972
  }
956
973
  // 未知错误
957
974
  if (i === attempts - 1) {
958
975
  this.logger.error('dynamicDetect generateDynamicImg() 推送卡片发送失败,原因:' + e.message);
959
976
  // 发送私聊消息并重启服务
960
- return await this.sendPrivateMsgAndRebootService(ctx, bot);
977
+ return await this.sendPrivateMsgAndStopService(ctx, bot);
961
978
  }
962
979
  }
963
980
  }
@@ -1109,18 +1126,22 @@ class ComRegister {
1109
1126
  return updatePoint(num);
1110
1127
  if (e.message === '出现关键词,屏蔽该动态') {
1111
1128
  // 如果需要发送才发送
1112
- this.config.filter.notify && await this.sendMsg(guildId, bot, `${upName}发布了一条含有屏蔽关键字的动态`);
1129
+ if (this.config.filter.notify) {
1130
+ await this.sendMsg(guildId, bot, `${upName}发布了一条含有屏蔽关键字的动态`);
1131
+ }
1113
1132
  return updatePoint(num);
1114
1133
  }
1115
1134
  if (e.message === '已屏蔽转发动态') {
1116
- this.config.filter.notify && await this.sendMsg(guildId, bot, `${upName}发布了一条转发动态,已屏蔽`);
1135
+ if (this.config.filter.notify) {
1136
+ await this.sendMsg(guildId, bot, `${upName}发布了一条转发动态,已屏蔽`);
1137
+ }
1117
1138
  return updatePoint(num);
1118
1139
  }
1119
1140
  // 未知错误
1120
1141
  if (i === attempts - 1) {
1121
1142
  this.logger.error('dynamicDetect generateDynamicImg() 推送卡片发送失败,原因:' + e.message);
1122
1143
  // 发送私聊消息并重启服务
1123
- return await this.sendPrivateMsgAndRebootService(ctx, bot);
1144
+ return await this.sendPrivateMsgAndStopService(ctx, bot);
1124
1145
  }
1125
1146
  }
1126
1147
  }
@@ -1185,7 +1206,7 @@ class ComRegister {
1185
1206
  if (i === attempts - 1) { // 已尝试三次
1186
1207
  this.logger.error('liveDetect generateLiveImg() 推送卡片生成失败,原因:' + e.message);
1187
1208
  // 发送私聊消息并重启服务
1188
- return await this.sendPrivateMsgAndRebootService(ctx, bot);
1209
+ return await this.sendPrivateMsgAndStopService(ctx, bot);
1189
1210
  }
1190
1211
  }
1191
1212
  }
@@ -1221,7 +1242,7 @@ class ComRegister {
1221
1242
  if (i === attempts - 1) { // 已尝试三次
1222
1243
  this.logger.error('liveDetect generateLiveImg() 推送卡片生成失败,原因:' + e.message);
1223
1244
  // 发送私聊消息并重启服务
1224
- return await this.sendPrivateMsgAndRebootService(ctx, bot);
1245
+ return await this.sendPrivateMsgAndStopService(ctx, bot);
1225
1246
  }
1226
1247
  }
1227
1248
  }
@@ -1273,7 +1294,7 @@ class ComRegister {
1273
1294
  this.logger.error('liveDetect getLiveRoomInfo 发生了错误,错误为:' + e.message);
1274
1295
  if (i === attempts - 1) { // 已尝试三次
1275
1296
  // 发送私聊消息并重启服务
1276
- return await this.sendPrivateMsgAndRebootService(ctx, bot);
1297
+ return await this.sendPrivateMsgAndStopService(ctx, bot);
1277
1298
  }
1278
1299
  }
1279
1300
  }
@@ -1294,7 +1315,7 @@ class ComRegister {
1294
1315
  this.logger.error('liveDetect getMasterInfo() 发生了错误,错误为:' + e.message);
1295
1316
  if (i === attempts - 1) { // 已尝试三次
1296
1317
  // 发送私聊消息并重启服务
1297
- return await this.sendPrivateMsgAndRebootService(ctx, bot);
1318
+ return await this.sendPrivateMsgAndStopService(ctx, bot);
1298
1319
  }
1299
1320
  }
1300
1321
  }
@@ -1326,8 +1347,8 @@ class ComRegister {
1326
1347
  let resizedImage;
1327
1348
  // Jimp无法处理Webp格式,直接跳过
1328
1349
  try {
1329
- resizedImage = await jimp_1.default.read(userface).then(async (image) => {
1330
- return await image.resize(100, 100).getBufferAsync(jimp_1.default.MIME_PNG);
1350
+ resizedImage = await jimp_1.Jimp.read(userface).then(async (image) => {
1351
+ return await image.resize({ w: 100, h: 100 }).getBuffer(jimp_1.JimpMime.png);
1331
1352
  });
1332
1353
  }
1333
1354
  catch (e) {
@@ -1362,7 +1383,7 @@ class ComRegister {
1362
1383
  this.logger.error('liveDetect open getMasterInfo() 发生了错误,错误为:' + e.message);
1363
1384
  if (i === attempts - 1) { // 已尝试三次
1364
1385
  // 发送私聊消息并重启服务
1365
- return await this.sendPrivateMsgAndRebootService(ctx, bot);
1386
+ return await this.sendPrivateMsgAndStopService(ctx, bot);
1366
1387
  }
1367
1388
  }
1368
1389
  }
@@ -1448,7 +1469,8 @@ class ComRegister {
1448
1469
  }
1449
1470
  updateSubNotifier(ctx) {
1450
1471
  // 更新控制台提示
1451
- this.subNotifier && this.subNotifier.dispose();
1472
+ if (this.subNotifier)
1473
+ this.subNotifier.dispose();
1452
1474
  // 获取订阅信息
1453
1475
  const subInfo = this.subShow();
1454
1476
  // 定义table
@@ -1571,7 +1593,7 @@ class ComRegister {
1571
1593
  this.logger.error('getSubFromDatabase() getUserInfo() 发生了错误,错误为:' + e.message);
1572
1594
  if (i === attempts - 1) { // 已尝试三次
1573
1595
  // 发送私聊消息并重启服务
1574
- return await this.sendPrivateMsgAndRebootService(ctx, bot);
1596
+ return await this.sendPrivateMsgAndStopService(ctx, bot);
1575
1597
  }
1576
1598
  }
1577
1599
  }
@@ -1674,7 +1696,8 @@ class ComRegister {
1674
1696
  if (index === -1)
1675
1697
  return '未订阅该用户,无需取消订阅';
1676
1698
  // 取消订阅
1677
- this.subManager[index].live && this.subManager[index].liveDispose();
1699
+ if (this.subManager[index].live)
1700
+ this.subManager[index].liveDispose();
1678
1701
  this.subManager[index].liveDispose = null;
1679
1702
  this.subManager[index].live = false;
1680
1703
  // 如果没有对这个UP的任何订阅,则移除
@@ -1693,7 +1716,8 @@ class ComRegister {
1693
1716
  if (index === -1)
1694
1717
  return '未订阅该用户,无需取消订阅';
1695
1718
  // 取消订阅
1696
- this.subManager[index].dynamic && this.subManager[index].dynamicDispose();
1719
+ if (this.subManager[index].dynamic)
1720
+ this.subManager[index].dynamicDispose();
1697
1721
  this.subManager[index].dynamicDispose = null;
1698
1722
  this.subManager[index].dynamic = false;
1699
1723
  // 如果没有对这个UP的任何订阅,则移除
package/lib/index.js CHANGED
@@ -28,7 +28,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.Config = exports.name = exports.inject = void 0;
30
30
  exports.apply = apply;
31
- /* eslint-disable @typescript-eslint/ban-types */
31
+ /* eslint-disable @typescript-eslint/no-empty-object-type */
32
32
  const koishi_1 = require("koishi");
33
33
  // import plugins
34
34
  // import Authority from './authority'
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": "1.3.6-alpha.0",
4
+ "version": "1.3.6-beta.0",
5
5
  "contributors": [
6
6
  "Akokko <admin@akokko.com>"
7
7
  ],
@@ -27,25 +27,25 @@
27
27
  "koishi": "^4.17.5"
28
28
  },
29
29
  "dependencies": {
30
- "axios": "^1.7.0-beta.1",
31
- "axios-cookiejar-support": "^5.0.2",
32
- "jimp": "^0.22.12",
33
- "jsdom": "^24.0.0",
34
- "luxon": "^3.4.4",
30
+ "axios": "^1.7.7",
31
+ "axios-cookiejar-support": "^5.0.3",
32
+ "jimp": "^1.6.0",
33
+ "jsdom": "^24.1.3",
34
+ "luxon": "^3.5.0",
35
35
  "md5": "^2.3.0",
36
- "qrcode": "^1.5.3",
36
+ "qrcode": "^1.5.4",
37
37
  "tough-cookie": "^4.1.4"
38
38
  },
39
39
  "devDependencies": {
40
- "@eslint/js": "^9.6.0",
41
- "@types/luxon": "^3",
42
- "@types/md5": "^2",
43
- "@types/qrcode": "^1",
44
- "@types/tough-cookie": "^4",
45
- "eslint": "9.x",
46
- "globals": "^15.6.0",
47
- "koishi-plugin-puppeteer": "^3.8.4",
48
- "typescript-eslint": "^7.14.1"
40
+ "@eslint/js": "^9.12.0",
41
+ "@types/luxon": "^3.4.2",
42
+ "@types/md5": "^2.3.5",
43
+ "@types/qrcode": "^1.5.5",
44
+ "@types/tough-cookie": "^4.0.5",
45
+ "eslint": "^9.12.0",
46
+ "globals": "^15.11.0",
47
+ "koishi-plugin-puppeteer": "^3.9.0",
48
+ "typescript-eslint": "^7.18.0"
49
49
  },
50
50
  "koishi": {
51
51
  "service": {
package/readme.md CHANGED
@@ -172,6 +172,7 @@
172
172
  - ver 1.3.4 新增消息推送失败是否自动重发的选项,修复了一些潜在的bug
173
173
  - ver 1.3.5 动态监测循环时间新增20分钟选项
174
174
  - ver 1.3.6-alpha.0 修复bug:无限重复的报错提示
175
+ - ver 1.3.6-beta.0 取消出错自动重启插件功能
175
176
 
176
177
  ## 交流群
177
178