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.
- 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 +24 -30
- package/plugin/acfun/acfunLive.js +38 -51
- 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 +86 -117
- 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 +12 -18
- 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 +8 -6
- package/src/types/message/MessageData.d.ts +132 -44
- 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,74 +129,68 @@ 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];
|
|
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
|
-
|
|
145
|
+
membership: msg.info[3][10] || 0,
|
|
167
146
|
} : null;
|
|
168
|
-
let
|
|
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
|
-
|
|
163
|
+
identity = "admin";
|
|
171
164
|
}
|
|
172
165
|
else if (uid == this.anchor.id) {
|
|
173
|
-
|
|
166
|
+
identity = "anchor";
|
|
174
167
|
}
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
251
|
+
membership: data.fans_medal.guard_level,
|
|
280
252
|
} : null,
|
|
281
|
-
|
|
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: "
|
|
304
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
317
|
+
membership: data.medal_info.guard_level,
|
|
346
318
|
} : null,
|
|
347
|
-
|
|
319
|
+
membership: data.user_info.guard_level,
|
|
348
320
|
},
|
|
349
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
362
|
+
record_time: new Date().valueOf(),
|
|
391
363
|
info: {
|
|
392
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
}
|
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,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 "
|
|
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": {
|
|
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.
|
|
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.
|
|
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
|
});
|