floating-live 0.8.7 → 0.10.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 (56) hide show
  1. package/README.md +6 -4
  2. package/index.d.ts +7 -2
  3. package/index.js +23 -4
  4. package/package.json +1 -1
  5. package/plugin/acfun/acfunLive.d.ts +24 -30
  6. package/plugin/acfun/acfunLive.js +38 -51
  7. package/plugin/acfun/index.d.ts +1 -1
  8. package/plugin/acfun/index.js +1 -3
  9. package/plugin/bilibili/bilibiliLive.d.ts +7 -15
  10. package/plugin/bilibili/bilibiliLive.js +86 -117
  11. package/plugin/bilibili/index.d.ts +1 -1
  12. package/plugin/bilibili/index.js +1 -3
  13. package/plugin/chatPrint/chatPrint.d.ts +6 -7
  14. package/plugin/chatPrint/chatPrint.js +12 -18
  15. package/plugin/chatPrint/index.d.ts +2 -2
  16. package/plugin/chatPrint/index.js +2 -5
  17. package/plugin/consoleEvent/index.d.ts +1 -1
  18. package/plugin/consoleEvent/index.js +14 -2
  19. package/plugin/msgSave/index.d.ts +1 -1
  20. package/plugin/msgSave/index.js +6 -6
  21. package/plugin/msgSave/msgSave.d.ts +3 -3
  22. package/src/index.d.ts +51 -25
  23. package/src/index.js +98 -41
  24. package/src/lib/LiveRoom.d.ts +88 -0
  25. package/src/lib/LiveRoom.js +72 -0
  26. package/src/lib/{Registerable.d.ts → Reglist.d.ts} +6 -8
  27. package/src/lib/{Registerable.js → Reglist.js} +13 -19
  28. package/src/module/Command.d.ts +2 -0
  29. package/src/{types/room/RoomInfo.js → module/Command.js} +4 -0
  30. package/src/module/Plugin.d.ts +24 -0
  31. package/src/module/Plugin.js +74 -0
  32. package/src/{controller → module}/Room.d.ts +7 -13
  33. package/src/{controller → module}/Room.js +24 -16
  34. package/src/types/message/AttributeInfo.d.ts +8 -6
  35. package/src/types/message/MessageData.d.ts +132 -44
  36. package/src/types/plugin/Plugin.d.ts +4 -2
  37. package/src/types/room/PlatformInfo.d.ts +1 -1
  38. package/plugin/chat/ChatCommand.d.ts +0 -9
  39. package/plugin/chat/ChatCommand.js +0 -39
  40. package/plugin/chat/ChatFilter.d.ts +0 -9
  41. package/plugin/chat/ChatFilter.js +0 -44
  42. package/plugin/chat/chatProcessor.d.ts +0 -12
  43. package/plugin/chat/chatProcessor.js +0 -24
  44. package/src/controller/Message.d.ts +0 -9
  45. package/src/controller/Message.js +0 -15
  46. package/src/controller/index.d.ts +0 -39
  47. package/src/controller/index.js +0 -74
  48. package/src/types/message/MessageInfo.d.ts +0 -123
  49. package/src/types/message/MessageInfo.js +0 -2
  50. package/src/types/room/LiveInfo.d.ts +0 -24
  51. package/src/types/room/LiveInfo.js +0 -2
  52. package/src/types/room/LiveRoom.d.ts +0 -20
  53. package/src/types/room/LiveRoom.js +0 -2
  54. package/src/types/room/RoomInfo.d.ts +0 -16
  55. package/src/utils/getRoomInfo.d.ts +0 -4
  56. package/src/utils/getRoomInfo.js +0 -25
@@ -5,8 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const bilibili_live_ws_1 = require("bilibili-live-ws");
7
7
  const axios_1 = __importDefault(require("axios"));
8
- const events_1 = require("events");
9
- class bilibiliLive extends events_1.EventEmitter {
8
+ const LiveRoom_1 = require("../../src/lib/LiveRoom");
9
+ class bilibiliLive extends LiveRoom_1.LiveRoom {
10
10
  constructor(id, // 房间id
11
11
  open = false, // 生成房间后是否打开
12
12
  config) {
@@ -16,33 +16,30 @@ class bilibiliLive extends events_1.EventEmitter {
16
16
  /** 直播间room_id */
17
17
  this.roomid = 0;
18
18
  /** 直播信息 */
19
- this.live = {
19
+ this.base = {
20
20
  /** 直播标题 */
21
21
  title: "",
22
22
  /** 分区 */
23
23
  area: [],
24
24
  /** 封面url */
25
25
  cover: "",
26
- /** 直播状态 */
27
- status: "off",
28
- /** 开始直播时间 */
29
- start_time: 0
30
26
  };
31
- this.cover = "";
27
+ /** 房间是否可用 */
28
+ this.available = false;
29
+ /** 是否连接上房间 */
30
+ this.connected = false;
32
31
  /** 主播信息 */
33
32
  this.anchor = { name: "", id: 0 };
34
- /** 直播间是否可用 */
35
- this.available = false;
36
33
  /** 直播间弹幕api模块 */
37
34
  this.client = null;
38
- /** 是否为持续监听状态 */
39
- this.opening = false;
40
35
  this.id = id; // 直播间号
41
36
  this.connectInterval = config?.connectInterval || 100;
42
- this.getInfo().then(() => {
43
- if (open)
44
- this.open();
45
- });
37
+ if (open) {
38
+ this.open();
39
+ }
40
+ else {
41
+ this.getInfo();
42
+ }
46
43
  }
47
44
  /** 获取房间信息 */
48
45
  async getInfo() {
@@ -51,30 +48,28 @@ class bilibiliLive extends events_1.EventEmitter {
51
48
  .then((res) => {
52
49
  let data = res.data.data;
53
50
  this.roomid = data.room_info.room_id;
54
- this.live.status = data.room_info.live_status == 1 ? "live" : "off";
55
- this.live.start_time = this.live.status == "live" ? data.room_info.live_start_time * 1000 : 0;
56
- this.live.title = data.room_info.title;
51
+ this.status = data.room_info.live_status == 1 ? "live" : "off";
52
+ this.timestamp = this.status == "live" ? data.room_info.live_start_time * 1000 : 0;
53
+ this.base.title = data.room_info.title;
54
+ this.base.area = [data.room_info.parent_area_name, data.room_info.area_name];
55
+ this.base.cover = data.room_info.cover;
57
56
  this.anchor.id = data.room_info.uid;
58
57
  this.anchor.name = data.anchor_info.base_info.uname;
59
58
  this.anchor.avatar = data.anchor_info.base_info.face;
60
- this.live.area = [data.room_info.parent_area_name, data.room_info.area_name];
61
- this.cover = data.room_info.cover;
62
59
  this.available = true;
60
+ console.log("[bilibiliLive] 已获取房间信息");
61
+ this.emit("info", this.info);
63
62
  })
64
63
  .catch((error) => {
65
64
  console.error(error);
66
65
  });
67
- console.log("[bilibiliLive] 已获取房间信息");
68
- this.emit("info");
69
66
  }
70
67
  /** 开启直播间监听 */
71
68
  async open() {
69
+ await this.getInfo();
70
+ // 如果直播间监听已打开或直播间不可用,则返回
72
71
  if (this.opening || !this.available)
73
72
  return;
74
- if (!this.roomid) {
75
- console.log("[bilibili-live-ws] 未获取直播间room_id属性");
76
- return;
77
- }
78
73
  this.opening = true;
79
74
  this.createWS();
80
75
  this.emit("open");
@@ -120,23 +115,6 @@ class bilibiliLive extends events_1.EventEmitter {
120
115
  this.client?.close();
121
116
  this.emit("close");
122
117
  }
123
- destory() {
124
- this.close();
125
- this.removeAllListeners();
126
- }
127
- emitMsg(data) {
128
- // 一般消息
129
- this.emit("msg", data);
130
- }
131
- emitOrigin(data) {
132
- // 源消息
133
- this.emit("origin", data);
134
- }
135
- emitChange(data) {
136
- this.live = Object.assign(this.live, data);
137
- // 直播信息
138
- this.emit("change", data);
139
- }
140
118
  getDanmakuMode(n) {
141
119
  switch (n) {
142
120
  case 1:
@@ -151,74 +129,68 @@ class bilibiliLive extends events_1.EventEmitter {
151
129
  }
152
130
  /** 获取弹幕消息 */
153
131
  msg_DANMU_MSG(msg) {
154
- let text = msg.info[1];
132
+ let content = msg.info[1];
155
133
  let mode = this.getDanmakuMode(msg.info[0][1]);
156
134
  let color = msg.info[0][3];
157
135
  let uname = msg.info[2][1];
158
136
  let uid = msg.info[2][0];
159
137
  let timestamp = msg.info[0][4];
160
138
  let guard_level = msg.info[7]; // 舰长级别
139
+ let extra = JSON.parse(msg.info[0][15].extra);
161
140
  let medal = (msg.info[3].length) ? {
162
141
  level: msg.info[3][0],
163
142
  name: msg.info[3][1],
164
143
  // user: msg.info[3][2],
165
144
  id: msg.info[3][12],
166
- privilege: msg.info[3][10] || 0,
145
+ membership: msg.info[3][10] || 0,
167
146
  } : null;
168
- let admin = undefined;
147
+ let identity = null;
148
+ let emoticon = undefined;
149
+ if (extra.emots) {
150
+ emoticon = {};
151
+ for (let key in extra.emots) {
152
+ let emotItem = extra.emots[key];
153
+ emoticon[key] = {
154
+ id: emotItem.emoticon_unique,
155
+ url: emotItem.url,
156
+ name: emotItem.emoji,
157
+ };
158
+ }
159
+ }
160
+ console.log(extra.emots);
161
+ console.log(emoticon);
169
162
  if (msg.info[2][2]) {
170
- admin = 2;
163
+ identity = "admin";
171
164
  }
172
165
  else if (uid == this.anchor.id) {
173
- admin = 1;
166
+ identity = "anchor";
174
167
  }
175
- let danmaku;
176
- if (msg.info[0][12]) {
177
- danmaku = {
178
- platform: "bilibili",
179
- room: this.id,
180
- type: "image",
181
- local_timestamp: new Date().valueOf(),
182
- info: {
183
- timestamp: timestamp,
184
- mode: mode,
185
- image: {
186
- name: text,
187
- id: msg.info[0][13].emoticon_unique,
188
- url: msg.info[0][13].url,
189
- size: [msg.info[0][13].width, msg.info[0][13].height],
190
- },
191
- user: {
192
- name: uname,
193
- id: uid,
194
- medal: medal,
195
- privilege: guard_level,
196
- admin: admin,
197
- }
168
+ let danmaku = {
169
+ platform: "bilibili",
170
+ room: this.id,
171
+ type: "chat",
172
+ record_time: new Date().valueOf(),
173
+ info: {
174
+ timestamp: timestamp,
175
+ color: color,
176
+ mode: mode,
177
+ content: content,
178
+ image: msg.info[0][12] ? {
179
+ name: content,
180
+ id: msg.info[0][13].emoticon_unique,
181
+ url: msg.info[0][13].url,
182
+ height: msg.info[0][13].height / 3,
183
+ } : undefined,
184
+ emoticon: emoticon,
185
+ user: {
186
+ name: uname,
187
+ id: uid,
188
+ medal: medal,
189
+ membership: guard_level,
190
+ identity: identity,
198
191
  }
199
- };
200
- }
201
- else {
202
- danmaku = {
203
- platform: "bilibili",
204
- room: this.id,
205
- type: "text",
206
- local_timestamp: new Date().valueOf(),
207
- info: {
208
- timestamp: timestamp,
209
- text: text,
210
- color: color,
211
- mode: mode,
212
- user: {
213
- name: uname,
214
- id: uid,
215
- medal: medal,
216
- privilege: guard_level,
217
- admin: admin,
218
- }
219
- },
220
- };
221
- }
192
+ }
193
+ };
222
194
  this.emitMsg(danmaku);
223
195
  }
224
196
  /** 获取互动消息 */
@@ -242,7 +214,7 @@ class bilibiliLive extends events_1.EventEmitter {
242
214
  platform: "bilibili",
243
215
  room: this.id,
244
216
  type: type,
245
- local_timestamp: new Date().valueOf(),
217
+ record_time: new Date().valueOf(),
246
218
  info: {
247
219
  timestamp: Math.floor(data.trigger_time / 1000000),
248
220
  user: {
@@ -252,7 +224,7 @@ class bilibiliLive extends events_1.EventEmitter {
252
224
  level: data.fans_medal.medal_level,
253
225
  name: data.fans_medal.medal_name,
254
226
  id: data.fans_medal.target_id,
255
- privilege: data.fans_medal.guard_level,
227
+ membership: data.fans_medal.guard_level,
256
228
  } : null
257
229
  }
258
230
  },
@@ -266,7 +238,7 @@ class bilibiliLive extends events_1.EventEmitter {
266
238
  platform: "bilibili",
267
239
  room: this.id,
268
240
  type: "gift",
269
- local_timestamp: new Date().valueOf(),
241
+ record_time: new Date().valueOf(),
270
242
  info: {
271
243
  timestamp: data.timestamp * 1000,
272
244
  user: {
@@ -276,9 +248,9 @@ class bilibiliLive extends events_1.EventEmitter {
276
248
  level: data.fans_medal.medal_level,
277
249
  name: data.fans_medal.medal_name,
278
250
  id: data.fans_medal.target_id,
279
- privilege: data.fans_medal.guard_level,
251
+ membership: data.fans_medal.guard_level,
280
252
  } : null,
281
- privilege: data.guard_level,
253
+ membership: data.guard_level,
282
254
  avatar: data.face
283
255
  },
284
256
  gift: {
@@ -300,14 +272,14 @@ class bilibiliLive extends events_1.EventEmitter {
300
272
  let gift = {
301
273
  platform: "bilibili",
302
274
  room: this.id,
303
- type: "privilege",
304
- local_timestamp: new Date().valueOf(),
275
+ type: "membership",
276
+ record_time: new Date().valueOf(),
305
277
  info: {
306
278
  timestamp: data.start_time * 1000,
307
279
  user: {
308
280
  name: data.username,
309
281
  id: data.uid,
310
- privilege: data.guard_level,
282
+ membership: data.guard_level,
311
283
  },
312
284
  gift: {
313
285
  name: data.gift_name,
@@ -330,7 +302,7 @@ class bilibiliLive extends events_1.EventEmitter {
330
302
  platform: "bilibili",
331
303
  room: this.id,
332
304
  type: "superchat",
333
- local_timestamp: new Date().valueOf(),
305
+ record_time: new Date().valueOf(),
334
306
  info: {
335
307
  id: data.id,
336
308
  timestamp: data.ts * 1000,
@@ -342,11 +314,11 @@ class bilibiliLive extends events_1.EventEmitter {
342
314
  level: data.medal_info.medal_level,
343
315
  name: data.medal_info.medal_name,
344
316
  id: data.medal_info.target_id,
345
- privilege: data.medal_info.guard_level,
317
+ membership: data.medal_info.guard_level,
346
318
  } : null,
347
- privilege: data.user_info.guard_level,
319
+ membership: data.user_info.guard_level,
348
320
  },
349
- text: data.message,
321
+ content: data.message,
350
322
  color: data.background_bottom_color,
351
323
  duration: data.time * 1000,
352
324
  gift: {
@@ -367,14 +339,14 @@ class bilibiliLive extends events_1.EventEmitter {
367
339
  platform: "bilibili",
368
340
  room: this.id,
369
341
  type: "block",
370
- local_timestamp: new Date().valueOf(),
342
+ record_time: new Date().valueOf(),
371
343
  info: {
372
344
  user: {
373
345
  id: data.uid,
374
346
  name: data.uname
375
347
  },
376
348
  operator: {
377
- admin: data.operator == 2 ? 1 : 2
349
+ identity: data.operator == 2 ? "anchor" : "admin"
378
350
  }
379
351
  },
380
352
  };
@@ -387,12 +359,11 @@ class bilibiliLive extends events_1.EventEmitter {
387
359
  platform: "bilibili",
388
360
  room: this.id,
389
361
  type: "live_start",
390
- local_timestamp: new Date().valueOf(),
362
+ record_time: new Date().valueOf(),
391
363
  info: {
392
- start_time: msg.live_time * 1000,
364
+ timestamp: msg.live_time * 1000,
393
365
  },
394
366
  };
395
- this.emitChange({ status: "live" });
396
367
  this.emitMsg(live);
397
368
  }
398
369
  }
@@ -402,12 +373,11 @@ class bilibiliLive extends events_1.EventEmitter {
402
373
  platform: "bilibili",
403
374
  room: this.id,
404
375
  type: "live_cut",
405
- local_timestamp: new Date().valueOf(),
376
+ record_time: new Date().valueOf(),
406
377
  info: {
407
378
  message: msg.msg,
408
379
  },
409
380
  };
410
- this.emitChange({ status: "off" });
411
381
  this.emitMsg(cut);
412
382
  }
413
383
  msg_PREPARING(msg) {
@@ -415,12 +385,11 @@ class bilibiliLive extends events_1.EventEmitter {
415
385
  platform: "bilibili",
416
386
  room: this.id,
417
387
  type: "live_end",
418
- local_timestamp: new Date().valueOf(),
388
+ record_time: new Date().valueOf(),
419
389
  info: {
420
390
  status: msg.round ? "round" : "off"
421
391
  }
422
392
  };
423
- this.emitChange({ status: msg.round ? "round" : "off" });
424
393
  this.emitMsg(off);
425
394
  }
426
395
  msg_ROOM_CHANGE(msg) {
@@ -428,12 +397,12 @@ class bilibiliLive extends events_1.EventEmitter {
428
397
  platform: "bilibili",
429
398
  room: this.id,
430
399
  type: "live_change",
400
+ record_time: new Date().valueOf(),
431
401
  info: {
432
402
  title: msg.data.title,
433
403
  area: [msg.data.parent_area_name, msg.data.area_name]
434
404
  }
435
405
  };
436
- this.emitChange(change.info);
437
406
  this.emitMsg(change);
438
407
  }
439
408
  }
@@ -1,3 +1,3 @@
1
- import FloatingLive from "../../src/index";
1
+ import { FloatingLive } from "../../src/index";
2
2
  declare const _default: (ctx: FloatingLive) => void;
3
3
  export = _default;
@@ -5,8 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  const bilibiliLive_1 = __importDefault(require("./bilibiliLive"));
6
6
  module.exports = (ctx) => {
7
7
  ctx.helper.roomGenerator.register("bilibili", (id, open) => {
8
- let key = `bilibili:${Number(id)}`;
9
- let room = new bilibiliLive_1.default(Number(id), open);
10
- return { key, room };
8
+ return new bilibiliLive_1.default(Number(id), open);
11
9
  });
12
10
  };
@@ -1,11 +1,11 @@
1
- import FloatingLiving from "../..";
1
+ import { FloatingLive } from "../..";
2
2
  import { UserInfo } from "../../src/types/message/AttributeInfo";
3
- import { MessageType } from "../../src/types/message/MessageData";
4
- declare class chatPrint {
3
+ import { MessageData } from "../../src/types/message/MessageData";
4
+ export declare class chatPrint {
5
5
  /** 主模块 */
6
- main: FloatingLiving;
6
+ main: FloatingLive;
7
7
  hideType: Set<string>;
8
- constructor(main: FloatingLiving);
8
+ constructor(main: FloatingLive);
9
9
  /** 获取用户信息 */
10
10
  getUserInfo(message: {
11
11
  platform: string;
@@ -16,6 +16,5 @@ declare class chatPrint {
16
16
  /** 获取特权粉丝名称 */
17
17
  getPriviliegeName(platform: string, level: number | boolean): string | number | boolean;
18
18
  /** 记录在控制台上 */
19
- log(message: MessageType): void;
19
+ log(message: MessageData): void;
20
20
  }
21
- export default chatPrint;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.chatPrint = void 0;
3
4
  class chatPrint {
4
5
  constructor(main) {
5
6
  this.main = main;
@@ -12,9 +13,9 @@ class chatPrint {
12
13
  let user = message.info.user; // 用户信息
13
14
  let name = `${"\x1b[33m"}${user.name}`; // 用户名
14
15
  let medal = user.medal ? `${"\x1b[32m"}[${user.medal.name}(${user.medal.level})] ` : ""; // 粉丝牌
15
- let privilege = user.privilege ? `${"\x1b[36m"}[${this.getPriviliegeName(message.platform, user.privilege)}]` : ""; // 特权粉丝
16
- let admin = user.admin ? `${"\x1b[95m"}[${["", "主播", "房"][user.admin]}]` : ""; // 房管
17
- return `${medal}${privilege}${admin}${name}${"\x1b[0m"}`; //[粉丝牌(等级)] [特权][房管]用户名
16
+ let membership = user.membership ? `${"\x1b[36m"}[${this.getPriviliegeName(message.platform, user.membership)}]` : ""; // 特权粉丝
17
+ let identity = user.identity ? `${"\x1b[95m"}[${{ admin: "房管", anchor: "主播" }[user.identity]}]` : ""; // 房管
18
+ return `${medal}${membership}${identity}${name}${"\x1b[0m"}`; //[粉丝牌(等级)] [特权][房管]用户名
18
19
  }
19
20
  /** 获取特权粉丝名称 */
20
21
  getPriviliegeName(platform, level) {
@@ -31,16 +32,10 @@ class chatPrint {
31
32
  return;
32
33
  }
33
34
  switch (message.type) {
34
- case "text": {
35
+ case "chat": {
35
36
  let user = this.getUserInfo(message);
36
- let text = message.info.text;
37
- console.log(`${user}: ${text}`);
38
- break;
39
- }
40
- case "image": {
41
- let user = this.getUserInfo(message);
42
- let image = message.info.image.name || message.info.image.id;
43
- console.log(`${user}: [img]${image}`);
37
+ let content = message.info.content;
38
+ console.log(`${user}: ${message.info.image ? "[img]" : ""}${content}`);
44
39
  break;
45
40
  }
46
41
  case "like": {
@@ -56,17 +51,16 @@ class chatPrint {
56
51
  console.log(`${user}${"\x1b[0m"} ${action} ${"\x1b[40;33m"}${name} x${num}${"\x1b[0m"}`);
57
52
  break;
58
53
  }
59
- case "privilege": {
54
+ case "membership": {
60
55
  let user = this.getUserInfo(message);
61
56
  let name = message.info.name;
62
- let action = message.info.renew ? ["开通", "续费", "自动续费"][message.info.renew] : "开通";
63
- console.log(`${user}${"\x1b[1;31m"} ${action}了主播的${"\x1b[33m"}${name}${"\x1b[0m"}`);
57
+ console.log(`${user}${"\x1b[1;31m"} 开通了主播的${"\x1b[33m"}${name}${"\x1b[0m"}`);
64
58
  break;
65
59
  }
66
60
  case "superchat": {
67
61
  let user = this.getUserInfo(message);
68
62
  let second = Math.round(message.info.duration / 1000);
69
- console.log(`${"\x1b[1;36m"}SC(${second}s) ${user}${"\x1b[0m"}: ${message.info.text}`);
63
+ console.log(`${"\x1b[1;36m"}SC(${second}s) ${user}${"\x1b[0m"}: ${message.info.content}`);
70
64
  break;
71
65
  }
72
66
  case "entry": {
@@ -86,7 +80,7 @@ class chatPrint {
86
80
  }
87
81
  case "block": {
88
82
  let user = this.getUserInfo(message);
89
- let operator = message.info.operator.admin ? ["", "主播", "房管"][message.info.operator.admin] : "管理员";
83
+ let operator = message.info.operator.identity ? { admin: "房管", anchor: "主播" }[message.info.operator.identity] : "管理员";
90
84
  console.log(`${user} 已被${operator}禁言`);
91
85
  break;
92
86
  }
@@ -108,4 +102,4 @@ class chatPrint {
108
102
  }
109
103
  }
110
104
  }
111
- exports.default = chatPrint;
105
+ exports.chatPrint = chatPrint;
@@ -1,4 +1,4 @@
1
- import FloatingLive from "../../src";
2
- import chatPrint from "./chatPrint";
1
+ import { FloatingLive } from "../../src";
2
+ import { chatPrint } from "./chatPrint";
3
3
  declare const _default: (ctx: FloatingLive) => chatPrint;
4
4
  export = _default;
@@ -1,8 +1,5 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- const chatPrint_1 = __importDefault(require("./chatPrint"));
2
+ const chatPrint_1 = require("./chatPrint");
6
3
  module.exports = (ctx) => {
7
- return new chatPrint_1.default(ctx);
4
+ return new chatPrint_1.chatPrint(ctx);
8
5
  };
@@ -1,3 +1,3 @@
1
- import FloatingLive from "../../src";
1
+ import { FloatingLive } from "../../src";
2
2
  declare const _default: (ctx: FloatingLive) => void;
3
3
  export = _default;
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  module.exports = (ctx) => {
3
3
  ctx.on("start", () => {
4
- console.log(`[controller]记录已开始: ${ctx.controller.timestamp}`);
4
+ console.log(`[controller]记录已开始: ${ctx.timestamp}`);
5
5
  });
6
6
  ctx.on("end", () => {
7
- console.log(`[controller]记录已结束: ${ctx.controller.timestamp}`);
7
+ console.log(`[controller]记录已结束: ${ctx.timestamp}`);
8
8
  });
9
9
  ctx.on("room_connect", (key) => {
10
10
  console.log(`[${key}]已连接到直播服务器`);
@@ -36,4 +36,16 @@ module.exports = (ctx) => {
36
36
  ctx.on("room_unexist", (key) => {
37
37
  console.log(`[room]房间不存在: ${key}`);
38
38
  });
39
+ ctx.on("plugin_add", (name) => {
40
+ console.log(`[plugin]已添加插件: ${name}`);
41
+ });
42
+ ctx.on("plugin_remove", (name) => {
43
+ console.log(`[plugin]已移除插件: ${name}`);
44
+ });
45
+ ctx.on("plugin_unexist", (name) => {
46
+ console.log(`[plugin]插件不存在: ${name}`);
47
+ });
48
+ ctx.on("plugin_duplicate", (name) => {
49
+ console.log(`[plugin]插件名称重复: ${name}`);
50
+ });
39
51
  };
@@ -1,4 +1,4 @@
1
- import FloatingLive from "../../src";
1
+ import { FloatingLive } from "../../src";
2
2
  import msgSave from "../msgSave/msgSave";
3
3
  export declare const messageSave: (ctx: FloatingLive) => msgSave;
4
4
  export declare const messageSaveOrigin: (ctx: FloatingLive) => msgSave;
@@ -6,10 +6,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.messageSaveOrigin = exports.messageSave = void 0;
7
7
  const msgSave_1 = __importDefault(require("../msgSave/msgSave"));
8
8
  const messageSave = (ctx) => {
9
- let saveMessage = new msgSave_1.default(ctx, "live_message", `./save/undefined.txt`, ctx.controller.started);
9
+ let saveMessage = new msgSave_1.default(ctx, "live_message", `./save/undefined.txt`, ctx.started);
10
10
  ctx.on("start", () => {
11
- let startDate = new Date(ctx.controller.timestamp);
12
- let fileId = `${startDate.getFullYear()}${(startDate.getMonth() + 1).toString().padStart(2, '0')}${startDate.getDate().toString().padStart(2, '0')}_${startDate.getHours().toString().padStart(2, '0')}${startDate.getMinutes().toString().padStart(2, '0')}${startDate.getSeconds().toString().padStart(2, '0')}-${String(ctx.controller.room.keyList[0]).replace(":", "-")}`;
11
+ let startDate = new Date(ctx.timestamp);
12
+ let fileId = `${startDate.getFullYear()}${(startDate.getMonth() + 1).toString().padStart(2, '0')}${startDate.getDate().toString().padStart(2, '0')}_${startDate.getHours().toString().padStart(2, '0')}${startDate.getMinutes().toString().padStart(2, '0')}${startDate.getSeconds().toString().padStart(2, '0')}-${String(ctx.room.keyList[0]).replace(":", "-")}`;
13
13
  saveMessage.changeFile(`./save/${fileId}.txt`);
14
14
  saveMessage.start();
15
15
  });
@@ -18,10 +18,10 @@ const messageSave = (ctx) => {
18
18
  };
19
19
  exports.messageSave = messageSave;
20
20
  const messageSaveOrigin = (ctx) => {
21
- let saveOrigin = new msgSave_1.default(ctx, "live_origin", `./save/undefined-origin.txt`, ctx.controller.started);
21
+ let saveOrigin = new msgSave_1.default(ctx, "live_origin", `./save/undefined-origin.txt`, ctx.started);
22
22
  ctx.on("start", () => {
23
- let startDate = new Date(ctx.controller.timestamp);
24
- let fileId = `${startDate.getFullYear()}${(startDate.getMonth() + 1).toString().padStart(2, '0')}${startDate.getDate().toString().padStart(2, '0')}_${startDate.getHours().toString().padStart(2, '0')}${startDate.getMinutes().toString().padStart(2, '0')}${startDate.getSeconds().toString().padStart(2, '0')}-${String(ctx.controller.room.keyList[0]).replace(":", "-")}`;
23
+ let startDate = new Date(ctx.timestamp);
24
+ let fileId = `${startDate.getFullYear()}${(startDate.getMonth() + 1).toString().padStart(2, '0')}${startDate.getDate().toString().padStart(2, '0')}_${startDate.getHours().toString().padStart(2, '0')}${startDate.getMinutes().toString().padStart(2, '0')}${startDate.getSeconds().toString().padStart(2, '0')}-${String(ctx.room.keyList[0]).replace(":", "-")}`;
25
25
  saveOrigin.changeFile(`./save/${fileId}-origin.txt`);
26
26
  saveOrigin.start();
27
27
  });
@@ -1,13 +1,13 @@
1
- import FloatingLiving from "../..";
1
+ import { FloatingLive } from "../..";
2
2
  declare class msgSave {
3
3
  /** 主模块 */
4
- main: FloatingLiving;
4
+ main: FloatingLive;
5
5
  file: string;
6
6
  config: object;
7
7
  type: string;
8
8
  paused: boolean;
9
9
  listener: (msg: any) => void;
10
- constructor(main: FloatingLiving, type: string, file: string, open?: boolean, config?: {
10
+ constructor(main: FloatingLive, type: string, file: string, open?: boolean, config?: {
11
11
  encoding: string;
12
12
  flag: string;
13
13
  });