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
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
3
|
+
exports.RoomController = void 0;
|
|
7
4
|
/** 直播间监听实例控制器 */
|
|
8
|
-
class
|
|
9
|
-
constructor(
|
|
5
|
+
class RoomController {
|
|
6
|
+
constructor(main) {
|
|
10
7
|
this.roomMap = new Map();
|
|
11
|
-
this.
|
|
12
|
-
this.main = controller.main;
|
|
8
|
+
this.main = main;
|
|
13
9
|
}
|
|
14
10
|
generate(r, open) {
|
|
15
11
|
let platform;
|
|
@@ -25,7 +21,8 @@ class Room {
|
|
|
25
21
|
}
|
|
26
22
|
}
|
|
27
23
|
/** 添加房间监听对象 */
|
|
28
|
-
add(
|
|
24
|
+
add(room, open) {
|
|
25
|
+
let key = room.key;
|
|
29
26
|
if (this.roomMap.has(key)) {
|
|
30
27
|
this.main.emit("room_exist", key);
|
|
31
28
|
return;
|
|
@@ -34,7 +31,10 @@ class Room {
|
|
|
34
31
|
// 添加监听事件
|
|
35
32
|
// 直播消息
|
|
36
33
|
room.on("msg", (data) => {
|
|
37
|
-
this.
|
|
34
|
+
this.main.helper.messageHandler.getList().forEach((handler) => {
|
|
35
|
+
handler(data);
|
|
36
|
+
});
|
|
37
|
+
this.main.emit("live_message", data);
|
|
38
38
|
});
|
|
39
39
|
// 直播消息源数据
|
|
40
40
|
room.on("origin", (data) => {
|
|
@@ -50,24 +50,32 @@ class Room {
|
|
|
50
50
|
});
|
|
51
51
|
// 获取房间信息
|
|
52
52
|
room.on("info", () => {
|
|
53
|
-
this.main.emit("room_info", key,
|
|
53
|
+
this.main.emit("room_info", key, room.info);
|
|
54
54
|
});
|
|
55
55
|
// 直播信息更改
|
|
56
56
|
room.on("change", (data) => {
|
|
57
57
|
this.main.emit("room_change", key, data);
|
|
58
58
|
});
|
|
59
|
+
// 直播状态更改
|
|
60
|
+
room.on("status", (status, timestamp) => {
|
|
61
|
+
this.main.emit("room_status", key, status, timestamp);
|
|
62
|
+
});
|
|
63
|
+
// 统计数据更新
|
|
64
|
+
room.on("stats", (data) => {
|
|
65
|
+
this.main.emit("room_stats", key, data);
|
|
66
|
+
});
|
|
59
67
|
// 房间被打开
|
|
60
68
|
room.on("open", () => {
|
|
61
|
-
this.main.emit("room_open", key,
|
|
69
|
+
this.main.emit("room_open", key, room.info);
|
|
62
70
|
});
|
|
63
71
|
// 房间被关闭
|
|
64
72
|
room.on("close", () => {
|
|
65
|
-
this.main.emit("room_close", key,
|
|
73
|
+
this.main.emit("room_close", key, room.info);
|
|
66
74
|
});
|
|
67
75
|
if (open) {
|
|
68
76
|
room.open();
|
|
69
77
|
}
|
|
70
|
-
this.main.emit("room_add", key,
|
|
78
|
+
this.main.emit("room_add", key, room.info);
|
|
71
79
|
}
|
|
72
80
|
/** 移除房间 */
|
|
73
81
|
remove(roomKey) {
|
|
@@ -87,7 +95,7 @@ class Room {
|
|
|
87
95
|
/** 获取房间信息 */
|
|
88
96
|
info(roomKey) {
|
|
89
97
|
let room = this.roomMap.get(roomKey);
|
|
90
|
-
return room ?
|
|
98
|
+
return room ? room.info : undefined;
|
|
91
99
|
}
|
|
92
100
|
/** 更新房间信息 */
|
|
93
101
|
update(roomKey) {
|
|
@@ -107,4 +115,4 @@ class Room {
|
|
|
107
115
|
room?.opening && room.close();
|
|
108
116
|
}
|
|
109
117
|
}
|
|
110
|
-
exports.
|
|
118
|
+
exports.RoomController = RoomController;
|
|
@@ -8,10 +8,10 @@ export interface UserInfo {
|
|
|
8
8
|
avatar?: string;
|
|
9
9
|
/** 粉丝勋章 */
|
|
10
10
|
medal?: MedalInfo | null;
|
|
11
|
-
/**
|
|
12
|
-
|
|
11
|
+
/** 身份 */
|
|
12
|
+
identity?: "anchor" | "admin" | null;
|
|
13
13
|
/** 粉丝vip等级 */
|
|
14
|
-
|
|
14
|
+
membership?: boolean | number;
|
|
15
15
|
/** vip等级 */
|
|
16
16
|
vip?: boolean | number;
|
|
17
17
|
/** 用户等级 */
|
|
@@ -26,7 +26,7 @@ export interface MedalInfo {
|
|
|
26
26
|
/** 粉丝牌等级 */
|
|
27
27
|
level?: number;
|
|
28
28
|
/** 粉丝vip等级 */
|
|
29
|
-
|
|
29
|
+
membership?: number;
|
|
30
30
|
}
|
|
31
31
|
/** 图像信息 */
|
|
32
32
|
export interface ImageInfo {
|
|
@@ -36,8 +36,8 @@ export interface ImageInfo {
|
|
|
36
36
|
id?: string | number;
|
|
37
37
|
/** 图像url */
|
|
38
38
|
url?: string;
|
|
39
|
-
/**
|
|
40
|
-
|
|
39
|
+
/** 图像高度 */
|
|
40
|
+
height?: number;
|
|
41
41
|
}
|
|
42
42
|
/** 礼物信息 */
|
|
43
43
|
export interface GiftInfo {
|
|
@@ -61,4 +61,6 @@ export interface GiftInfo {
|
|
|
61
61
|
action?: string;
|
|
62
62
|
/** 随机礼物信息 */
|
|
63
63
|
blind_gift?: GiftInfo;
|
|
64
|
+
/** 图片信息 */
|
|
65
|
+
image?: string;
|
|
64
66
|
}
|
|
@@ -1,80 +1,168 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { RoomBaseInfo, RoomStatsInfo, RoomStatus } from "../../lib/LiveRoom";
|
|
2
|
+
import { UserInfo, GiftInfo, ImageInfo } from "./AttributeInfo";
|
|
3
|
+
declare type MessageBase = {
|
|
4
4
|
/** 平台名称 */
|
|
5
5
|
platform: string;
|
|
6
6
|
/** 房间号 */
|
|
7
7
|
room: number | string;
|
|
8
8
|
/** 信息类型 */
|
|
9
9
|
type: string;
|
|
10
|
-
/**
|
|
11
|
-
|
|
12
|
-
/** 本地时间戳 */
|
|
13
|
-
local_timestamp?: number;
|
|
10
|
+
/** 记录时间 */
|
|
11
|
+
record_time: number;
|
|
14
12
|
/** 其他属性 */
|
|
15
13
|
[attr: string]: any;
|
|
14
|
+
};
|
|
15
|
+
export interface MessageInterface extends MessageBase {
|
|
16
|
+
/** 数据信息 */
|
|
17
|
+
info: {
|
|
18
|
+
[attr: string]: any;
|
|
19
|
+
};
|
|
16
20
|
}
|
|
17
|
-
export
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
export declare type MessageExt<T extends MessageInterface, E extends {
|
|
22
|
+
[attr: string]: any;
|
|
23
|
+
} = {
|
|
24
|
+
[attr: string]: any;
|
|
25
|
+
}> = T & {
|
|
26
|
+
info: E;
|
|
27
|
+
};
|
|
28
|
+
/** 文本聊天消息 */
|
|
29
|
+
export declare type MessageChat = MessageBase & {
|
|
30
|
+
type: "chat";
|
|
31
|
+
info: {
|
|
32
|
+
/** 用户信息 */
|
|
33
|
+
user: UserInfo;
|
|
34
|
+
/** 日期时间戳 */
|
|
35
|
+
timestamp: number;
|
|
36
|
+
/** 文本内容 */
|
|
37
|
+
content: string;
|
|
38
|
+
/** 文字颜色 */
|
|
39
|
+
color?: number | string;
|
|
40
|
+
/** 弹幕模式 */
|
|
41
|
+
mode?: number | string;
|
|
42
|
+
/** 文字大小 */
|
|
43
|
+
size?: number | string;
|
|
44
|
+
/** 图片信息 */
|
|
45
|
+
image?: ImageInfo;
|
|
46
|
+
/** 表情信息 */
|
|
47
|
+
emoticon?: {
|
|
48
|
+
[keyword: string]: ImageInfo;
|
|
49
|
+
};
|
|
50
|
+
/** 标签信息 */
|
|
51
|
+
tag?: string;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
26
54
|
/** 礼物消息 */
|
|
27
|
-
export
|
|
55
|
+
export declare type MessageGift = MessageBase & {
|
|
28
56
|
type: "gift";
|
|
29
|
-
info:
|
|
30
|
-
|
|
57
|
+
info: {
|
|
58
|
+
/** 用户信息 */
|
|
59
|
+
user: UserInfo;
|
|
60
|
+
/** 日期时间戳 */
|
|
61
|
+
timestamp: number;
|
|
62
|
+
/** 礼物信息 */
|
|
63
|
+
gift: GiftInfo;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
31
66
|
/** 互动消息(进入直播间、点赞、关注、分享、加入粉丝团) */
|
|
32
|
-
export
|
|
67
|
+
export declare type MessageInteract = MessageBase & {
|
|
33
68
|
type: "entry" | "like" | "follow" | "share" | "join";
|
|
34
|
-
info:
|
|
35
|
-
|
|
69
|
+
info: {
|
|
70
|
+
/** 用户信息 */
|
|
71
|
+
user: UserInfo;
|
|
72
|
+
/** 日期时间戳 */
|
|
73
|
+
timestamp: number;
|
|
74
|
+
/** 信息标签 */
|
|
75
|
+
tag?: string | boolean;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
36
78
|
/** 粉丝vip开通消息 */
|
|
37
|
-
export
|
|
38
|
-
type: "
|
|
39
|
-
info:
|
|
40
|
-
|
|
79
|
+
export declare type MessageMembership = MessageBase & {
|
|
80
|
+
type: "membership";
|
|
81
|
+
info: {
|
|
82
|
+
/** 用户信息 */
|
|
83
|
+
user: UserInfo;
|
|
84
|
+
/** 日期时间戳 */
|
|
85
|
+
timestamp: number;
|
|
86
|
+
/** 礼物信息 */
|
|
87
|
+
gift: GiftInfo;
|
|
88
|
+
/** 开通vip名称 */
|
|
89
|
+
name: string;
|
|
90
|
+
/** 开通vip等级 */
|
|
91
|
+
level?: number;
|
|
92
|
+
/** 持续时间(天数) */
|
|
93
|
+
duration: number;
|
|
94
|
+
};
|
|
95
|
+
};
|
|
41
96
|
/** 粉丝vip开通消息 */
|
|
42
|
-
export
|
|
97
|
+
export declare type MessageSuperchat = MessageBase & {
|
|
43
98
|
type: "superchat";
|
|
44
|
-
info:
|
|
45
|
-
|
|
99
|
+
info: {
|
|
100
|
+
/** 留言id */
|
|
101
|
+
id?: string;
|
|
102
|
+
/** 用户信息 */
|
|
103
|
+
user: UserInfo;
|
|
104
|
+
/** 日期时间戳 */
|
|
105
|
+
timestamp: number;
|
|
106
|
+
/** 文本内容 */
|
|
107
|
+
content: string;
|
|
108
|
+
/** 文字颜色 */
|
|
109
|
+
color?: number | string;
|
|
110
|
+
/** 礼物信息 */
|
|
111
|
+
gift: GiftInfo;
|
|
112
|
+
/** (SC)持续时间 */
|
|
113
|
+
duration: number;
|
|
114
|
+
};
|
|
115
|
+
};
|
|
46
116
|
/** 禁言消息 */
|
|
47
|
-
export
|
|
117
|
+
export declare type MessageBlock = MessageBase & {
|
|
48
118
|
type: "block";
|
|
49
|
-
info:
|
|
50
|
-
|
|
119
|
+
info: {
|
|
120
|
+
/** 用户信息 */
|
|
121
|
+
user: UserInfo;
|
|
122
|
+
/** 日期时间戳 */
|
|
123
|
+
timestamp?: number;
|
|
124
|
+
/** 操作者 */
|
|
125
|
+
operator: UserInfo | {
|
|
126
|
+
identity: null | "admin" | "anchor";
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
};
|
|
51
130
|
/** 直播开播消息 */
|
|
52
|
-
export
|
|
131
|
+
export declare type MessageLiveStart = MessageBase & {
|
|
53
132
|
type: "live_start";
|
|
54
133
|
info: {
|
|
55
134
|
/** 开播时间 */
|
|
56
|
-
|
|
135
|
+
timestamp: number;
|
|
57
136
|
};
|
|
58
|
-
}
|
|
137
|
+
};
|
|
59
138
|
/** 直播切断消息 */
|
|
60
|
-
export
|
|
139
|
+
export declare type MessageLiveCut = MessageBase & {
|
|
61
140
|
type: "live_cut";
|
|
62
141
|
info: {
|
|
63
142
|
/** 切断消息 */
|
|
64
143
|
message: string;
|
|
65
144
|
};
|
|
66
|
-
}
|
|
145
|
+
};
|
|
67
146
|
/** 直播数据更新 */
|
|
68
|
-
export
|
|
147
|
+
export declare type MessageLiveStats = MessageBase & {
|
|
69
148
|
type: "live_stats";
|
|
70
|
-
info:
|
|
71
|
-
}
|
|
149
|
+
info: RoomStatsInfo;
|
|
150
|
+
};
|
|
151
|
+
/** 直播信息更新 */
|
|
152
|
+
export declare type MessageLiveChange = MessageBase & {
|
|
153
|
+
type: "live_change";
|
|
154
|
+
info: RoomBaseInfo;
|
|
155
|
+
};
|
|
72
156
|
/** 直播结束 */
|
|
73
|
-
export
|
|
157
|
+
export declare type MessageLiveEnd = MessageBase & {
|
|
74
158
|
type: "live_end";
|
|
75
159
|
info: {
|
|
76
160
|
/** 直播状态 */
|
|
77
|
-
status:
|
|
161
|
+
status: RoomStatus;
|
|
78
162
|
};
|
|
79
|
-
}
|
|
80
|
-
|
|
163
|
+
};
|
|
164
|
+
declare type AllMessageType = MessageChat | MessageGift | MessageInteract | MessageMembership | MessageSuperchat | MessageBlock | MessageLiveStart | MessageLiveEnd | MessageLiveCut | MessageLiveChange | MessageLiveStats;
|
|
165
|
+
export declare type MessageData<T extends AllMessageType["type"] = AllMessageType["type"]> = AllMessageType & {
|
|
166
|
+
type: T;
|
|
167
|
+
};
|
|
168
|
+
export {};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import FloatingLive from "../..";
|
|
1
|
+
import { FloatingLive } from "../..";
|
|
2
2
|
/** 插件模块, 加载时调用 */
|
|
3
|
-
export declare type FloatingLivePlugin<T =
|
|
3
|
+
export declare type FloatingLivePlugin<T extends FloatingLive = FloatingLive> = (ctx: T) => {
|
|
4
|
+
[key: string]: any;
|
|
5
|
+
} | void;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { MessageData } from "../../src/types/message/MessageData";
|
|
2
|
-
import ChatProcessor from "./chatProcessor";
|
|
3
|
-
declare class ChatCommand {
|
|
4
|
-
chatProcessor: ChatProcessor;
|
|
5
|
-
filterList: any[];
|
|
6
|
-
constructor(chatProcessor: ChatProcessor, filterList: any[]);
|
|
7
|
-
process(msg: MessageData): void;
|
|
8
|
-
}
|
|
9
|
-
export default ChatCommand;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
class ChatCommand {
|
|
4
|
-
constructor(chatProcessor, filterList) {
|
|
5
|
-
this.chatProcessor = chatProcessor;
|
|
6
|
-
this.filterList = filterList;
|
|
7
|
-
}
|
|
8
|
-
process(msg) {
|
|
9
|
-
if (msg.type == "text" && !msg.block) {
|
|
10
|
-
let text = msg.info.text;
|
|
11
|
-
let filterList = this.filterList;
|
|
12
|
-
for (let g = 0; g < filterList.length; g++) {
|
|
13
|
-
let rule = filterList[g];
|
|
14
|
-
if (rule.pattern.test(text)) {
|
|
15
|
-
let command = {
|
|
16
|
-
platform: msg.platform,
|
|
17
|
-
type: "command",
|
|
18
|
-
command: rule.command,
|
|
19
|
-
timestamp: msg.local_timestamp,
|
|
20
|
-
info: {
|
|
21
|
-
type: "text",
|
|
22
|
-
user: msg.info.user,
|
|
23
|
-
},
|
|
24
|
-
data: {},
|
|
25
|
-
};
|
|
26
|
-
if (rule.callback) {
|
|
27
|
-
rule.callback(msg, command, rule.pattern);
|
|
28
|
-
}
|
|
29
|
-
msg.command = {
|
|
30
|
-
command: command.command,
|
|
31
|
-
data: command.data
|
|
32
|
-
};
|
|
33
|
-
this.chatProcessor.emit("command", command);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
exports.default = ChatCommand;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { MessageData } from "../../src/types/message/MessageData";
|
|
2
|
-
import ChatProcessor from "./ChatProcessor";
|
|
3
|
-
declare class ChatFilter {
|
|
4
|
-
chatProcessor: ChatProcessor;
|
|
5
|
-
filterList: any[];
|
|
6
|
-
constructor(chatProcessor: ChatProcessor, filterList: any[]);
|
|
7
|
-
process(msg: MessageData): void;
|
|
8
|
-
}
|
|
9
|
-
export default ChatFilter;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
class ChatFilter {
|
|
4
|
-
constructor(chatProcessor, filterList) {
|
|
5
|
-
this.chatProcessor = chatProcessor;
|
|
6
|
-
this.filterList = filterList;
|
|
7
|
-
}
|
|
8
|
-
process(msg) {
|
|
9
|
-
if (msg.type == "text" && msg.info.text) {
|
|
10
|
-
let text = msg.info.text;
|
|
11
|
-
let filterList = this.filterList;
|
|
12
|
-
fgroup: for (let g = 0; g < filterList.length; g++) {
|
|
13
|
-
let group = filterList[g];
|
|
14
|
-
if (group.open) {
|
|
15
|
-
for (let i = 0; i < group.keyword.length; i++) {
|
|
16
|
-
if (text.includes(group.keyword[i])) {
|
|
17
|
-
let keyword = group.keyword[i];
|
|
18
|
-
msg.block = {
|
|
19
|
-
type: group.type,
|
|
20
|
-
name: group.name,
|
|
21
|
-
keyword: keyword,
|
|
22
|
-
mode: group.mode,
|
|
23
|
-
};
|
|
24
|
-
switch (group.mode) {
|
|
25
|
-
case "hide": {
|
|
26
|
-
msg.block.reason = group.reason;
|
|
27
|
-
break;
|
|
28
|
-
}
|
|
29
|
-
case "replace": {
|
|
30
|
-
msg.block.reason = group.reason;
|
|
31
|
-
msg.block.replace = group.replace;
|
|
32
|
-
break;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
this.chatProcessor.emit("filter", msg);
|
|
36
|
-
break fgroup;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
exports.default = ChatFilter;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import ChatFilter from "./ChatFilter";
|
|
3
|
-
import ChatCommand from "./ChatCommand";
|
|
4
|
-
import { EventEmitter } from "events";
|
|
5
|
-
import { MessageData } from "../../src/types/message/MessageData";
|
|
6
|
-
declare class ChatProcessor extends EventEmitter {
|
|
7
|
-
filter: ChatFilter;
|
|
8
|
-
command: ChatCommand;
|
|
9
|
-
constructor();
|
|
10
|
-
process(msg: MessageData): void;
|
|
11
|
-
}
|
|
12
|
-
export default ChatProcessor;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const ChatFilter_1 = __importDefault(require("./ChatFilter"));
|
|
7
|
-
const ChatCommand_1 = __importDefault(require("./ChatCommand"));
|
|
8
|
-
const events_1 = require("events");
|
|
9
|
-
let commandList = [];
|
|
10
|
-
let filterList = [];
|
|
11
|
-
class ChatProcessor extends events_1.EventEmitter {
|
|
12
|
-
constructor() {
|
|
13
|
-
super();
|
|
14
|
-
this.filter = new ChatFilter_1.default(this, filterList);
|
|
15
|
-
this.command = new ChatCommand_1.default(this, commandList);
|
|
16
|
-
}
|
|
17
|
-
process(msg) {
|
|
18
|
-
if (this.filter)
|
|
19
|
-
this.filter.process(msg);
|
|
20
|
-
if (this.command)
|
|
21
|
-
this.command.process(msg);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
exports.default = ChatProcessor;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import Controller from ".";
|
|
2
|
-
import FloatingLive from "..";
|
|
3
|
-
import { MessageType } from "../types/message/MessageData";
|
|
4
|
-
export default class Message {
|
|
5
|
-
readonly controller: Controller;
|
|
6
|
-
readonly main: FloatingLive;
|
|
7
|
-
constructor(controller: Controller);
|
|
8
|
-
send(msg: MessageType): void;
|
|
9
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
class Message {
|
|
4
|
-
constructor(controller) {
|
|
5
|
-
this.controller = controller;
|
|
6
|
-
this.main = controller.main;
|
|
7
|
-
}
|
|
8
|
-
send(msg) {
|
|
9
|
-
this.main.helper.messageHandler.getList().forEach((handler) => {
|
|
10
|
-
handler(msg);
|
|
11
|
-
});
|
|
12
|
-
this.main.emit("live_message", msg);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
exports.default = Message;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import FloatingLive from "..";
|
|
2
|
-
import LiveRoom from "../types/room/LiveRoom";
|
|
3
|
-
import Message from "./Message";
|
|
4
|
-
import Room from "./Room";
|
|
5
|
-
export default class Controller {
|
|
6
|
-
readonly main: FloatingLive;
|
|
7
|
-
/** room 控制模块 */
|
|
8
|
-
readonly room: Room;
|
|
9
|
-
/** message 控制模块 */
|
|
10
|
-
readonly message: Message;
|
|
11
|
-
/** 开始时间戳 */
|
|
12
|
-
timestamp: number;
|
|
13
|
-
/** 开始状态 */
|
|
14
|
-
started: boolean;
|
|
15
|
-
constructor(main: FloatingLive);
|
|
16
|
-
/** 开始 */
|
|
17
|
-
start(): void;
|
|
18
|
-
/** 结束 */
|
|
19
|
-
end(): void;
|
|
20
|
-
/** 添加房间 */
|
|
21
|
-
addRoom({ platform, id }: {
|
|
22
|
-
platform: string;
|
|
23
|
-
id: string | number;
|
|
24
|
-
}, open?: boolean): void;
|
|
25
|
-
/** 移除房间 */
|
|
26
|
-
removeRoom(roomKey: string): void;
|
|
27
|
-
/** 添加房间实例 */
|
|
28
|
-
addLiveRoom(key: string, room: LiveRoom): void;
|
|
29
|
-
/** 打开房间 */
|
|
30
|
-
openRoom(roomKey: string): void;
|
|
31
|
-
/** 关闭房间 */
|
|
32
|
-
closeRoom(roomKey: string): void;
|
|
33
|
-
/** 打开所有房间 */
|
|
34
|
-
openAllRooms(): void;
|
|
35
|
-
/** 关闭所有房间 */
|
|
36
|
-
closeAllRooms(): void;
|
|
37
|
-
/** 更新房间信息 */
|
|
38
|
-
updateRoomInfo(roomKey: string): void;
|
|
39
|
-
}
|
package/src/controller/index.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const Message_1 = __importDefault(require("./Message"));
|
|
7
|
-
const Room_1 = __importDefault(require("./Room"));
|
|
8
|
-
class Controller {
|
|
9
|
-
constructor(main) {
|
|
10
|
-
/** 开始时间戳 */
|
|
11
|
-
this.timestamp = 0;
|
|
12
|
-
/** 开始状态 */
|
|
13
|
-
this.started = false;
|
|
14
|
-
this.main = main;
|
|
15
|
-
this.room = new Room_1.default(this);
|
|
16
|
-
this.message = new Message_1.default(this);
|
|
17
|
-
this.main.on("room_open", () => {
|
|
18
|
-
this.start();
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
/** 开始 */
|
|
22
|
-
start() {
|
|
23
|
-
this.started = true;
|
|
24
|
-
this.timestamp = new Date().valueOf();
|
|
25
|
-
this.main.emit("start", this.timestamp);
|
|
26
|
-
}
|
|
27
|
-
/** 结束 */
|
|
28
|
-
end() {
|
|
29
|
-
this.closeAllRooms();
|
|
30
|
-
this.started = false;
|
|
31
|
-
this.main.emit("end", this.timestamp);
|
|
32
|
-
this.timestamp = 0;
|
|
33
|
-
}
|
|
34
|
-
/** 添加房间 */
|
|
35
|
-
addRoom({ platform, id }, open) {
|
|
36
|
-
let generated = this.room.generate({ platform, id }, open);
|
|
37
|
-
if (generated) {
|
|
38
|
-
this.room.add(generated.key, generated.room);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
/** 移除房间 */
|
|
42
|
-
removeRoom(roomKey) {
|
|
43
|
-
this.room.remove(roomKey);
|
|
44
|
-
}
|
|
45
|
-
/** 添加房间实例 */
|
|
46
|
-
addLiveRoom(key, room) {
|
|
47
|
-
this.room.add(key, room);
|
|
48
|
-
}
|
|
49
|
-
/** 打开房间 */
|
|
50
|
-
openRoom(roomKey) {
|
|
51
|
-
this.room.open(roomKey);
|
|
52
|
-
}
|
|
53
|
-
/** 关闭房间 */
|
|
54
|
-
closeRoom(roomKey) {
|
|
55
|
-
this.room.close(roomKey);
|
|
56
|
-
}
|
|
57
|
-
/** 打开所有房间 */
|
|
58
|
-
openAllRooms() {
|
|
59
|
-
this.room.keyList.forEach((key) => {
|
|
60
|
-
this.room.open(key);
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
/** 关闭所有房间 */
|
|
64
|
-
closeAllRooms() {
|
|
65
|
-
this.room.keyList.forEach((key) => {
|
|
66
|
-
this.room.close(key);
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
/** 更新房间信息 */
|
|
70
|
-
updateRoomInfo(roomKey) {
|
|
71
|
-
this.room.update(roomKey);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
exports.default = Controller;
|