koishi-plugin-bilibili-notify 3.0.0-alpha.21 → 3.0.0-alpha.23

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.d.ts CHANGED
@@ -26,21 +26,7 @@ declare class BiliAPI extends Service {
26
26
  }): Promise<string>;
27
27
  encrypt(text: string): string;
28
28
  decrypt(text: string): string;
29
- getTheUserWhoIsLiveStreaming(): Promise<{
30
- count: number;
31
- group: string;
32
- items: [
33
- {
34
- face: string;
35
- is_reserve_recall: boolean;
36
- jump_url: string;
37
- mid: number;
38
- room_id: number;
39
- title: string;
40
- uname: string;
41
- }
42
- ];
43
- }>;
29
+ getTheUserWhoIsLiveStreaming(): Promise<any>;
44
30
  getLiveRoomInfoStreamKey(roomId: string): Promise<any>;
45
31
  getServerUTCTime(): Promise<number>;
46
32
  getTimeNow(): Promise<any>;
package/lib/biliAPI.js CHANGED
@@ -120,9 +120,9 @@ class BiliAPI extends koishi_1.Service {
120
120
  // BA API
121
121
  async getTheUserWhoIsLiveStreaming() {
122
122
  // 获取直播间信息流密钥
123
- const { data: { live_users }, } = await this.client.get(GET_LATEST_UPDATED_UPS);
123
+ const { data } = await this.client.get(GET_LATEST_UPDATED_UPS);
124
124
  // 返回data
125
- return live_users;
125
+ return data;
126
126
  }
127
127
  async getLiveRoomInfoStreamKey(roomId) {
128
128
  // 获取直播间信息流密钥
package/lib/blive.js CHANGED
@@ -33,7 +33,7 @@ class BLive extends koishi_1.Service {
33
33
  },
34
34
  });
35
35
  // logger
36
- this.logger.info(`${roomId}直播间弹幕监听已开启`);
36
+ this.logger.info(`${roomId}直播间监听已开启`);
37
37
  }
38
38
  closeListener(roomId) {
39
39
  // 判断直播间监听器是否关闭
@@ -213,6 +213,40 @@ class ComRegister {
213
213
  // 发送提示
214
214
  await session.send("已发送消息,如未收到则说明您的机器人不支持发送私聊消息或您的信息填写有误");
215
215
  });
216
+ biliCom
217
+ .subcommand(".ll")
218
+ .usage("展示当前正在直播的订阅对象")
219
+ .example("bili ll")
220
+ .action(async () => {
221
+ // 获取liveUsers
222
+ const { data: { live_users }, } = (await ctx.ba.getTheUserWhoIsLiveStreaming());
223
+ // 定义当前正在直播且订阅的UP主列表
224
+ const subLiveUsers = [];
225
+ // 获取当前订阅的UP主
226
+ for (const sub of this.subManager) {
227
+ // 定义开播标志位
228
+ let onLive = false;
229
+ // 遍历liveUsers
230
+ for (const user of live_users.items) {
231
+ // 判断是否是订阅直播的UP
232
+ if (user.mid.toString() === sub.uid && sub.live) {
233
+ // 设置标志位为true
234
+ onLive = true;
235
+ // break
236
+ break;
237
+ }
238
+ }
239
+ // 判断是否未开播
240
+ subLiveUsers.push({ uid: Number.parseInt(sub.uid), uname: sub.uname, onLive });
241
+ }
242
+ // 定义table字符串
243
+ let table = "";
244
+ // 遍历liveUsers
245
+ for (const user of subLiveUsers) {
246
+ table += `[UID:${user.uid}] 「${user.uname}」 ${user.onLive ? '正在直播' : '未开播'}\n`;
247
+ }
248
+ return table;
249
+ });
216
250
  }
217
251
  async init(config) {
218
252
  // 设置logger
@@ -1372,6 +1406,7 @@ class ComRegister {
1372
1406
  this.subManager.push({
1373
1407
  id: +sub.uid,
1374
1408
  uid: sub.uid,
1409
+ uname: data.name,
1375
1410
  roomId: sub.live ? data.live_room.roomid : "",
1376
1411
  target: sub.target,
1377
1412
  platform: "",
package/lib/index.js CHANGED
@@ -154,7 +154,7 @@ class ServerManager extends koishi_1.Service {
154
154
  hideDesc: globalConfig.hideDesc,
155
155
  enableLargeFont: globalConfig.enableLargeFont,
156
156
  font: globalConfig.font,
157
- followerDisplay: globalConfig.followerDisplay
157
+ followerDisplay: globalConfig.followerDisplay,
158
158
  });
159
159
  // CR = ComRegister
160
160
  const cr = this.ctx.plugin(comRegister_1.default, {
@@ -303,17 +303,30 @@ exports.Config = koishi_1.Schema.object({
303
303
  dynamic: koishi_1.Schema.boolean().default(false).description("是否订阅用户动态"),
304
304
  live: koishi_1.Schema.boolean().default(false).description("是否订阅用户直播"),
305
305
  target: koishi_1.Schema.array(koishi_1.Schema.object({
306
+ platform: koishi_1.Schema.string()
307
+ .required()
308
+ .description("推送平台,例如onebot、qq、discord"),
306
309
  channelIdArr: koishi_1.Schema.array(koishi_1.Schema.object({
307
310
  channelId: koishi_1.Schema.string().required().description("频道/群组号"),
308
- dynamic: koishi_1.Schema.boolean().default(false).description("该频道/群组是否推送动态信息"),
309
- live: koishi_1.Schema.boolean().default(false).description("该频道/群组是否推送直播通知"),
310
- liveGuardBuy: koishi_1.Schema.boolean().default(false).description("该频道/群组是否推送上舰消息"),
311
- atAll: koishi_1.Schema.boolean().default(false).description("推送开播通知时是否艾特全体成员"),
312
- })).description("需推送的频道/群组详细设置"),
313
- platform: koishi_1.Schema.string().required().description("推送平台,例如onebot、qq、discord"),
311
+ dynamic: koishi_1.Schema.boolean()
312
+ .default(false)
313
+ .description("该频道/群组是否推送动态信息"),
314
+ live: koishi_1.Schema.boolean()
315
+ .default(false)
316
+ .description("该频道/群组是否推送直播通知"),
317
+ liveGuardBuy: koishi_1.Schema.boolean()
318
+ .default(false)
319
+ .description("该频道/群组是否推送上舰消息"),
320
+ atAll: koishi_1.Schema.boolean()
321
+ .default(false)
322
+ .description("推送开播通知时是否艾特全体成员"),
323
+ }))
324
+ .role("table")
325
+ .required()
326
+ .description("需推送的频道/群组详细设置"),
314
327
  })).description("订阅用户需要发送的平台和频道/群组信息(一个平台下可以推送多个频道/群组)"),
315
- }))
316
- .role("table")
328
+ }).collapse())
329
+ .collapse()
317
330
  .description("输入订阅信息,自定义订阅内容; uid: 订阅用户UID,dynamic: 是否需要订阅动态,live: 是否需要订阅直播"),
318
331
  dynamic: koishi_1.Schema.object({}).description("动态推送设置"),
319
332
  dynamicUrl: koishi_1.Schema.boolean()
@@ -20,6 +20,7 @@ export type Target = Array<TargetItem>;
20
20
  export type SubItem = {
21
21
  id: number;
22
22
  uid: string;
23
+ uname: string;
23
24
  roomId: string;
24
25
  target: Target;
25
26
  platform: string;
@@ -35,3 +36,17 @@ export type MasterInfo = {
35
36
  liveEndFollowerNum: number;
36
37
  liveFollowerChange: number;
37
38
  };
39
+ export type LiveUsersItem = {
40
+ face: string;
41
+ is_reserve_recall: boolean;
42
+ jump_url: string;
43
+ mid: number;
44
+ room_id: number;
45
+ title: string;
46
+ uname: string;
47
+ };
48
+ export type LiveUsers = {
49
+ count: number;
50
+ group: string;
51
+ items: Array<LiveUsersItem>;
52
+ };
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.21",
4
+ "version": "3.0.0-alpha.23",
5
5
  "contributors": [
6
6
  "Akokko <admin@akokko.com>"
7
7
  ],
package/readme.md CHANGED
@@ -59,6 +59,10 @@
59
59
 
60
60
  - 使用指令 `bili list`
61
61
 
62
+ 查看目前订阅直播的UP主们的直播情况:
63
+
64
+ - 使用指令 `bili ll`
65
+
62
66
  插件的启动、停止和重启
63
67
 
64
68
  - 使用指令 `sys`
@@ -201,6 +205,8 @@
201
205
  - ver 3.0.0-alpha.19 修复:开播提示语粉丝数单位错误; 优化:订阅配置中所有配置项改为必填项
202
206
  - ver 3.0.0-alpha.20 优化:订阅配置中开关选项默认为关闭
203
207
  - ver 3.0.0-alpha.21 优化:部分代码; 新增:更新插件后,由于机器人还未启动,已开始发送消息报错 `this._request is not a function` ,新增报错后自动重新发送消息的功能
208
+ - ver 3.0.0-alpha.22 优化:订阅配置展示优化
209
+ - ver 3.0.0-alpha.23 新增:指令 `bili ll` 可以查看当前订阅直播的UP主们的开播情况
204
210
 
205
211
  ## 交流群
206
212