floating-live 0.10.2 → 0.11.1
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/index.d.ts +2 -4
- package/index.js +2 -4
- package/package.json +2 -2
- package/plugin/acfun/acfunLive.d.ts +7 -4
- package/plugin/acfun/acfunLive.js +57 -28
- package/plugin/acfun/index.d.ts +3 -1
- package/plugin/acfun/index.js +8 -4
- package/plugin/bilibili/bilibiliLive.d.ts +11 -6
- package/plugin/bilibili/bilibiliLive.js +95 -67
- package/plugin/bilibili/index.d.ts +4 -2
- package/plugin/bilibili/index.js +8 -4
- package/plugin/chatPrint/chatPrint.d.ts +2 -2
- package/plugin/chatPrint/chatPrint.js +4 -3
- package/plugin/chatPrint/index.d.ts +4 -2
- package/plugin/chatPrint/index.js +6 -2
- package/plugin/consoleEvent/index.d.ts +4 -2
- package/plugin/consoleEvent/index.js +6 -1
- package/plugin/msgSave/index.d.ts +8 -4
- package/plugin/msgSave/index.js +76 -21
- package/plugin/msgSave/msgSave.d.ts +75 -14
- package/plugin/msgSave/msgSave.js +130 -19
- package/src/enum.d.ts +34 -0
- package/src/enum.js +41 -0
- package/src/index.d.ts +3 -3
- package/src/index.js +9 -7
- package/src/lib/LiveRoom.d.ts +10 -9
- package/src/lib/LiveRoom.js +28 -27
- package/src/module/Command.d.ts +2 -1
- package/src/module/Command.js +3 -3
- package/src/module/Plugin.d.ts +4 -2
- package/src/module/Plugin.js +12 -4
- package/src/module/Room.js +7 -7
- package/src/types/index.d.ts +4 -0
- package/src/types/index.js +20 -0
- package/src/types/message/AttributeInfo.d.ts +5 -4
- package/src/types/message/MessageData.d.ts +20 -24
- package/src/types/plugin.d.ts +9 -0
- package/src/types/{room/PlatformInfo.d.ts → room.d.ts} +2 -0
- package/src/types/plugin/Plugin.d.ts +0 -5
- /package/src/types/{plugin/Plugin.js → plugin.js} +0 -0
- /package/src/types/{room/PlatformInfo.js → room.js} +0 -0
package/index.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
export { FloatingLive } from "./src";
|
|
2
|
-
export * from "./src/types
|
|
3
|
-
export * from "./src/
|
|
4
|
-
export * from "./src/types/plugin/Plugin";
|
|
5
|
-
export * from "./src/types/room/PlatformInfo";
|
|
2
|
+
export * from "./src/types";
|
|
3
|
+
export * from "./src/enum";
|
|
6
4
|
export * from "./src/lib/LiveRoom";
|
|
7
5
|
export * from "./src/lib/Reglist";
|
package/index.js
CHANGED
|
@@ -17,9 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
exports.FloatingLive = void 0;
|
|
18
18
|
var src_1 = require("./src");
|
|
19
19
|
Object.defineProperty(exports, "FloatingLive", { enumerable: true, get: function () { return src_1.FloatingLive; } });
|
|
20
|
-
__exportStar(require("./src/types
|
|
21
|
-
__exportStar(require("./src/
|
|
22
|
-
__exportStar(require("./src/types/plugin/Plugin"), exports);
|
|
23
|
-
__exportStar(require("./src/types/room/PlatformInfo"), exports);
|
|
20
|
+
__exportStar(require("./src/types"), exports);
|
|
21
|
+
__exportStar(require("./src/enum"), exports);
|
|
24
22
|
__exportStar(require("./src/lib/LiveRoom"), exports);
|
|
25
23
|
__exportStar(require("./src/lib/Reglist"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "floating-live",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.1",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"acfun-live-danmaku": "^0.6.1",
|
|
19
|
-
"axios": "^1.
|
|
19
|
+
"axios": "^1.4.0",
|
|
20
20
|
"bilibili-live-ws": "^6.0.3",
|
|
21
21
|
"fs-extra": "^11.1.0"
|
|
22
22
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { MedalInfo, UserInfo } from "
|
|
1
|
+
import { MedalInfo, UserInfo } from "../..";
|
|
2
2
|
import AcClient from "acfun-live-danmaku/client";
|
|
3
|
-
import { LiveRoom,
|
|
3
|
+
import { LiveRoom, RoomStatsInfo, RoomViewInfo } from "../..";
|
|
4
4
|
declare type ZtLiveUserInfo = {
|
|
5
5
|
userIdentity: {
|
|
6
6
|
managerType?: number;
|
|
@@ -19,8 +19,10 @@ declare class acfunLive extends LiveRoom {
|
|
|
19
19
|
readonly platform: string;
|
|
20
20
|
/** 房间id */
|
|
21
21
|
readonly id: number;
|
|
22
|
-
/**
|
|
23
|
-
|
|
22
|
+
/** 直播展示信息 */
|
|
23
|
+
view: RoomViewInfo;
|
|
24
|
+
/** 直播数据信息 */
|
|
25
|
+
stats: RoomStatsInfo;
|
|
24
26
|
/** 主播信息 */
|
|
25
27
|
anchor: UserInfo;
|
|
26
28
|
/** 直播间弹幕api模块 */
|
|
@@ -38,6 +40,7 @@ declare class acfunLive extends LiveRoom {
|
|
|
38
40
|
open(): Promise<void>;
|
|
39
41
|
/** 初始化直播服务端监听 */
|
|
40
42
|
private initWS;
|
|
43
|
+
/** 关闭直播间监听 */
|
|
41
44
|
close(): void;
|
|
42
45
|
destory(): void;
|
|
43
46
|
/** 根据守护徽章字符串获取粉丝牌信息 */
|
|
@@ -4,15 +4,27 @@ 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
|
|
8
|
-
const
|
|
9
|
-
|
|
7
|
+
const __1 = require("../..");
|
|
8
|
+
const __2 = require("../..");
|
|
9
|
+
// 获取当前时间戳,以替代无法从数据中获取时间戳的情况,精度为1s
|
|
10
|
+
function getDateTimestamp() {
|
|
11
|
+
return Math.floor(Date.now() / 1000) * 1000;
|
|
12
|
+
}
|
|
13
|
+
function stringToNumber(num) {
|
|
14
|
+
if (num.slice(-1) == "万") {
|
|
15
|
+
return Math.round(parseFloat(num) * 10000);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
return parseFloat(num);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
class acfunLive extends __1.LiveRoom {
|
|
10
22
|
constructor(id, open = false) {
|
|
11
23
|
super();
|
|
12
24
|
/** 平台id */
|
|
13
25
|
this.platform = "acfun";
|
|
14
|
-
/**
|
|
15
|
-
this.
|
|
26
|
+
/** 直播展示信息 */
|
|
27
|
+
this.view = {
|
|
16
28
|
/** 直播标题 */
|
|
17
29
|
title: "",
|
|
18
30
|
/** 分区 */
|
|
@@ -20,6 +32,13 @@ class acfunLive extends LiveRoom_1.LiveRoom {
|
|
|
20
32
|
/** 封面 */
|
|
21
33
|
cover: "",
|
|
22
34
|
};
|
|
35
|
+
/** 直播数据信息 */
|
|
36
|
+
this.stats = {
|
|
37
|
+
/** 点赞数 */
|
|
38
|
+
like: 0,
|
|
39
|
+
/** 在线观看数 */
|
|
40
|
+
online: 0,
|
|
41
|
+
};
|
|
23
42
|
/** 主播信息 */
|
|
24
43
|
this.anchor = { name: "", id: 0 };
|
|
25
44
|
/** 直播间弹幕api模块 */
|
|
@@ -46,22 +65,24 @@ class acfunLive extends LiveRoom_1.LiveRoom {
|
|
|
46
65
|
if (!this.client) {
|
|
47
66
|
this.client = await (0, acfun_live_danmaku_1.default)(this.id) || null;
|
|
48
67
|
if (this.client) {
|
|
49
|
-
this.status =
|
|
68
|
+
this.status = __2.RoomStatus.live;
|
|
50
69
|
this.timestamp = this.client.liveStartTime;
|
|
51
|
-
this.
|
|
52
|
-
this.
|
|
70
|
+
this.view.title = this.client.caption; // bug
|
|
71
|
+
this.view.cover = `https://tx2.a.kwimgs.com/bs2/ztlc/cover_${this.client.liveId}_raw.jpg`;
|
|
53
72
|
}
|
|
54
|
-
await
|
|
55
|
-
|
|
73
|
+
await fetch(`https://live.acfun.cn/rest/pc-direct/user/userInfo?userId=${this.id}`, {
|
|
74
|
+
method: "GET"
|
|
75
|
+
})
|
|
76
|
+
.then((response) => response.json())
|
|
56
77
|
.then((res) => {
|
|
57
|
-
let
|
|
58
|
-
this.anchor.avatar =
|
|
59
|
-
this.anchor.name =
|
|
78
|
+
let { headUrl, name } = res.profile;
|
|
79
|
+
this.anchor.avatar = headUrl;
|
|
80
|
+
this.anchor.name = name;
|
|
81
|
+
this.emit("info");
|
|
60
82
|
})
|
|
61
83
|
.catch((error) => {
|
|
62
84
|
console.error(error);
|
|
63
85
|
});
|
|
64
|
-
this.emit("info");
|
|
65
86
|
}
|
|
66
87
|
// 暂不能在连接房间后更新信息
|
|
67
88
|
}
|
|
@@ -84,7 +105,7 @@ class acfunLive extends LiveRoom_1.LiveRoom {
|
|
|
84
105
|
let client = this.client;
|
|
85
106
|
client.on("EnterRoomAck", () => {
|
|
86
107
|
console.log("[acfun-live-danmaku] 已连接AcFun直播间");
|
|
87
|
-
this.status =
|
|
108
|
+
this.status = __2.RoomStatus.live;
|
|
88
109
|
});
|
|
89
110
|
client.on("RecentComment", (comments) => {
|
|
90
111
|
//当前弹幕列表
|
|
@@ -102,6 +123,7 @@ class acfunLive extends LiveRoom_1.LiveRoom {
|
|
|
102
123
|
client.on("LiveBanned", (end) => { this.msg_LiveBanned(); });
|
|
103
124
|
this.wsInit = true;
|
|
104
125
|
}
|
|
126
|
+
/** 关闭直播间监听 */
|
|
105
127
|
close() {
|
|
106
128
|
if (!this.opening)
|
|
107
129
|
return;
|
|
@@ -131,17 +153,17 @@ class acfunLive extends LiveRoom_1.LiveRoom {
|
|
|
131
153
|
getUser(user) {
|
|
132
154
|
let identity = null;
|
|
133
155
|
if (user.userIdentity?.managerType == 1) {
|
|
134
|
-
identity =
|
|
156
|
+
identity = __2.UserAdmin.admin;
|
|
135
157
|
}
|
|
136
158
|
else if (parseInt(user.userId) == this.anchor.id) {
|
|
137
|
-
identity =
|
|
159
|
+
identity = __2.UserAdmin.anchor;
|
|
138
160
|
}
|
|
139
161
|
return {
|
|
140
162
|
name: user.nickname,
|
|
141
163
|
id: parseInt(user.userId),
|
|
142
164
|
medal: this.getMedal(user.badge),
|
|
143
165
|
avatar: user.avatar[0].url,
|
|
144
|
-
|
|
166
|
+
admin: identity
|
|
145
167
|
};
|
|
146
168
|
}
|
|
147
169
|
/** 文本信息(Comment) */
|
|
@@ -149,12 +171,11 @@ class acfunLive extends LiveRoom_1.LiveRoom {
|
|
|
149
171
|
let danmaku = {
|
|
150
172
|
platform: "acfun",
|
|
151
173
|
room: this.id,
|
|
152
|
-
|
|
174
|
+
timestamp: parseInt(data.sendTimeMs),
|
|
153
175
|
type: "chat",
|
|
154
176
|
info: {
|
|
155
177
|
content: data.content,
|
|
156
178
|
user: this.getUser(data.userInfo),
|
|
157
|
-
timestamp: parseInt(data.sendTimeMs),
|
|
158
179
|
},
|
|
159
180
|
};
|
|
160
181
|
this.emitMsg(danmaku);
|
|
@@ -165,7 +186,7 @@ class acfunLive extends LiveRoom_1.LiveRoom {
|
|
|
165
186
|
platform: "acfun",
|
|
166
187
|
room: this.id,
|
|
167
188
|
type: "gift",
|
|
168
|
-
|
|
189
|
+
timestamp: parseInt(data.sendTimeMs),
|
|
169
190
|
info: {
|
|
170
191
|
user: this.getUser(data.user),
|
|
171
192
|
gift: {
|
|
@@ -175,7 +196,6 @@ class acfunLive extends LiveRoom_1.LiveRoom {
|
|
|
175
196
|
currency: data.giftId == "1" ? "banana" : "coin",
|
|
176
197
|
value: parseInt(data.value), // 总价值
|
|
177
198
|
},
|
|
178
|
-
timestamp: parseInt(data.sendTimeMs),
|
|
179
199
|
},
|
|
180
200
|
};
|
|
181
201
|
this.emitMsg(gift);
|
|
@@ -186,10 +206,9 @@ class acfunLive extends LiveRoom_1.LiveRoom {
|
|
|
186
206
|
platform: "acfun",
|
|
187
207
|
room: this.id,
|
|
188
208
|
type: type,
|
|
189
|
-
|
|
209
|
+
timestamp: parseInt(data.sendTimeMs),
|
|
190
210
|
info: {
|
|
191
211
|
user: this.getUser(data.userInfo),
|
|
192
|
-
timestamp: parseInt(data.sendTimeMs),
|
|
193
212
|
},
|
|
194
213
|
};
|
|
195
214
|
this.emitMsg(like);
|
|
@@ -199,9 +218,9 @@ class acfunLive extends LiveRoom_1.LiveRoom {
|
|
|
199
218
|
platform: "acfun",
|
|
200
219
|
room: this.id,
|
|
201
220
|
type: "live_end",
|
|
202
|
-
|
|
221
|
+
timestamp: getDateTimestamp(),
|
|
203
222
|
info: {
|
|
204
|
-
status:
|
|
223
|
+
status: __2.RoomStatus.off
|
|
205
224
|
}
|
|
206
225
|
};
|
|
207
226
|
this.client = null;
|
|
@@ -212,7 +231,7 @@ class acfunLive extends LiveRoom_1.LiveRoom {
|
|
|
212
231
|
platform: "acfun",
|
|
213
232
|
room: this.id,
|
|
214
233
|
type: "live_cut",
|
|
215
|
-
|
|
234
|
+
timestamp: getDateTimestamp(),
|
|
216
235
|
info: {
|
|
217
236
|
message: ""
|
|
218
237
|
}
|
|
@@ -221,7 +240,17 @@ class acfunLive extends LiveRoom_1.LiveRoom {
|
|
|
221
240
|
this.emitMsg(cut);
|
|
222
241
|
}
|
|
223
242
|
msg_DisplayInfo(data) {
|
|
224
|
-
|
|
243
|
+
let stats = {
|
|
244
|
+
platform: "acfun",
|
|
245
|
+
room: this.id,
|
|
246
|
+
type: "live_stats",
|
|
247
|
+
timestamp: getDateTimestamp(),
|
|
248
|
+
info: {
|
|
249
|
+
like: stringToNumber(data.likeCount),
|
|
250
|
+
online: stringToNumber(data.watchingCount),
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
this.emitMsg(stats);
|
|
225
254
|
}
|
|
226
255
|
}
|
|
227
256
|
exports.default = acfunLive;
|
package/plugin/acfun/index.d.ts
CHANGED
package/plugin/acfun/index.js
CHANGED
|
@@ -3,8 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
const acfunLive_1 = __importDefault(require("./acfunLive"));
|
|
6
|
-
module.exports = (
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
module.exports = () => {
|
|
7
|
+
return {
|
|
8
|
+
register: (ctx) => {
|
|
9
|
+
ctx.helper.roomGenerator.register("acfun", (id, open) => {
|
|
10
|
+
return new acfunLive_1.default(Number(id), open);
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
};
|
|
10
14
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { UserInfo } from "
|
|
1
|
+
import { UserInfo } from "../..";
|
|
2
2
|
import { KeepLiveWS } from "bilibili-live-ws";
|
|
3
|
-
import { LiveRoom,
|
|
3
|
+
import { LiveRoom, RoomStatsInfo, RoomViewInfo } from "../..";
|
|
4
4
|
declare class bilibiliLive extends LiveRoom {
|
|
5
5
|
/** 平台id */
|
|
6
6
|
readonly platform: string;
|
|
@@ -8,8 +8,9 @@ declare class bilibiliLive extends LiveRoom {
|
|
|
8
8
|
readonly id: number;
|
|
9
9
|
/** 直播间room_id */
|
|
10
10
|
roomid: number;
|
|
11
|
-
/**
|
|
12
|
-
|
|
11
|
+
/** 展示信息 */
|
|
12
|
+
view: RoomViewInfo;
|
|
13
|
+
stats: RoomStatsInfo;
|
|
13
14
|
/** 房间是否可用 */
|
|
14
15
|
available: boolean;
|
|
15
16
|
/** 是否连接上房间 */
|
|
@@ -26,13 +27,13 @@ declare class bilibiliLive extends LiveRoom {
|
|
|
26
27
|
connectInterval: number;
|
|
27
28
|
});
|
|
28
29
|
/** 获取房间信息 */
|
|
29
|
-
getInfo(): Promise<void>;
|
|
30
|
+
getInfo(refresh?: boolean): Promise<void>;
|
|
30
31
|
/** 开启直播间监听 */
|
|
31
32
|
open(): Promise<void>;
|
|
32
33
|
/** 连接直播服务端 */
|
|
33
34
|
createWS(): Promise<void>;
|
|
35
|
+
/** 关闭直播间监听 */
|
|
34
36
|
close(): void;
|
|
35
|
-
getDanmakuMode(n: number): string;
|
|
36
37
|
/** 获取弹幕消息 */
|
|
37
38
|
msg_DANMU_MSG(msg: any): void;
|
|
38
39
|
/** 获取互动消息 */
|
|
@@ -43,6 +44,10 @@ declare class bilibiliLive extends LiveRoom {
|
|
|
43
44
|
msg_GUARD_BUY(msg: any): void;
|
|
44
45
|
/** 获取醒目留言消息 */
|
|
45
46
|
msg_SUPER_CHAT_MESSAGE(msg: any): void;
|
|
47
|
+
/** 观看数变化 */
|
|
48
|
+
msg_WATCHED_CHANGE(msg: any): void;
|
|
49
|
+
/** 点赞数变化 */
|
|
50
|
+
msg_LIKE_INFO_V3_UPDATE(msg: any): void;
|
|
46
51
|
msg_ROOM_BLOCK_MSG(msg: any): void;
|
|
47
52
|
msg_LIVE(msg: any): void;
|
|
48
53
|
msg_CUT_OFF(msg: any): void;
|