floating-live 0.12.0 → 0.13.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.
Files changed (63) hide show
  1. package/README.md +7 -8
  2. package/index.d.ts +3 -3
  3. package/index.js +3 -3
  4. package/package.json +4 -2
  5. package/plugin/acfun/acfunLive.d.ts +3 -3
  6. package/plugin/acfun/acfunLive.js +10 -10
  7. package/plugin/acfun/index.d.ts +1 -0
  8. package/plugin/acfun/index.js +3 -2
  9. package/plugin/bilibili/index.d.ts +1 -0
  10. package/plugin/bilibili/index.js +17 -4
  11. package/plugin/bilibili/parser.d.ts +6 -0
  12. package/plugin/bilibili/{bilibiliLive.js → parser.js} +132 -231
  13. package/plugin/bilibili/room.d.ts +77 -0
  14. package/plugin/bilibili/room.js +261 -0
  15. package/plugin/bilibili/types.d.ts +424 -0
  16. package/plugin/bilibili/utils.d.ts +16 -0
  17. package/plugin/bilibili/utils.js +140 -0
  18. package/plugin/chatPrint/chatPrint.d.ts +2 -2
  19. package/plugin/chatPrint/chatPrint.js +16 -6
  20. package/plugin/chatPrint/index.d.ts +1 -0
  21. package/plugin/chatPrint/index.js +2 -1
  22. package/plugin/consoleEvent/index.d.ts +1 -0
  23. package/plugin/consoleEvent/index.js +16 -21
  24. package/plugin/msgSave/index.d.ts +3 -1
  25. package/plugin/msgSave/index.js +25 -30
  26. package/plugin/msgSave/msgSave.d.ts +5 -5
  27. package/plugin/msgSave/msgSave.js +25 -9
  28. package/src/abstract/LiveRoom.d.ts +44 -0
  29. package/src/{lib → abstract}/LiveRoom.js +12 -7
  30. package/src/enum.d.ts +4 -2
  31. package/src/enum.js +9 -7
  32. package/src/index.d.ts +13 -37
  33. package/src/index.js +12 -74
  34. package/src/module/ModAuth.d.ts +8 -0
  35. package/src/module/ModAuth.js +14 -0
  36. package/src/module/ModCommand.d.ts +3 -0
  37. package/src/module/ModCommand.js +6 -0
  38. package/src/module/ModMessage.d.ts +9 -0
  39. package/src/module/ModMessage.js +12 -0
  40. package/src/module/{Plugin.d.ts → ModPlugin.d.ts} +2 -6
  41. package/src/module/{Plugin.js → ModPlugin.js} +20 -18
  42. package/src/module/ModRooms.d.ts +36 -0
  43. package/src/module/{Room.js → ModRooms.js} +50 -31
  44. package/src/types/index.d.ts +1 -2
  45. package/src/types/index.js +1 -2
  46. package/src/types/message.d.ts +210 -0
  47. package/src/types/plugin.d.ts +4 -5
  48. package/src/types/room.d.ts +48 -2
  49. package/src/utils.d.ts +2 -0
  50. package/src/{tool.js → utils.js} +4 -4
  51. package/test/type/bilibili_getInfoByRoom.d.ts +492 -0
  52. package/plugin/bilibili/bilibiliLive.d.ts +0 -58
  53. package/src/lib/LiveRoom.d.ts +0 -89
  54. package/src/module/Command.d.ts +0 -3
  55. package/src/module/Command.js +0 -6
  56. package/src/module/Room.d.ts +0 -26
  57. package/src/tool.d.ts +0 -2
  58. package/src/types/message/AttributeInfo.d.ts +0 -67
  59. package/src/types/message/MessageData.d.ts +0 -166
  60. /package/{src/types/message/AttributeInfo.js → plugin/bilibili/types.js} +0 -0
  61. /package/src/{lib → abstract}/Reglist.d.ts +0 -0
  62. /package/src/{lib → abstract}/Reglist.js +0 -0
  63. /package/src/types/{message/MessageData.js → message.js} +0 -0
@@ -1,157 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const __1 = require("../..");
4
- const bilibili_live_ws_1 = require("bilibili-live-ws");
5
- const __2 = require("../..");
3
+ exports.parseInfo = exports.parseMessage = void 0;
4
+ const enum_1 = require("../../src/enum");
5
+ const utils_1 = require("../../src/utils");
6
6
  // utils
7
7
  // 获取当前时间戳,以替代无法从数据中获取时间戳的情况,精度为1s
8
8
  function getDateTimestamp() {
9
9
  return Math.floor(Date.now() / 1000) * 1000;
10
10
  }
11
- function getRoomStatus(s) {
12
- switch (s) {
13
- case 1:
14
- return __1.RoomStatus.live;
15
- case 2:
16
- return __1.RoomStatus.round;
17
- default:
18
- return __1.RoomStatus.off;
19
- }
20
- }
21
- class bilibiliLive extends __2.LiveRoom {
22
- constructor(id, // 房间id
23
- open = false, // 生成房间后是否打开
24
- config) {
25
- super();
26
- /** 平台id */
27
- this.platform = "bilibili";
28
- /** 直播间room_id */
29
- this.roomid = 0;
30
- /** 房间信息 */
31
- this.detail = {
32
- /** 直播标题 */
33
- title: "",
34
- /** 分区 */
35
- area: [],
36
- /** 封面url */
37
- cover: "",
38
- };
39
- this.stats = {
40
- /** 观看数 */
41
- watch: 0,
42
- /** 点赞数 */
43
- like: 0,
44
- };
45
- /** 房间是否可用 */
46
- this.available = false;
47
- /** 是否连接上房间 */
48
- this.connected = false;
49
- /** 主播信息 */
50
- this.anchor = { name: "", id: 0 };
51
- /** 直播间弹幕api模块 */
52
- this.client = null;
53
- this.id = id; // 直播间号
54
- this.connectInterval = config?.connectInterval || 100;
55
- if (open) {
56
- this.open();
57
- }
58
- else {
59
- this.getInfo();
60
- }
61
- }
62
- /** 获取房间信息 */
63
- async getInfo() {
64
- await fetch(`https://api.live.bilibili.com/xlive/web-room/v1/index/getInfoByRoom?room_id=${this.id}`, {
65
- method: "GET",
66
- }) // 获取直播间信息
67
- .then((response) => response.json())
68
- .then((res) => {
69
- const { room_info, anchor_info, like_info_v3, watched_show } = res.data;
70
- this.roomid = room_info.room_id;
71
- this.status = room_info.lock_status
72
- ? __1.RoomStatus.banned
73
- : getRoomStatus(room_info.live_status);
74
- this.timestamp =
75
- this.status == __1.RoomStatus.live
76
- ? room_info.live_start_time * 1000
77
- : this.timestamp;
78
- this.detail.title = room_info.title;
79
- this.detail.area = [room_info.parent_area_name, room_info.area_name];
80
- this.detail.cover = room_info.cover;
81
- this.stats.watch = watched_show.num;
82
- this.stats.like = like_info_v3.total_likes;
83
- this.anchor.id = room_info.uid;
84
- this.anchor.name = anchor_info.base_info.uname;
85
- this.anchor.avatar = anchor_info.base_info.face;
86
- this.liveId = room_info.live_id_str;
87
- this.available = true;
88
- console.log("[bilibiliLive] 已获取房间信息");
89
- this.emit("info", this.info);
90
- })
91
- .catch((error) => {
92
- console.error(error);
93
- });
94
- }
95
- /** 开启直播间监听 */
96
- async open() {
97
- // 如果直播间监听已打开,则返回
98
- if (this.opening)
99
- return;
100
- await this.getInfo();
101
- // 如果直播间不可用,则返回
102
- if (!this.available)
103
- return;
104
- this.opening = true;
105
- this.createWS();
106
- this.emit("open");
107
- }
108
- /** 连接直播服务端 */
109
- async createWS() {
110
- // 与Websocket服务器连接
111
- console.log("[bilibili-live-ws] 开始连接bilibili直播服务器");
112
- this.client = new bilibili_live_ws_1.KeepLiveWS(this.roomid, { uid: this.anchor.id });
113
- let client = this.client;
114
- client.interval = this.connectInterval;
115
- client.on("open", () => {
116
- console.log("[bilibili-live-ws] 已连接bilibili直播服务器");
117
- this.emit("connect");
118
- });
119
- client.on("close", () => {
120
- console.log("[bilibili-live-ws] 与bilibili直播服务器的连接已关闭");
121
- this.emit("disconnect");
122
- });
123
- client.on("live", () => {
124
- console.log("[bilibili-live-ws] 目标房间连接成功");
125
- });
126
- client.on("msg", (data) => {
127
- this.emitOrigin(data);
128
- });
129
- client.on("DANMU_MSG", this.msg_DANMU_MSG.bind(this));
130
- //client.on("ENTRY_EFFECT", this.msg_ENTRY_EFFECT.bind(this));
131
- client.on("INTERACT_WORD", this.msg_INTERACT_WORD.bind(this));
132
- client.on("SEND_GIFT", this.msg_SEND_GIFT.bind(this));
133
- client.on("GUARD_BUY", this.msg_GUARD_BUY.bind(this));
134
- //client.on('COMBO_SEND', this.msg_COMBO_SEND.bind(this))
135
- client.on("ROOM_BLOCK_MSG", this.msg_ROOM_BLOCK_MSG.bind(this));
136
- client.on("SUPER_CHAT_MESSAGE", this.msg_SUPER_CHAT_MESSAGE.bind(this));
137
- client.on("CUT_OFF", this.msg_CUT_OFF.bind(this));
138
- client.on("PREPARING", this.msg_PREPARING.bind(this));
139
- client.on("LIVE", this.msg_LIVE.bind(this));
140
- client.on("ROOM_CHANGE", this.msg_ROOM_CHANGE.bind(this));
141
- client.on("WATCHED_CHANGE", this.msg_WATCHED_CHANGE.bind(this));
142
- client.on("LIKE_INFO_V3_UPDATE", this.msg_LIKE_INFO_V3_UPDATE.bind(this));
143
- client.on("ONLINE_RANK_COUNT", this.msg_ONLINE_RANK_COUNT.bind(this));
144
- }
145
- /** 关闭直播间监听 */
146
- close() {
147
- if (!this.opening)
148
- return;
149
- this.opening = false;
150
- this.client?.close();
151
- this.emit("close");
152
- }
153
- /** 获取弹幕消息 */
154
- msg_DANMU_MSG(msg) {
11
+ const parseFunction = {
12
+ DANMU_MSG: (msg, room) => {
155
13
  const { info, msg_id } = msg;
156
14
  let content = info[1];
157
15
  let mode = info[0][1];
@@ -161,7 +19,7 @@ class bilibiliLive extends __2.LiveRoom {
161
19
  let timestamp = info[0][4];
162
20
  let guard_level = info[7]; // 舰长级别
163
21
  let extra = JSON.parse(info[0][15].extra);
164
- let medal = info[3].length
22
+ let medal = info[3][0] != null
165
23
  ? {
166
24
  level: info[3][0],
167
25
  name: info[3][1],
@@ -170,7 +28,7 @@ class bilibiliLive extends __2.LiveRoom {
170
28
  membership: info[3][10] || 0,
171
29
  }
172
30
  : null;
173
- let identity = null;
31
+ let identity = 0;
174
32
  let emoticon = undefined;
175
33
  if (extra.emots) {
176
34
  emoticon = {};
@@ -184,14 +42,14 @@ class bilibiliLive extends __2.LiveRoom {
184
42
  }
185
43
  }
186
44
  if (info[2][2]) {
187
- identity = __1.UserAdmin.admin;
45
+ identity = enum_1.UserType.admin;
188
46
  }
189
- else if (uid == this.anchor.id) {
190
- identity = __1.UserAdmin.anchor;
47
+ else if (uid === room?.anchor.id) {
48
+ identity = enum_1.UserType.anchor;
191
49
  }
192
50
  let danmaku = {
193
51
  platform: "bilibili",
194
- room: this.id,
52
+ room: room?.id || 0,
195
53
  type: "chat",
196
54
  timestamp: timestamp,
197
55
  id: msg_id,
@@ -205,8 +63,8 @@ class bilibiliLive extends __2.LiveRoom {
205
63
  id: info[0][13].emoticon_unique,
206
64
  url: info[0][13].url,
207
65
  size: info[0][13].width == info[0][13].height
208
- ? __1.ImageSize.large
209
- : __1.ImageSize.small,
66
+ ? enum_1.ImageSize.large
67
+ : enum_1.ImageSize.small,
210
68
  }
211
69
  : undefined,
212
70
  emoticon: emoticon,
@@ -215,14 +73,14 @@ class bilibiliLive extends __2.LiveRoom {
215
73
  id: uid,
216
74
  medal: medal,
217
75
  membership: guard_level,
218
- admin: identity,
76
+ type: identity,
219
77
  },
220
78
  },
221
79
  };
222
- this.emitMsg(danmaku);
223
- }
224
- /** 获取互动消息 */
225
- msg_INTERACT_WORD(msg) {
80
+ danmaku.id ?? (danmaku.id = (0, utils_1.generateId)(danmaku));
81
+ return danmaku;
82
+ },
83
+ INTERACT_WORD: (msg, room) => {
226
84
  const { data, msg_id, send_time } = msg;
227
85
  let type;
228
86
  switch (data.msg_type) {
@@ -240,10 +98,10 @@ class bilibiliLive extends __2.LiveRoom {
240
98
  }
241
99
  let interact = {
242
100
  platform: "bilibili",
243
- room: this.id,
101
+ room: room?.id || 0,
244
102
  type: type,
245
103
  id: msg_id,
246
- timestamp: send_time,
104
+ timestamp: send_time || Math.floor(data.trigger_time / 1000000),
247
105
  info: {
248
106
  user: {
249
107
  name: data.uname,
@@ -259,17 +117,17 @@ class bilibiliLive extends __2.LiveRoom {
259
117
  },
260
118
  },
261
119
  };
262
- this.emitMsg(interact);
263
- }
264
- /** 获取礼物消息 */
265
- msg_SEND_GIFT(msg) {
120
+ interact.id ?? (interact.id = (0, utils_1.generateId)(interact));
121
+ return interact;
122
+ },
123
+ SEND_GIFT: (msg, room) => {
266
124
  const { data, msg_id, send_time } = msg;
267
125
  let gift = {
268
126
  platform: "bilibili",
269
- room: this.id,
127
+ room: room?.id || 0,
270
128
  type: "gift",
271
- id: msg_id,
272
- timestamp: send_time,
129
+ id: msg_id || data.combo_id,
130
+ timestamp: send_time || data.timestamp * 1000,
273
131
  info: {
274
132
  user: {
275
133
  name: data.uname,
@@ -296,17 +154,17 @@ class bilibiliLive extends __2.LiveRoom {
296
154
  },
297
155
  },
298
156
  };
299
- this.emitMsg(gift);
300
- }
301
- /** 获取舰长开通消息 */
302
- msg_GUARD_BUY(msg) {
157
+ gift.id ?? (gift.id = (0, utils_1.generateId)(gift));
158
+ return gift;
159
+ },
160
+ GUARD_BUY: (msg, room) => {
303
161
  const { data, msg_id, send_time } = msg;
304
162
  let gift = {
305
163
  platform: "bilibili",
306
- room: this.id,
164
+ room: room?.id || 0,
307
165
  type: "membership",
308
166
  id: msg_id,
309
- timestamp: send_time,
167
+ timestamp: send_time || data.start_time * 1000,
310
168
  info: {
311
169
  user: {
312
170
  name: data.username,
@@ -325,17 +183,17 @@ class bilibiliLive extends __2.LiveRoom {
325
183
  duration: data.num * 30,
326
184
  },
327
185
  };
328
- this.emitMsg(gift);
329
- }
330
- /** 获取醒目留言消息 */
331
- msg_SUPER_CHAT_MESSAGE(msg) {
186
+ gift.id ?? (gift.id = (0, utils_1.generateId)(gift));
187
+ return gift;
188
+ },
189
+ SUPER_CHAT_MESSAGE: (msg, room) => {
332
190
  const { data, msg_id, send_time } = msg;
333
191
  let sc = {
334
192
  platform: "bilibili",
335
- room: this.id,
193
+ room: room?.id || 0,
336
194
  type: "superchat",
337
195
  id: msg_id,
338
- timestamp: send_time,
196
+ timestamp: send_time || data.ts * 1000,
339
197
  info: {
340
198
  id: data.id,
341
199
  user: {
@@ -364,133 +222,176 @@ class bilibiliLive extends __2.LiveRoom {
364
222
  },
365
223
  },
366
224
  };
367
- this.emitMsg(sc);
368
- }
369
- /** 观看数变化 */
370
- msg_WATCHED_CHANGE(msg) {
225
+ sc.id ?? (sc.id = (0, utils_1.generateId)(sc));
226
+ return sc;
227
+ },
228
+ WATCHED_CHANGE: (msg, room) => {
371
229
  const { data, msg_id, send_time } = msg;
372
230
  const stats = {
373
231
  platform: "bilibili",
374
- room: this.id,
232
+ room: room?.id || 0,
375
233
  type: "live_stats",
376
234
  id: msg_id,
377
- timestamp: send_time,
235
+ timestamp: send_time || getDateTimestamp(),
378
236
  info: {
379
237
  watch: data.num,
380
238
  },
381
239
  };
382
- this.emitMsg(stats);
383
- }
384
- /** 点赞数变化 */
385
- msg_LIKE_INFO_V3_UPDATE(msg) {
240
+ stats.id ?? (stats.id = (0, utils_1.generateId)(stats));
241
+ return stats;
242
+ },
243
+ LIKE_INFO_V3_UPDATE: (msg, room) => {
386
244
  const { data, msg_id, send_time } = msg;
387
245
  const stats = {
388
246
  platform: "bilibili",
389
- room: this.id,
247
+ room: room?.id || 0,
390
248
  type: "live_stats",
391
249
  id: msg_id,
392
- timestamp: send_time,
250
+ timestamp: send_time || getDateTimestamp(),
393
251
  info: {
394
252
  like: data.click_count,
395
253
  },
396
254
  };
397
- this.emitMsg(stats);
398
- }
399
- msg_ONLINE_RANK_COUNT(msg) {
255
+ stats.id ?? (stats.id = (0, utils_1.generateId)(stats));
256
+ return stats;
257
+ },
258
+ ONLINE_RANK_COUNT: (msg, room) => {
400
259
  const { data, msg_id, send_time } = msg;
260
+ if (data.online_count == null)
261
+ return;
401
262
  const stats = {
402
263
  platform: "bilibili",
403
- room: this.id,
264
+ room: room?.id || 0,
404
265
  type: "live_stats",
405
266
  id: msg_id,
406
- timestamp: send_time,
267
+ timestamp: send_time || getDateTimestamp(),
407
268
  info: {
408
- online: data.count,
269
+ online: data.online_count,
409
270
  },
410
271
  };
411
- this.emitMsg(stats);
412
- }
413
- msg_ROOM_BLOCK_MSG(msg) {
414
- // 禁言
272
+ stats.id ?? (stats.id = (0, utils_1.generateId)(stats));
273
+ return stats;
274
+ },
275
+ ROOM_BLOCK_MSG: (msg, room) => {
415
276
  const { data, msg_id, send_time } = msg;
416
277
  const block = {
417
278
  platform: "bilibili",
418
- room: this.id,
279
+ room: room?.id || 0,
419
280
  type: "block",
420
281
  id: msg_id,
421
- timestamp: send_time,
282
+ timestamp: send_time || getDateTimestamp(),
422
283
  info: {
423
284
  user: {
424
285
  id: data.uid,
425
286
  name: data.uname,
426
287
  },
427
288
  operator: {
428
- admin: data.operator == 2 ? __1.UserAdmin.anchor : __1.UserAdmin.admin,
289
+ type: data.operator == 2 ? enum_1.UserType.anchor : enum_1.UserType.admin,
429
290
  },
430
291
  },
431
292
  };
432
- this.emitMsg(block);
433
- }
434
- msg_LIVE(msg) {
435
- const { data, msg_id, send_time } = msg;
293
+ block.id ?? (block.id = (0, utils_1.generateId)(block));
294
+ return block;
295
+ },
296
+ LIVE: (msg, room) => {
297
+ const { msg_id, send_time } = msg;
436
298
  // 直播间开播
437
299
  if (msg.live_time) {
438
300
  let live = {
439
301
  platform: "bilibili",
440
- room: this.id,
302
+ room: room?.id || 0,
441
303
  type: "live_start",
442
304
  id: msg_id,
443
- timestamp: send_time,
305
+ timestamp: send_time || msg.live_time * 1000,
444
306
  info: {
445
307
  id: msg.live_key.toString(),
446
308
  },
447
309
  };
448
- this.emitMsg(live);
310
+ live.id ?? (live.id = (0, utils_1.generateId)(live));
311
+ return live;
449
312
  }
450
- }
451
- msg_CUT_OFF(msg) {
313
+ },
314
+ CUT_OFF: (msg, room) => {
452
315
  const { msg_id, send_time } = msg;
453
316
  // 直播间被切断
454
317
  let cut = {
455
318
  platform: "bilibili",
456
- room: this.id,
319
+ room: room?.id || 0,
457
320
  type: "live_cut",
458
321
  id: msg_id,
459
- timestamp: send_time,
322
+ timestamp: send_time || getDateTimestamp(),
460
323
  info: {
461
324
  message: msg.msg,
462
325
  },
463
326
  };
464
- this.emitMsg(cut);
465
- }
466
- msg_PREPARING(msg) {
327
+ cut.id ?? (cut.id = (0, utils_1.generateId)(cut));
328
+ return cut;
329
+ },
330
+ PREPARING: (msg, room) => {
467
331
  const { msg_id, send_time } = msg;
468
332
  let off = {
469
333
  platform: "bilibili",
470
- room: this.id,
334
+ room: room?.id || 0,
471
335
  type: "live_end",
472
336
  id: msg_id,
473
- timestamp: send_time,
337
+ timestamp: send_time || getDateTimestamp(),
474
338
  info: {
475
- status: msg.round ? __1.RoomStatus.round : __1.RoomStatus.off,
339
+ status: msg.round ? enum_1.RoomStatus.round : enum_1.RoomStatus.off,
476
340
  },
477
341
  };
478
- this.emitMsg(off);
479
- }
480
- msg_ROOM_CHANGE(msg) {
342
+ off.id ?? (off.id = (0, utils_1.generateId)(off));
343
+ return off;
344
+ },
345
+ ROOM_CHANGE: (msg, room) => {
481
346
  const { data, msg_id, send_time } = msg;
482
347
  let change = {
483
348
  platform: "bilibili",
484
- room: this.id,
349
+ room: room?.id || 0,
485
350
  type: "live_detail",
486
351
  id: msg_id,
487
- timestamp: send_time,
352
+ timestamp: send_time || getDateTimestamp(),
488
353
  info: {
489
354
  title: data.title,
490
355
  area: [data.parent_area_name, data.area_name],
491
356
  },
492
357
  };
493
- this.emitMsg(change);
494
- }
358
+ change.id ?? (change.id = (0, utils_1.generateId)(change));
359
+ return change;
360
+ },
361
+ };
362
+ /** 转换bilibili直播弹幕为floating通用格式 */
363
+ function parseMessage(data, room) {
364
+ return parseFunction[data.cmd](data, room);
365
+ }
366
+ exports.parseMessage = parseMessage;
367
+ function parseInfo(data) {
368
+ const { room_info, anchor_info, like_info_v3, watched_show } = data;
369
+ return {
370
+ platform: "bilibili",
371
+ id: room_info.room_id,
372
+ key: `bilibili:${room_info.room_id}`,
373
+ detail: {
374
+ title: room_info.title,
375
+ area: [room_info.parent_area_name, room_info.area_name],
376
+ cover: room_info.cover,
377
+ },
378
+ anchor: {
379
+ id: room_info.uid,
380
+ name: anchor_info.base_info.uname,
381
+ avatar: anchor_info.base_info.face,
382
+ },
383
+ stats: {
384
+ watch: watched_show.num,
385
+ like: like_info_v3.total_likes,
386
+ },
387
+ liveId: room_info.live_id_str,
388
+ available: true,
389
+ status: room_info.lock_status ? enum_1.RoomStatus.banned : room_info.live_status,
390
+ timestamp: room_info.live_status == enum_1.RoomStatus.live
391
+ ? room_info.live_start_time * 1000
392
+ : 0,
393
+ opened: false,
394
+ connected: false,
395
+ };
495
396
  }
496
- exports.default = bilibiliLive;
397
+ exports.parseInfo = parseInfo;
@@ -0,0 +1,77 @@
1
+ import { UserInfo } from "../..";
2
+ import { KeepLiveWS } from "bilibili-live-ws";
3
+ import { RoomStatsInfo, RoomDetail } from "../..";
4
+ import { RawMessage } from "./types";
5
+ import { LiveRoom } from "../../src/abstract/LiveRoom";
6
+ declare class RoomBilibili extends LiveRoom {
7
+ #private;
8
+ /** 平台id */
9
+ readonly platform: string;
10
+ /** 直播间号 */
11
+ readonly id: number;
12
+ /** 直播间room_id */
13
+ roomid: number;
14
+ /** 房间信息 */
15
+ detail: RoomDetail;
16
+ stats: RoomStatsInfo;
17
+ /** 房间是否可用 */
18
+ available: boolean;
19
+ /** 是否连接上房间 */
20
+ connected: boolean;
21
+ /** 主播信息 */
22
+ anchor: UserInfo;
23
+ /** 直播间弹幕api模块 */
24
+ client: KeepLiveWS | null;
25
+ /** 断线重连间隔 */
26
+ connectInterval: number;
27
+ private userId;
28
+ private buvid;
29
+ private token;
30
+ /** 是否处于正在打开的状态 */
31
+ private opening;
32
+ constructor(
33
+ /** 房间id */
34
+ id: number,
35
+ /** 生成房间后是否打开 */
36
+ open?: boolean,
37
+ /** 配置项 */
38
+ config?: {
39
+ /** 登录凭据 */
40
+ auth?: string;
41
+ /** 断线重连间隔(默认值为100ms) */
42
+ connectInterval?: number;
43
+ });
44
+ /** 获取房间信息 */
45
+ getInfo(): Promise<void>;
46
+ /** 开启直播间监听 */
47
+ open(): Promise<void>;
48
+ /** 设置登录凭据 */
49
+ setAuth(auth: string): void;
50
+ /** 初始化登录凭据 */
51
+ private initAuth;
52
+ /** 连接直播服务端 */
53
+ createWS(): void;
54
+ /** 关闭直播间监听 */
55
+ close(): void;
56
+ /** 获取弹幕消息 */
57
+ msg_DANMU_MSG(msg: RawMessage.DANMU_MSG): void;
58
+ /** 获取互动消息 */
59
+ msg_INTERACT_WORD(msg: RawMessage.INTERACT_WORD): void;
60
+ /** 获取礼物消息 */
61
+ msg_SEND_GIFT(msg: RawMessage.SEND_GIFT): void;
62
+ /** 获取舰长开通消息 */
63
+ msg_GUARD_BUY(msg: RawMessage.GUARD_BUY): void;
64
+ /** 获取醒目留言消息 */
65
+ msg_SUPER_CHAT_MESSAGE(msg: RawMessage.SUPER_CHAT_MESSAGE): void;
66
+ /** 观看数变化 */
67
+ msg_WATCHED_CHANGE(msg: RawMessage.WATCHED_CHANGE): void;
68
+ /** 点赞数变化 */
69
+ msg_LIKE_INFO_V3_UPDATE(msg: RawMessage.LIKE_INFO_V3_UPDATE): void;
70
+ msg_ONLINE_RANK_COUNT(msg: RawMessage.ONLINE_RANK_COUNT): void;
71
+ msg_ROOM_BLOCK_MSG(msg: RawMessage.ROOM_BLOCK_MSG): void;
72
+ msg_LIVE(msg: RawMessage.LIVE): void;
73
+ msg_CUT_OFF(msg: RawMessage.CUT_OFF): void;
74
+ msg_PREPARING(msg: RawMessage.PREPARING): void;
75
+ msg_ROOM_CHANGE(msg: RawMessage.ROOM_CHANGE): void;
76
+ }
77
+ export default RoomBilibili;