floating-live 0.8.7 → 0.9.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.
- package/README.md +6 -4
- package/index.d.ts +7 -2
- package/index.js +23 -4
- package/package.json +1 -1
- package/plugin/acfun/acfunLive.d.ts +5 -10
- package/plugin/acfun/acfunLive.js +18 -35
- package/plugin/acfun/index.d.ts +1 -1
- package/plugin/acfun/index.js +1 -3
- package/plugin/bilibili/bilibiliLive.d.ts +7 -15
- package/plugin/bilibili/bilibiliLive.js +67 -114
- package/plugin/bilibili/index.d.ts +1 -1
- package/plugin/bilibili/index.js +1 -3
- package/plugin/chatPrint/chatPrint.d.ts +6 -7
- package/plugin/chatPrint/chatPrint.js +11 -17
- package/plugin/chatPrint/index.d.ts +2 -2
- package/plugin/chatPrint/index.js +2 -5
- package/plugin/consoleEvent/index.d.ts +1 -1
- package/plugin/consoleEvent/index.js +14 -2
- package/plugin/msgSave/index.d.ts +1 -1
- package/plugin/msgSave/index.js +6 -6
- package/plugin/msgSave/msgSave.d.ts +3 -3
- package/src/index.d.ts +51 -25
- package/src/index.js +98 -41
- package/src/lib/LiveRoom.d.ts +88 -0
- package/src/lib/LiveRoom.js +72 -0
- package/src/lib/{Registerable.d.ts → Reglist.d.ts} +6 -8
- package/src/lib/{Registerable.js → Reglist.js} +13 -19
- package/src/module/Command.d.ts +2 -0
- package/src/{types/room/RoomInfo.js → module/Command.js} +4 -0
- package/src/module/Plugin.d.ts +24 -0
- package/src/module/Plugin.js +74 -0
- package/src/{controller → module}/Room.d.ts +7 -13
- package/src/{controller → module}/Room.js +24 -16
- package/src/types/message/AttributeInfo.d.ts +4 -4
- package/src/types/message/MessageData.d.ts +125 -43
- package/src/types/plugin/Plugin.d.ts +4 -2
- package/src/types/room/PlatformInfo.d.ts +1 -1
- package/plugin/chat/ChatCommand.d.ts +0 -9
- package/plugin/chat/ChatCommand.js +0 -39
- package/plugin/chat/ChatFilter.d.ts +0 -9
- package/plugin/chat/ChatFilter.js +0 -44
- package/plugin/chat/chatProcessor.d.ts +0 -12
- package/plugin/chat/chatProcessor.js +0 -24
- package/src/controller/Message.d.ts +0 -9
- package/src/controller/Message.js +0 -15
- package/src/controller/index.d.ts +0 -39
- package/src/controller/index.js +0 -74
- package/src/types/message/MessageInfo.d.ts +0 -123
- package/src/types/message/MessageInfo.js +0 -2
- package/src/types/room/LiveInfo.d.ts +0 -24
- package/src/types/room/LiveInfo.js +0 -2
- package/src/types/room/LiveRoom.d.ts +0 -20
- package/src/types/room/LiveRoom.js +0 -2
- package/src/types/room/RoomInfo.d.ts +0 -16
- package/src/utils/getRoomInfo.d.ts +0 -4
- 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
|
|
9
|
-
class bilibiliLive extends
|
|
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.
|
|
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
|
-
|
|
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
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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.
|
|
55
|
-
this.
|
|
56
|
-
this.
|
|
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,7 +129,7 @@ class bilibiliLive extends events_1.EventEmitter {
|
|
|
151
129
|
}
|
|
152
130
|
/** 获取弹幕消息 */
|
|
153
131
|
msg_DANMU_MSG(msg) {
|
|
154
|
-
let
|
|
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];
|
|
@@ -163,7 +141,7 @@ class bilibiliLive extends events_1.EventEmitter {
|
|
|
163
141
|
name: msg.info[3][1],
|
|
164
142
|
// user: msg.info[3][2],
|
|
165
143
|
id: msg.info[3][12],
|
|
166
|
-
|
|
144
|
+
membership: msg.info[3][10] || 0,
|
|
167
145
|
} : null;
|
|
168
146
|
let admin = undefined;
|
|
169
147
|
if (msg.info[2][2]) {
|
|
@@ -172,53 +150,31 @@ class bilibiliLive extends events_1.EventEmitter {
|
|
|
172
150
|
else if (uid == this.anchor.id) {
|
|
173
151
|
admin = 1;
|
|
174
152
|
}
|
|
175
|
-
let danmaku
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
}
|
|
153
|
+
let danmaku = {
|
|
154
|
+
platform: "bilibili",
|
|
155
|
+
room: this.id,
|
|
156
|
+
type: "chat",
|
|
157
|
+
record_time: new Date().valueOf(),
|
|
158
|
+
info: {
|
|
159
|
+
timestamp: timestamp,
|
|
160
|
+
color: color,
|
|
161
|
+
mode: mode,
|
|
162
|
+
content: content,
|
|
163
|
+
image: msg.info[0][12] ? {
|
|
164
|
+
name: content,
|
|
165
|
+
id: msg.info[0][13].emoticon_unique,
|
|
166
|
+
url: msg.info[0][13].url,
|
|
167
|
+
size: [msg.info[0][13].width, msg.info[0][13].height],
|
|
168
|
+
} : undefined,
|
|
169
|
+
user: {
|
|
170
|
+
name: uname,
|
|
171
|
+
id: uid,
|
|
172
|
+
medal: medal,
|
|
173
|
+
membership: guard_level,
|
|
174
|
+
admin: admin,
|
|
198
175
|
}
|
|
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
|
-
}
|
|
176
|
+
}
|
|
177
|
+
};
|
|
222
178
|
this.emitMsg(danmaku);
|
|
223
179
|
}
|
|
224
180
|
/** 获取互动消息 */
|
|
@@ -242,7 +198,7 @@ class bilibiliLive extends events_1.EventEmitter {
|
|
|
242
198
|
platform: "bilibili",
|
|
243
199
|
room: this.id,
|
|
244
200
|
type: type,
|
|
245
|
-
|
|
201
|
+
record_time: new Date().valueOf(),
|
|
246
202
|
info: {
|
|
247
203
|
timestamp: Math.floor(data.trigger_time / 1000000),
|
|
248
204
|
user: {
|
|
@@ -252,7 +208,7 @@ class bilibiliLive extends events_1.EventEmitter {
|
|
|
252
208
|
level: data.fans_medal.medal_level,
|
|
253
209
|
name: data.fans_medal.medal_name,
|
|
254
210
|
id: data.fans_medal.target_id,
|
|
255
|
-
|
|
211
|
+
membership: data.fans_medal.guard_level,
|
|
256
212
|
} : null
|
|
257
213
|
}
|
|
258
214
|
},
|
|
@@ -266,7 +222,7 @@ class bilibiliLive extends events_1.EventEmitter {
|
|
|
266
222
|
platform: "bilibili",
|
|
267
223
|
room: this.id,
|
|
268
224
|
type: "gift",
|
|
269
|
-
|
|
225
|
+
record_time: new Date().valueOf(),
|
|
270
226
|
info: {
|
|
271
227
|
timestamp: data.timestamp * 1000,
|
|
272
228
|
user: {
|
|
@@ -276,9 +232,9 @@ class bilibiliLive extends events_1.EventEmitter {
|
|
|
276
232
|
level: data.fans_medal.medal_level,
|
|
277
233
|
name: data.fans_medal.medal_name,
|
|
278
234
|
id: data.fans_medal.target_id,
|
|
279
|
-
|
|
235
|
+
membership: data.fans_medal.guard_level,
|
|
280
236
|
} : null,
|
|
281
|
-
|
|
237
|
+
membership: data.guard_level,
|
|
282
238
|
avatar: data.face
|
|
283
239
|
},
|
|
284
240
|
gift: {
|
|
@@ -300,14 +256,14 @@ class bilibiliLive extends events_1.EventEmitter {
|
|
|
300
256
|
let gift = {
|
|
301
257
|
platform: "bilibili",
|
|
302
258
|
room: this.id,
|
|
303
|
-
type: "
|
|
304
|
-
|
|
259
|
+
type: "membership",
|
|
260
|
+
record_time: new Date().valueOf(),
|
|
305
261
|
info: {
|
|
306
262
|
timestamp: data.start_time * 1000,
|
|
307
263
|
user: {
|
|
308
264
|
name: data.username,
|
|
309
265
|
id: data.uid,
|
|
310
|
-
|
|
266
|
+
membership: data.guard_level,
|
|
311
267
|
},
|
|
312
268
|
gift: {
|
|
313
269
|
name: data.gift_name,
|
|
@@ -330,7 +286,7 @@ class bilibiliLive extends events_1.EventEmitter {
|
|
|
330
286
|
platform: "bilibili",
|
|
331
287
|
room: this.id,
|
|
332
288
|
type: "superchat",
|
|
333
|
-
|
|
289
|
+
record_time: new Date().valueOf(),
|
|
334
290
|
info: {
|
|
335
291
|
id: data.id,
|
|
336
292
|
timestamp: data.ts * 1000,
|
|
@@ -342,11 +298,11 @@ class bilibiliLive extends events_1.EventEmitter {
|
|
|
342
298
|
level: data.medal_info.medal_level,
|
|
343
299
|
name: data.medal_info.medal_name,
|
|
344
300
|
id: data.medal_info.target_id,
|
|
345
|
-
|
|
301
|
+
membership: data.medal_info.guard_level,
|
|
346
302
|
} : null,
|
|
347
|
-
|
|
303
|
+
membership: data.user_info.guard_level,
|
|
348
304
|
},
|
|
349
|
-
|
|
305
|
+
content: data.message,
|
|
350
306
|
color: data.background_bottom_color,
|
|
351
307
|
duration: data.time * 1000,
|
|
352
308
|
gift: {
|
|
@@ -367,14 +323,14 @@ class bilibiliLive extends events_1.EventEmitter {
|
|
|
367
323
|
platform: "bilibili",
|
|
368
324
|
room: this.id,
|
|
369
325
|
type: "block",
|
|
370
|
-
|
|
326
|
+
record_time: new Date().valueOf(),
|
|
371
327
|
info: {
|
|
372
328
|
user: {
|
|
373
329
|
id: data.uid,
|
|
374
330
|
name: data.uname
|
|
375
331
|
},
|
|
376
332
|
operator: {
|
|
377
|
-
|
|
333
|
+
identity: data.operator == 2 ? "anchor" : "admin"
|
|
378
334
|
}
|
|
379
335
|
},
|
|
380
336
|
};
|
|
@@ -387,12 +343,11 @@ class bilibiliLive extends events_1.EventEmitter {
|
|
|
387
343
|
platform: "bilibili",
|
|
388
344
|
room: this.id,
|
|
389
345
|
type: "live_start",
|
|
390
|
-
|
|
346
|
+
record_time: new Date().valueOf(),
|
|
391
347
|
info: {
|
|
392
|
-
|
|
348
|
+
timestamp: msg.live_time * 1000,
|
|
393
349
|
},
|
|
394
350
|
};
|
|
395
|
-
this.emitChange({ status: "live" });
|
|
396
351
|
this.emitMsg(live);
|
|
397
352
|
}
|
|
398
353
|
}
|
|
@@ -402,12 +357,11 @@ class bilibiliLive extends events_1.EventEmitter {
|
|
|
402
357
|
platform: "bilibili",
|
|
403
358
|
room: this.id,
|
|
404
359
|
type: "live_cut",
|
|
405
|
-
|
|
360
|
+
record_time: new Date().valueOf(),
|
|
406
361
|
info: {
|
|
407
362
|
message: msg.msg,
|
|
408
363
|
},
|
|
409
364
|
};
|
|
410
|
-
this.emitChange({ status: "off" });
|
|
411
365
|
this.emitMsg(cut);
|
|
412
366
|
}
|
|
413
367
|
msg_PREPARING(msg) {
|
|
@@ -415,12 +369,11 @@ class bilibiliLive extends events_1.EventEmitter {
|
|
|
415
369
|
platform: "bilibili",
|
|
416
370
|
room: this.id,
|
|
417
371
|
type: "live_end",
|
|
418
|
-
|
|
372
|
+
record_time: new Date().valueOf(),
|
|
419
373
|
info: {
|
|
420
374
|
status: msg.round ? "round" : "off"
|
|
421
375
|
}
|
|
422
376
|
};
|
|
423
|
-
this.emitChange({ status: msg.round ? "round" : "off" });
|
|
424
377
|
this.emitMsg(off);
|
|
425
378
|
}
|
|
426
379
|
msg_ROOM_CHANGE(msg) {
|
|
@@ -428,12 +381,12 @@ class bilibiliLive extends events_1.EventEmitter {
|
|
|
428
381
|
platform: "bilibili",
|
|
429
382
|
room: this.id,
|
|
430
383
|
type: "live_change",
|
|
384
|
+
record_time: new Date().valueOf(),
|
|
431
385
|
info: {
|
|
432
386
|
title: msg.data.title,
|
|
433
387
|
area: [msg.data.parent_area_name, msg.data.area_name]
|
|
434
388
|
}
|
|
435
389
|
};
|
|
436
|
-
this.emitChange(change.info);
|
|
437
390
|
this.emitMsg(change);
|
|
438
391
|
}
|
|
439
392
|
}
|
package/plugin/bilibili/index.js
CHANGED
|
@@ -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
|
-
|
|
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
|
|
1
|
+
import { FloatingLive } from "../..";
|
|
2
2
|
import { UserInfo } from "../../src/types/message/AttributeInfo";
|
|
3
|
-
import {
|
|
4
|
-
declare class chatPrint {
|
|
3
|
+
import { MessageData } from "../../src/types/message/MessageData";
|
|
4
|
+
export declare class chatPrint {
|
|
5
5
|
/** 主模块 */
|
|
6
|
-
main:
|
|
6
|
+
main: FloatingLive;
|
|
7
7
|
hideType: Set<string>;
|
|
8
|
-
constructor(main:
|
|
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:
|
|
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
|
|
16
|
-
let
|
|
17
|
-
return `${medal}${
|
|
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 "
|
|
35
|
+
case "chat": {
|
|
35
36
|
let user = this.getUserInfo(message);
|
|
36
|
-
let
|
|
37
|
-
console.log(`${user}: ${
|
|
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,11 +51,10 @@ 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 "
|
|
54
|
+
case "membership": {
|
|
60
55
|
let user = this.getUserInfo(message);
|
|
61
56
|
let name = message.info.name;
|
|
62
|
-
|
|
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": {
|
|
@@ -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.
|
|
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.
|
|
105
|
+
exports.chatPrint = chatPrint;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
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.
|
|
4
|
+
return new chatPrint_1.chatPrint(ctx);
|
|
8
5
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
module.exports = (ctx) => {
|
|
3
3
|
ctx.on("start", () => {
|
|
4
|
-
console.log(`[controller]记录已开始: ${ctx.
|
|
4
|
+
console.log(`[controller]记录已开始: ${ctx.timestamp}`);
|
|
5
5
|
});
|
|
6
6
|
ctx.on("end", () => {
|
|
7
|
-
console.log(`[controller]记录已结束: ${ctx.
|
|
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
|
};
|
package/plugin/msgSave/index.js
CHANGED
|
@@ -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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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
|
|
1
|
+
import { FloatingLive } from "../..";
|
|
2
2
|
declare class msgSave {
|
|
3
3
|
/** 主模块 */
|
|
4
|
-
main:
|
|
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:
|
|
10
|
+
constructor(main: FloatingLive, type: string, file: string, open?: boolean, config?: {
|
|
11
11
|
encoding: string;
|
|
12
12
|
flag: string;
|
|
13
13
|
});
|