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
package/README.md
CHANGED
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
|
|
8
8
|
注意:当前项目未进入正式版本阶段,程序结构及导出数据结构可能随时改动,**非常不建议用于正式项目中**。
|
|
9
9
|
|
|
10
|
+
GUI版本:[Minteea/floating-live-gui](https://github.com/Minteea/floating-live-gui)
|
|
11
|
+
|
|
10
12
|
## 使用方法
|
|
11
13
|
### npm安装
|
|
12
14
|
```
|
|
@@ -14,18 +16,18 @@ npm install floating-live
|
|
|
14
16
|
```
|
|
15
17
|
``` javascript
|
|
16
18
|
// 导入FloatingLive
|
|
17
|
-
const FloatingLive = require("floating-live")
|
|
19
|
+
const { FloatingLive } = require("floating-live")
|
|
18
20
|
// 导入bilibili房间生成插件
|
|
19
21
|
const bilibili = require("floating-live/plugin/bilibili")
|
|
20
22
|
|
|
21
23
|
// 创建一个FloatingLive实例
|
|
22
24
|
const live = new FloatingLive()
|
|
23
25
|
// 注册插件
|
|
24
|
-
live.
|
|
26
|
+
live.plugin.register("bilibili", bilibili)
|
|
25
27
|
// 添加房间
|
|
26
|
-
live.
|
|
28
|
+
live.addRoom({platform: "bilibili", id: 6})
|
|
27
29
|
// 打开
|
|
28
|
-
live.
|
|
30
|
+
live.start()
|
|
29
31
|
```
|
|
30
32
|
|
|
31
33
|
### 拆包即用模式
|
package/index.d.ts
CHANGED
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
1
|
+
export { FloatingLive } from "./src";
|
|
2
|
+
export * from "./src/types/message/AttributeInfo";
|
|
3
|
+
export * from "./src/types/message/MessageData";
|
|
4
|
+
export * from "./src/types/plugin/Plugin";
|
|
5
|
+
export * from "./src/types/room/PlatformInfo";
|
|
6
|
+
export * from "./src/lib/LiveRoom";
|
|
7
|
+
export * from "./src/lib/Reglist";
|
package/index.js
CHANGED
|
@@ -1,6 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
4
15
|
};
|
|
5
|
-
|
|
6
|
-
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.FloatingLive = void 0;
|
|
18
|
+
var src_1 = require("./src");
|
|
19
|
+
Object.defineProperty(exports, "FloatingLive", { enumerable: true, get: function () { return src_1.FloatingLive; } });
|
|
20
|
+
__exportStar(require("./src/types/message/AttributeInfo"), exports);
|
|
21
|
+
__exportStar(require("./src/types/message/MessageData"), exports);
|
|
22
|
+
__exportStar(require("./src/types/plugin/Plugin"), exports);
|
|
23
|
+
__exportStar(require("./src/types/room/PlatformInfo"), exports);
|
|
24
|
+
__exportStar(require("./src/lib/LiveRoom"), exports);
|
|
25
|
+
__exportStar(require("./src/lib/Reglist"), exports);
|
package/package.json
CHANGED
|
@@ -1,23 +1,21 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { MedalInfo, UserInfo } from "../../src/types/message/AttributeInfo";
|
|
3
|
-
import LiveRoom from "../../src/types/room/LiveRoom";
|
|
4
2
|
import AcClient from "acfun-live-danmaku/client";
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
import { MessageType } from "../../src/types/message/MessageData";
|
|
8
|
-
declare class acfunLive extends EventEmitter implements LiveRoom {
|
|
3
|
+
import { LiveRoom, RoomBaseInfo } from "../../src/lib/LiveRoom";
|
|
4
|
+
declare class acfunLive extends LiveRoom {
|
|
9
5
|
/** 平台id */
|
|
10
6
|
readonly platform: string;
|
|
11
7
|
/** 房间id */
|
|
12
8
|
readonly id: number;
|
|
13
9
|
/** 直播信息 */
|
|
14
|
-
|
|
10
|
+
base: RoomBaseInfo;
|
|
15
11
|
/** 主播信息 */
|
|
16
12
|
anchor: UserInfo;
|
|
17
13
|
/** 直播间弹幕api模块 */
|
|
18
14
|
client: AcClient | null;
|
|
19
15
|
/** 是否为打开状态 */
|
|
20
16
|
opening: boolean;
|
|
17
|
+
/** 是否连接上服务器 */
|
|
18
|
+
connected: boolean;
|
|
21
19
|
private wsInit;
|
|
22
20
|
/** 直播间是否可用 */
|
|
23
21
|
get available(): boolean;
|
|
@@ -69,8 +67,5 @@ declare class acfunLive extends EventEmitter implements LiveRoom {
|
|
|
69
67
|
msg_LiveClosed(): void;
|
|
70
68
|
msg_LiveBanned(): void;
|
|
71
69
|
msg_DisplayInfo(data: any): void;
|
|
72
|
-
emitMsg(data: MessageType): void;
|
|
73
|
-
emitOrigin(data: any): void;
|
|
74
|
-
emitChange(data: Partial<LiveInfo>): void;
|
|
75
70
|
}
|
|
76
71
|
export default acfunLive;
|
|
@@ -4,25 +4,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const acfun_live_danmaku_1 = __importDefault(require("acfun-live-danmaku"));
|
|
7
|
-
const events_1 = require("events");
|
|
8
7
|
const axios_1 = __importDefault(require("axios"));
|
|
9
|
-
|
|
8
|
+
const LiveRoom_1 = require("../../src/lib/LiveRoom");
|
|
9
|
+
class acfunLive extends LiveRoom_1.LiveRoom {
|
|
10
10
|
constructor(id, open = false) {
|
|
11
11
|
super();
|
|
12
12
|
/** 平台id */
|
|
13
13
|
this.platform = "acfun";
|
|
14
14
|
/** 直播信息 */
|
|
15
|
-
this.
|
|
15
|
+
this.base = {
|
|
16
16
|
/** 直播标题 */
|
|
17
17
|
title: "",
|
|
18
18
|
/** 分区 */
|
|
19
19
|
area: [],
|
|
20
20
|
/** 封面 */
|
|
21
21
|
cover: "",
|
|
22
|
-
/** 直播状态 */
|
|
23
|
-
status: "off",
|
|
24
|
-
/** 开始直播时间 */
|
|
25
|
-
start_time: 0
|
|
26
22
|
};
|
|
27
23
|
/** 主播信息 */
|
|
28
24
|
this.anchor = { name: "", id: 0 };
|
|
@@ -30,6 +26,8 @@ class acfunLive extends events_1.EventEmitter {
|
|
|
30
26
|
this.client = null;
|
|
31
27
|
/** 是否为打开状态 */
|
|
32
28
|
this.opening = false;
|
|
29
|
+
/** 是否连接上服务器 */
|
|
30
|
+
this.connected = false;
|
|
33
31
|
this.wsInit = false;
|
|
34
32
|
this.platform = "acfun";
|
|
35
33
|
this.id = id; // 直播间号
|
|
@@ -49,10 +47,10 @@ class acfunLive extends events_1.EventEmitter {
|
|
|
49
47
|
if (!this.client) {
|
|
50
48
|
this.client = await (0, acfun_live_danmaku_1.default)(this.id) || null;
|
|
51
49
|
if (this.client) {
|
|
52
|
-
this.
|
|
53
|
-
this.
|
|
54
|
-
this.
|
|
55
|
-
this.
|
|
50
|
+
this.status = "live";
|
|
51
|
+
this.timestamp = this.client.liveStartTime;
|
|
52
|
+
this.base.title = this.client.caption; // bug
|
|
53
|
+
this.base.cover = `https://tx2.a.kwimgs.com/bs2/ztlc/cover_${this.client.liveId}_raw.jpg`;
|
|
56
54
|
}
|
|
57
55
|
await axios_1.default
|
|
58
56
|
.get(`https://live.acfun.cn/rest/pc-direct/user/userInfo?userId=${this.id}`)
|
|
@@ -87,7 +85,7 @@ class acfunLive extends events_1.EventEmitter {
|
|
|
87
85
|
let client = this.client;
|
|
88
86
|
client.on("EnterRoomAck", () => {
|
|
89
87
|
console.log("[acfun-live-danmaku] 已连接AcFun直播间");
|
|
90
|
-
this.
|
|
88
|
+
this.status = "live";
|
|
91
89
|
});
|
|
92
90
|
client.on("RecentComment", (comments) => {
|
|
93
91
|
//当前弹幕列表
|
|
@@ -136,10 +134,10 @@ class acfunLive extends events_1.EventEmitter {
|
|
|
136
134
|
let danmaku = {
|
|
137
135
|
platform: "acfun",
|
|
138
136
|
room: this.id,
|
|
139
|
-
|
|
140
|
-
type: "
|
|
137
|
+
record_time: new Date().valueOf(),
|
|
138
|
+
type: "chat",
|
|
141
139
|
info: {
|
|
142
|
-
|
|
140
|
+
content: data.content,
|
|
143
141
|
user: {
|
|
144
142
|
name: data.userInfo.nickname,
|
|
145
143
|
id: parseInt(data.userInfo.userId),
|
|
@@ -156,7 +154,7 @@ class acfunLive extends events_1.EventEmitter {
|
|
|
156
154
|
platform: "acfun",
|
|
157
155
|
room: this.id,
|
|
158
156
|
type: "gift",
|
|
159
|
-
|
|
157
|
+
record_time: new Date().valueOf(),
|
|
160
158
|
info: {
|
|
161
159
|
user: {
|
|
162
160
|
name: data.user.nickname,
|
|
@@ -181,7 +179,7 @@ class acfunLive extends events_1.EventEmitter {
|
|
|
181
179
|
platform: "acfun",
|
|
182
180
|
room: this.id,
|
|
183
181
|
type: type,
|
|
184
|
-
|
|
182
|
+
record_time: new Date().valueOf(),
|
|
185
183
|
info: {
|
|
186
184
|
user: {
|
|
187
185
|
name: data.userInfo.nickname,
|
|
@@ -198,13 +196,12 @@ class acfunLive extends events_1.EventEmitter {
|
|
|
198
196
|
platform: "acfun",
|
|
199
197
|
room: this.id,
|
|
200
198
|
type: "live_end",
|
|
201
|
-
|
|
199
|
+
record_time: new Date().valueOf(),
|
|
202
200
|
info: {
|
|
203
201
|
status: "off"
|
|
204
202
|
}
|
|
205
203
|
};
|
|
206
204
|
this.client = null;
|
|
207
|
-
this.emit("change", { status: "off" });
|
|
208
205
|
this.emitMsg(off);
|
|
209
206
|
}
|
|
210
207
|
msg_LiveBanned() {
|
|
@@ -212,30 +209,16 @@ class acfunLive extends events_1.EventEmitter {
|
|
|
212
209
|
platform: "acfun",
|
|
213
210
|
room: this.id,
|
|
214
211
|
type: "live_cut",
|
|
215
|
-
|
|
212
|
+
record_time: new Date().valueOf(),
|
|
216
213
|
info: {
|
|
217
214
|
message: ""
|
|
218
215
|
}
|
|
219
216
|
};
|
|
220
217
|
this.client = null;
|
|
221
|
-
this.emit("change", { status: "off" });
|
|
222
218
|
this.emitMsg(cut);
|
|
223
219
|
}
|
|
224
220
|
msg_DisplayInfo(data) {
|
|
225
|
-
//
|
|
226
|
-
}
|
|
227
|
-
emitMsg(data) {
|
|
228
|
-
// 一般消息
|
|
229
|
-
this.emit("msg", data);
|
|
230
|
-
}
|
|
231
|
-
emitOrigin(data) {
|
|
232
|
-
// 源消息
|
|
233
|
-
this.emit("origin", data);
|
|
234
|
-
}
|
|
235
|
-
emitChange(data) {
|
|
236
|
-
this.live = Object.assign(this.live, data);
|
|
237
|
-
// 直播信息
|
|
238
|
-
this.emit("change", data);
|
|
221
|
+
//
|
|
239
222
|
}
|
|
240
223
|
}
|
|
241
224
|
exports.default = acfunLive;
|
package/plugin/acfun/index.d.ts
CHANGED
package/plugin/acfun/index.js
CHANGED
|
@@ -5,8 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
const acfunLive_1 = __importDefault(require("./acfunLive"));
|
|
6
6
|
module.exports = (ctx) => {
|
|
7
7
|
ctx.helper.roomGenerator.register("acfun", (id, open) => {
|
|
8
|
-
|
|
9
|
-
let room = new acfunLive_1.default(Number(id), open);
|
|
10
|
-
return { key, room };
|
|
8
|
+
return new acfunLive_1.default(Number(id), open);
|
|
11
9
|
});
|
|
12
10
|
};
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { UserInfo } from "../../src/types/message/AttributeInfo";
|
|
3
2
|
import { KeepLiveWS } from "bilibili-live-ws";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import { LiveInfo } from "../../src/types/room/LiveInfo";
|
|
7
|
-
declare class bilibiliLive extends EventEmitter implements LiveRoom {
|
|
3
|
+
import { LiveRoom, RoomBaseInfo } from "../../src/lib/LiveRoom";
|
|
4
|
+
declare class bilibiliLive extends LiveRoom {
|
|
8
5
|
/** 平台id */
|
|
9
6
|
readonly platform: string;
|
|
10
7
|
/** 直播间号 */
|
|
@@ -12,16 +9,15 @@ declare class bilibiliLive extends EventEmitter implements LiveRoom {
|
|
|
12
9
|
/** 直播间room_id */
|
|
13
10
|
roomid: number;
|
|
14
11
|
/** 直播信息 */
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
base: RoomBaseInfo;
|
|
13
|
+
/** 房间是否可用 */
|
|
14
|
+
available: boolean;
|
|
15
|
+
/** 是否连接上房间 */
|
|
16
|
+
connected: boolean;
|
|
17
17
|
/** 主播信息 */
|
|
18
18
|
anchor: UserInfo;
|
|
19
|
-
/** 直播间是否可用 */
|
|
20
|
-
available: boolean;
|
|
21
19
|
/** 直播间弹幕api模块 */
|
|
22
20
|
client: KeepLiveWS | null;
|
|
23
|
-
/** 是否为持续监听状态 */
|
|
24
|
-
opening: boolean;
|
|
25
21
|
/** 断线重连间隔 */
|
|
26
22
|
connectInterval: number;
|
|
27
23
|
constructor(id: number, // 房间id
|
|
@@ -36,10 +32,6 @@ declare class bilibiliLive extends EventEmitter implements LiveRoom {
|
|
|
36
32
|
/** 连接直播服务端 */
|
|
37
33
|
createWS(): Promise<void>;
|
|
38
34
|
close(): void;
|
|
39
|
-
destory(): void;
|
|
40
|
-
emitMsg(data: any): void;
|
|
41
|
-
emitOrigin(data: any): void;
|
|
42
|
-
emitChange(data: Partial<LiveInfo>): void;
|
|
43
35
|
getDanmakuMode(n: number): string;
|
|
44
36
|
/** 获取弹幕消息 */
|
|
45
37
|
msg_DANMU_MSG(msg: any): void;
|