koishi-plugin-bilibili-notify 3.0.0-alpha.18 → 3.0.0-alpha.19

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.
@@ -21,6 +21,7 @@ declare class ComRegister {
21
21
  constructor(ctx: Context, config: ComRegister.Config);
22
22
  init(config: ComRegister.Config): Promise<void>;
23
23
  getBot(pf: string): Bot<Context, any>;
24
+ test_wordCloud(): Promise<void>;
24
25
  sendPrivateMsg(content: string): Promise<void>;
25
26
  sendPrivateMsgAndRebootService(): Promise<void>;
26
27
  sendPrivateMsgAndStopService(): Promise<void>;
@@ -4,13 +4,12 @@ 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
+ // Koishi核心依赖
7
8
  const koishi_1 = require("koishi");
8
- // 导入qrcode
9
+ // 外部依赖:qrcode
9
10
  const qrcode_1 = __importDefault(require("qrcode"));
11
+ // Types
10
12
  const type_1 = require("./type");
11
- // 弹幕词云
12
- // TODO:WorlCloud
13
- // import { Segment } from "segmentit";
14
13
  class ComRegister {
15
14
  // 必须服务
16
15
  static inject = ["ba", "gi", "database", "bl", "sm"];
@@ -284,8 +283,33 @@ class ComRegister {
284
283
  this.checkIfDynamicDetectIsNeeded();
285
284
  // 在控制台中显示订阅对象
286
285
  this.updateSubNotifier();
287
- /* // Test
288
- const testTarget: Target = [
286
+ }
287
+ // biome-ignore lint/suspicious/noExplicitAny: <explanation>
288
+ getBot(pf) {
289
+ return this.ctx.bots.find((bot) => bot.platform === pf);
290
+ }
291
+ // TODO:WordCloud
292
+ async test_wordCloud() {
293
+ /* const currentLiveDanmakuArr = []
294
+ // 定义获取弹幕权重Record函数
295
+ const getDanmakuWeightRecord = (): Record<string, number> => {
296
+ // 创建segmentit
297
+ const segmentit = useDefault(new Segment());
298
+ // 创建Record
299
+ const danmakuWeightRecord: Record<string, number> = {};
300
+ // 循环遍历currentLiveDanmakuArr
301
+ for (const danmaku of currentLiveDanmakuArr) {
302
+ // 遍历结果
303
+ segmentit.doSegment(danmaku).map((word: { w: string; p: number }) => {
304
+ // 定义权重
305
+ danmakuWeightRecord[word.w] = (danmakuWeightRecord[word.w] || 0) + 1;
306
+ });
307
+ }
308
+ // 返回Record
309
+ return danmakuWeightRecord;
310
+ }; */
311
+ // Test
312
+ const testTarget = [
289
313
  {
290
314
  channelIdArr: [
291
315
  {
@@ -299,13 +323,6 @@ class ComRegister {
299
323
  platform: "qqguild",
300
324
  },
301
325
  ];
302
-
303
- const buffer = await this.ctx.gi.generateWordCloudImg();
304
- this.sendMsg(testTarget, h.image(buffer, "image/png")); */
305
- }
306
- // biome-ignore lint/suspicious/noExplicitAny: <explanation>
307
- getBot(pf) {
308
- return this.ctx.bots.find((bot) => bot.platform === pf);
309
326
  }
310
327
  async sendPrivateMsg(content) {
311
328
  if (this.config.master.enable) {
@@ -911,24 +928,6 @@ class ComRegister {
911
928
  }
912
929
  return content.data;
913
930
  }
914
- // TODO:WordCloud
915
- /* // 定义获取弹幕权重Record函数
916
- const getDanmakuWeightRecord = (): Record<string, number> => {
917
- // 创建segmentit
918
- const segmentit = useDefault(new Segment());
919
- // 创建Record
920
- const danmakuWeightRecord: Record<string, number> = {};
921
- // 循环遍历currentLiveDanmakuArr
922
- for (const danmaku of currentLiveDanmakuArr) {
923
- // 遍历结果
924
- segmentit.doSegment(danmaku).map((word: { w: string; p: number }) => {
925
- // 定义权重
926
- danmakuWeightRecord[word.w] = (danmakuWeightRecord[word.w] || 0) + 1;
927
- });
928
- }
929
- // 返回Record
930
- return danmakuWeightRecord;
931
- }; */
932
931
  async liveDetectWithListener(roomId, target) {
933
932
  // 定义开播时间
934
933
  let liveTime;
@@ -1049,7 +1048,9 @@ class ComRegister {
1049
1048
  // 设置开播时间
1050
1049
  liveTime = liveRoomInfo.live_time;
1051
1050
  // 获取当前粉丝数
1052
- const follower = masterInfo.liveOpenFollowerNum >= 10_000 ? `${masterInfo.liveOpenFollowerNum.toFixed(1)}万` : masterInfo.liveOpenFollowerNum.toString();
1051
+ const follower = masterInfo.liveOpenFollowerNum >= 10_000
1052
+ ? `${(masterInfo.liveOpenFollowerNum / 10000).toFixed(1)}万`
1053
+ : masterInfo.liveOpenFollowerNum.toString();
1053
1054
  // 定义开播通知语
1054
1055
  const liveStartMsg = this.config.customLiveStart
1055
1056
  ? this.config.customLiveStart
@@ -1088,10 +1089,14 @@ class ComRegister {
1088
1089
  // 判断是否大于0
1089
1090
  if (liveFollowerChangeNum > 0) {
1090
1091
  // 大于0则加+
1091
- return liveFollowerChangeNum >= 10_000 ? `+${liveFollowerChangeNum.toFixed(1)}万` : `+${liveFollowerChangeNum}`;
1092
+ return liveFollowerChangeNum >= 10_000
1093
+ ? `+${liveFollowerChangeNum.toFixed(1)}万`
1094
+ : `+${liveFollowerChangeNum}`;
1092
1095
  }
1093
1096
  // 小于0
1094
- return liveFollowerChangeNum <= -10_000 ? `${liveFollowerChangeNum.toFixed(1)}万` : liveFollowerChangeNum.toString();
1097
+ return liveFollowerChangeNum <= -10_000
1098
+ ? `${liveFollowerChangeNum.toFixed(1)}万`
1099
+ : liveFollowerChangeNum.toString();
1095
1100
  })();
1096
1101
  // 定义下播播通知语
1097
1102
  const liveEndMsg = this.config.customLiveEnd
@@ -24,7 +24,6 @@ declare class GenerateImg extends Service {
24
24
  link: string;
25
25
  buffer?: undefined;
26
26
  }>;
27
- generateWordCloudImg(): Promise<Buffer<ArrayBufferLike>>;
28
27
  getLiveStatus(time: string, liveStatus: number): Promise<[string, string, boolean]>;
29
28
  getTimeDifference(dateString: string): Promise<string>;
30
29
  unixTimestampToString(timestamp: number): string;
@@ -1429,35 +1429,6 @@ class GenerateImg extends koishi_1.Service {
1429
1429
  }
1430
1430
  }
1431
1431
  }
1432
- async generateWordCloudImg() {
1433
- const page = await this.ctx.puppeteer.page();
1434
- // 创建HTML内容
1435
- const htmlContent = /* html */ `
1436
- <!DOCTYPE html>
1437
- <html>
1438
- <head>
1439
- <script src="https://cdn.jsdelivr.net/npm/echarts@5.4.0/dist/echarts.min.js"></script>
1440
- </head>
1441
- <body>
1442
- <div id="chart" style="width:800px;height:600px;"></div>
1443
- <script>
1444
- const chart = echarts.init(document.getElementById('chart'));
1445
- chart.setOption({
1446
- title: { text: 'Node.js ECharts示例' },
1447
- tooltip: {},
1448
- xAxis: { data: ['A', 'B', 'C', 'D', 'E'] },
1449
- yAxis: {},
1450
- series: [{ name: '数据', type: 'bar', data: [5, 20, 36, 10, 15] }]
1451
- });
1452
- </script>
1453
- </body>
1454
- </html>
1455
- `;
1456
- // 加载HTML并截图
1457
- await page.setContent(htmlContent);
1458
- const buffer = await page.screenshot({ path: "output.png" });
1459
- return buffer;
1460
- }
1461
1432
  async getLiveStatus(time, liveStatus) {
1462
1433
  let titleStatus;
1463
1434
  let liveTime;
package/lib/index.js CHANGED
@@ -237,7 +237,7 @@ function apply(ctx, config) {
237
237
  });
238
238
  ctx.notifier.create({
239
239
  type: "warning",
240
- content: "请使用Auth插件创建超级管理员账号,没有权限将无法使用该插件提供的指令。",
240
+ content: "请使用Auth插件创建超级管理员账号,没有权限将无法使用该插件提供的指令",
241
241
  });
242
242
  // load database
243
243
  ctx.plugin(Database);
@@ -302,18 +302,18 @@ exports.Config = koishi_1.Schema.object({
302
302
  .description("设置请求头User-Agen,请求出现-352时可以尝试修改,UA获取方法可参考:https://blog.csdn.net/qq_44503987/article/details/104929111"),
303
303
  subTitle: koishi_1.Schema.object({}).description("订阅配置"),
304
304
  sub: koishi_1.Schema.array(koishi_1.Schema.object({
305
- uid: koishi_1.Schema.string().description("订阅用户UID"),
306
- dynamic: koishi_1.Schema.boolean().description("是否订阅用户动态"),
307
- live: koishi_1.Schema.boolean().description("是否订阅用户直播"),
305
+ uid: koishi_1.Schema.string().required().description("订阅用户UID"),
306
+ dynamic: koishi_1.Schema.boolean().required().description("是否订阅用户动态"),
307
+ live: koishi_1.Schema.boolean().required().description("是否订阅用户直播"),
308
308
  target: koishi_1.Schema.array(koishi_1.Schema.object({
309
309
  channelIdArr: koishi_1.Schema.array(koishi_1.Schema.object({
310
- channelId: koishi_1.Schema.string().description("频道/群组号"),
311
- dynamic: koishi_1.Schema.boolean().description("该频道/群组是否推送动态信息"),
312
- live: koishi_1.Schema.boolean().description("该频道/群组是否推送直播通知"),
313
- liveGuardBuy: koishi_1.Schema.boolean().description("该频道/群组是否推送上舰消息"),
314
- atAll: koishi_1.Schema.boolean().description("推送开播通知时是否艾特全体成员"),
315
- })).description("需推送的频道/群组详细设置"),
316
- platform: koishi_1.Schema.string().description("推送平台"),
310
+ channelId: koishi_1.Schema.string().required().description("频道/群组号"),
311
+ dynamic: koishi_1.Schema.boolean().required().description("该频道/群组是否推送动态信息"),
312
+ live: koishi_1.Schema.boolean().required().description("该频道/群组是否推送直播通知"),
313
+ liveGuardBuy: koishi_1.Schema.boolean().required().description("该频道/群组是否推送上舰消息"),
314
+ atAll: koishi_1.Schema.boolean().required().description("推送开播通知时是否艾特全体成员"),
315
+ })).required().description("需推送的频道/群组详细设置"),
316
+ platform: koishi_1.Schema.string().required().description("推送平台"),
317
317
  })).description("订阅用户需要发送的平台和频道/群组信息(一个平台下可以推送多个频道/群组)"),
318
318
  }))
319
319
  .role("table")
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.0-alpha.18",
4
+ "version": "3.0.0-alpha.19",
5
5
  "contributors": [
6
6
  "Akokko <admin@akokko.com>"
7
7
  ],
package/readme.md CHANGED
@@ -198,6 +198,7 @@
198
198
  - ver 3.0.0-alpha.16 重大更新:订阅不再依赖数据库,从指令订阅全面迁移到配置订阅; 修复:直播时长有误; 优化:`bili show` 指令更改为 `bili list`
199
199
  - ver 3.0.0-alpha.17 新增:更多的提示语变量,开播,当前粉丝数。正在直播,累计观看人数。下播,粉丝数变化。选项,新增的提示语变量是否展示到推送卡片中
200
200
  - ver 3.0.0-alpha.18 移除:直播检测API模式已被废弃; 优化:更多提示语数据显示优化
201
+ - ver 3.0.0-alpha.19 修复:开播提示语粉丝数单位错误; 优化:订阅配置中所有配置项改为必填项
201
202
 
202
203
  ## 交流群
203
204
 
@@ -205,7 +206,9 @@
205
206
 
206
207
  ## 感谢
207
208
 
208
- 感谢 [koishijs](https://github.com/koishijs/koishi) 官方提供的插件开发框架, 以及技术指导
209
+ [koishijs](https://github.com/koishijs/koishi) 感谢官方提供的插件开发框架, 以及技术指导
210
+ [blive-message-listener](https://github.com/ddiu8081/blive-message-listener) 感谢 `ddiu8081` 提供简单方便的B站直播监听依赖
211
+ [bilibili-API-collect](https://github.com/SocialSisterYi/bilibili-API-collect) 感谢 `SocialSisterYi` 提供B站API参考
209
212
 
210
213
  ## License
211
214