koishi-plugin-bilibili-notify 3.0.0-alpha.0 → 3.0.0-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/blive.d.ts CHANGED
@@ -7,12 +7,11 @@ declare module 'koishi' {
7
7
  }
8
8
  declare class BLive extends Service {
9
9
  static inject: string[];
10
- private blConfig;
11
10
  private listenerRecord;
12
11
  private timerRecord;
13
- constructor(ctx: Context, config: BLive.Config);
12
+ constructor(ctx: Context);
14
13
  protected stop(): Awaitable<void>;
15
- startLiveRoomListener(roomId: string, handler: MsgHandler, danmakuPushTime: () => void): Promise<void>;
14
+ startLiveRoomListener(roomId: string, handler: MsgHandler, pushOnceEveryTens: () => void): Promise<void>;
16
15
  closeListener(roomId: string): void;
17
16
  }
18
17
  declare namespace BLive {
package/lib/blive.js CHANGED
@@ -5,16 +5,11 @@ const blive_message_listener_1 = require("blive-message-listener");
5
5
  class BLive extends koishi_1.Service {
6
6
  // 必要服务
7
7
  static inject = ['ba'];
8
- // 配置
9
- blConfig;
10
8
  // 定义类属性
11
9
  listenerRecord = {};
12
10
  timerRecord = {};
13
- constructor(ctx, config) {
14
- // Extends super
11
+ constructor(ctx) {
15
12
  super(ctx, 'bl');
16
- // 将config赋值给类属性
17
- this.blConfig = config;
18
13
  }
19
14
  // 注册插件dispose逻辑
20
15
  stop() {
@@ -23,7 +18,7 @@ class BLive extends koishi_1.Service {
23
18
  this.closeListener(key);
24
19
  }
25
20
  }
26
- async startLiveRoomListener(roomId, handler, danmakuPushTime) {
21
+ async startLiveRoomListener(roomId, handler, pushOnceEveryTens) {
27
22
  // 获取cookieStr
28
23
  const cookiesStr = await this.ctx.ba.getCookiesForHeader();
29
24
  // 获取自身信息
@@ -38,20 +33,18 @@ class BLive extends koishi_1.Service {
38
33
  }
39
34
  });
40
35
  // 默认30s推送一次弹幕消息到群组并将dispose函数保存到Record中
41
- this.timerRecord[roomId] = this.ctx.setInterval(danmakuPushTime, this.blConfig.danmakuPushTime * 1000 * 60);
42
- // logger
43
- this.logger.info(`${roomId}直播间弹幕监听已开启`);
36
+ this.timerRecord[roomId] = this.ctx.setInterval(pushOnceEveryTens, this.config.danmakuPushTime * 1000 * 60);
44
37
  }
45
38
  closeListener(roomId) {
46
39
  // 判断直播间监听器是否关闭
47
40
  if (!this.listenerRecord || !this.listenerRecord[roomId] || !this.listenerRecord[roomId].closed) {
48
41
  // 输出logger
49
- this.logger.info(`${roomId}直播间弹幕监听器无需关闭`);
42
+ this.logger.info('直播间监听器无需关闭');
50
43
  }
51
44
  // 判断消息发送定时器是否关闭
52
45
  if (!this.timerRecord || !this.timerRecord[roomId]) {
53
46
  // 输出logger
54
- this.logger.info(`${roomId}直播间消息发送定时器无需关闭`);
47
+ this.logger.info('消息发送定时器无需关闭');
55
48
  }
56
49
  // 关闭直播间监听器
57
50
  this.listenerRecord[roomId].close();
@@ -64,12 +57,12 @@ class BLive extends koishi_1.Service {
64
57
  // 删除消息发送定时器
65
58
  delete this.timerRecord[roomId];
66
59
  // 输出logger
67
- this.logger.info(`${roomId}直播间弹幕监听已关闭`);
60
+ this.logger.info('直播间监听已关闭');
68
61
  // 直接返回
69
62
  return;
70
63
  }
71
64
  // 未关闭成功
72
- this.logger.warn(`${roomId}直播间弹幕监听未成功关闭`);
65
+ this.logger.warn('直播间监听未成功关闭');
73
66
  }
74
67
  }
75
68
  // eslint-disable-next-line @typescript-eslint/no-namespace
@@ -11,7 +11,6 @@ type ChannelIdArr = Array<{
11
11
  channelId: string;
12
12
  dynamic: boolean;
13
13
  live: boolean;
14
- liveDanmaku: boolean;
15
14
  atAll: boolean;
16
15
  }>;
17
16
  type TargetItem = {
@@ -27,6 +26,7 @@ type SubItem = {
27
26
  platform: string;
28
27
  live: boolean;
29
28
  dynamic: boolean;
29
+ liveDispose: Function;
30
30
  };
31
31
  type SubManager = Array<SubItem>;
32
32
  declare class ComRegister {
@@ -38,52 +38,50 @@ declare class ComRegister {
38
38
  num: number;
39
39
  rebootCount: number;
40
40
  subNotifier: Notifier;
41
- ctx: Context;
42
41
  subManager: SubManager;
43
42
  loginDBData: FlatPick<LoginBili, "dynamic_group_id">;
44
43
  privateBot: Bot<Context>;
45
44
  dynamicDispose: Function;
46
45
  sendMsgFunc: (bot: Bot<Context, any>, channelId: string, content: any) => Promise<void>;
47
46
  constructor(ctx: Context, config: ComRegister.Config);
48
- init(config: ComRegister.Config): Promise<void>;
47
+ init(ctx: Context, config: ComRegister.Config): Promise<void>;
49
48
  splitMultiPlatformStr(str: string): Target;
50
- getBot(pf: string): Bot<Context, any>;
49
+ getBot(ctx: Context, pf: string): Bot<Context, any>;
51
50
  sendPrivateMsg(content: string): Promise<void>;
52
- sendPrivateMsgAndRebootService(): Promise<void>;
53
- sendPrivateMsgAndStopService(): Promise<void>;
54
- sendMsg(targets: Target, content: any, live?: boolean): Promise<void>;
55
- dynamicDetect(): () => Promise<void>;
56
- debug_dynamicDetect(): () => Promise<void>;
57
- sendLiveNotifyCard(info: {
51
+ sendPrivateMsgAndRebootService(ctx: Context): Promise<void>;
52
+ sendPrivateMsgAndStopService(ctx: Context): Promise<void>;
53
+ sendMsg(ctx: Context, targets: Target, content: any, live?: boolean): Promise<void>;
54
+ dynamicDetect(ctx: Context): () => Promise<void>;
55
+ debug_dynamicDetect(ctx: Context): () => Promise<void>;
56
+ sendLiveNotifyCard(ctx: Context, info: {
58
57
  username: string;
59
58
  userface: string;
60
59
  target: Target;
61
60
  data: any;
62
61
  }, liveType: LiveType, liveNotifyMsg?: string): Promise<void>;
63
- useMasterInfo(uid: string): Promise<{
62
+ useMasterInfo(ctx: Context, uid: string): Promise<{
64
63
  username: string;
65
64
  userface: string;
66
- roomId: number;
67
65
  }>;
68
- useLiveRoomInfo(roomId: string): Promise<any>;
69
- liveDetectWithAPI(): Promise<() => Promise<void>>;
70
- liveDetectWithListener(roomId: string, target: Target): Promise<void>;
66
+ useLiveRoomInfo(ctx: Context, roomId: string): Promise<any>;
67
+ liveDetectWithAPI(ctx: Context): Promise<() => Promise<void>>;
68
+ liveDetectWithListener(ctx: Context, roomId: string, target: Target): void;
71
69
  subShow(): string;
72
70
  checkIfNeedSub(liveSub: boolean, dynamicSub: boolean, session: Session, liveRoomData: any): Promise<Array<boolean>>;
73
- updateSubNotifier(): void;
74
- checkIfLoginInfoIsLoaded(): Promise<unknown>;
75
- subUserInBili(mid: string): Promise<{
71
+ updateSubNotifier(ctx: Context): void;
72
+ checkIfLoginInfoIsLoaded(ctx: Context): Promise<unknown>;
73
+ subUserInBili(ctx: Context, mid: string): Promise<{
76
74
  flag: boolean;
77
75
  msg: string;
78
76
  }>;
79
- loadSubFromConfig(subs: ComRegister.Config["sub"]): Promise<void>;
80
- loadSubFromDatabase(): Promise<void>;
81
- checkIfDynamicDetectIsNeeded(): void;
82
- enableDynamicDetect(): void;
83
- unsubSingle(id: string, type: number): string;
77
+ loadSubFromConfig(ctx: Context, subs: ComRegister.Config["sub"]): Promise<void>;
78
+ loadSubFromDatabase(ctx: Context): Promise<void>;
79
+ checkIfDynamicDetectIsNeeded(ctx: Context): void;
80
+ enableDynamicDetect(ctx: Context): void;
81
+ unsubSingle(ctx: Context, id: string, type: number): string;
84
82
  checkIfUserIsTheLastOneWhoSubDyn(): void;
85
- unsubAll(uid: string): void;
86
- checkIfIsLogin(): Promise<boolean>;
83
+ unsubAll(ctx: Context, uid: string): void;
84
+ checkIfIsLogin(ctx: Context): Promise<boolean>;
87
85
  }
88
86
  declare namespace ComRegister {
89
87
  interface Config {
@@ -96,7 +94,6 @@ declare namespace ComRegister {
96
94
  channelId: string;
97
95
  dynamic: boolean;
98
96
  live: boolean;
99
- liveDanmaku: boolean;
100
97
  atAll: boolean;
101
98
  }>;
102
99
  platform: string;
@@ -110,6 +107,7 @@ declare namespace ComRegister {
110
107
  };
111
108
  unlockSubLimits: boolean;
112
109
  automaticResend: boolean;
110
+ changeMasterInfoApi: boolean;
113
111
  restartPush: boolean;
114
112
  pushTime: number;
115
113
  liveLoopTime: number;