floating-live 0.17.0-alpha.8 → 0.17.0-beta.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/LICENSE +8 -8
- package/README.md +36 -36
- package/dist/FloatingLive.d.ts +0 -2
- package/dist/FloatingLive.js +0 -4
- package/dist/app.d.ts +2 -1
- package/dist/app.js +4 -1
- package/dist/command/manager.d.ts +5 -1
- package/dist/command/manager.js +44 -4
- package/dist/command/types.d.ts +17 -8
- package/dist/error/index.d.ts +7 -3
- package/dist/error/index.js +6 -2
- package/dist/event/types.d.ts +1 -0
- package/dist/hook/manager.d.ts +1 -1
- package/dist/hook/manager.js +11 -8
- package/dist/live/message.d.ts +35 -70
- package/dist/live/messageInfo.d.ts +10 -8
- package/dist/live/platform.d.ts +1 -1
- package/dist/live/room.d.ts +27 -9
- package/dist/live/room.js +23 -23
- package/dist/plugin/context/CommonPluginContext.d.ts +2 -1
- package/dist/plugin/context/CommonPluginContext.js +4 -0
- package/dist/plugin/context/SafePluginContext.js +3 -1
- package/dist/plugin/manager.d.ts +1 -1
- package/dist/plugin/manager.js +41 -30
- package/dist/plugin/types.d.ts +6 -3
- package/dist/plugins/platform/index.d.ts +14 -6
- package/dist/plugins/platform/index.js +22 -7
- package/dist/plugins/room/index.d.ts +49 -21
- package/dist/plugins/room/index.js +174 -60
- package/dist/value/manager.d.ts +1 -1
- package/dist/value/manager.js +27 -6
- package/package.json +1 -1
package/LICENSE
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2023 Minteea
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
-
|
|
7
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
-
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Minteea
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
9
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
# Floating Live
|
|
2
|
-
|
|
3
|
-
一个用于处理和保存直播弹幕的 Web 小工具,开箱即用。
|
|
4
|
-
|
|
5
|
-
本体无弹幕获取功能,需要配合[floating-live-plugins](https://github.com/Minteea/floating-live-plugins)中的插件使用。
|
|
6
|
-
|
|
7
|
-
目前插件库支持 bilibili 和 AcFun 的直播弹幕,不同平台的弹幕会转换为同一种格式便于保存。
|
|
8
|
-
|
|
9
|
-
项目仍在开发中,功能尚未完善,目前除了记录保存直播弹幕外暂时没有别的用处啦,敬请期待。
|
|
10
|
-
|
|
11
|
-
注意:当前项目未进入正式版本阶段,程序结构及导出数据结构可能随时改动,**非常不建议用于正式项目中**。
|
|
12
|
-
|
|
13
|
-
GUI 版本:[Minteea/floating-live-gui](https://github.com/Minteea/floating-live-gui)
|
|
14
|
-
|
|
15
|
-
## 使用方法
|
|
16
|
-
|
|
17
|
-
### npm 安装
|
|
18
|
-
|
|
19
|
-
```
|
|
20
|
-
npm install floating-live
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
```javascript
|
|
24
|
-
// 导入FloatingLive本体
|
|
25
|
-
import { FloatingLive } from "floating-live";
|
|
26
|
-
// 导入bilibili房间生成插件
|
|
27
|
-
import bilibili from "@floating-live/bilibili";
|
|
28
|
-
|
|
29
|
-
// 创建一个FloatingLive实例
|
|
30
|
-
const live = new FloatingLive();
|
|
31
|
-
// 注册插件
|
|
32
|
-
live.plugin.register(bilibili);
|
|
33
|
-
|
|
34
|
-
// 添加房间并自动打开
|
|
35
|
-
live.room.add("bilibili", 6, true);
|
|
36
|
-
```
|
|
1
|
+
# Floating Live
|
|
2
|
+
|
|
3
|
+
一个用于处理和保存直播弹幕的 Web 小工具,开箱即用。
|
|
4
|
+
|
|
5
|
+
本体无弹幕获取功能,需要配合[floating-live-plugins](https://github.com/Minteea/floating-live-plugins)中的插件使用。
|
|
6
|
+
|
|
7
|
+
目前插件库支持 bilibili 和 AcFun 的直播弹幕,不同平台的弹幕会转换为同一种格式便于保存。
|
|
8
|
+
|
|
9
|
+
项目仍在开发中,功能尚未完善,目前除了记录保存直播弹幕外暂时没有别的用处啦,敬请期待。
|
|
10
|
+
|
|
11
|
+
注意:当前项目未进入正式版本阶段,程序结构及导出数据结构可能随时改动,**非常不建议用于正式项目中**。
|
|
12
|
+
|
|
13
|
+
GUI 版本:[Minteea/floating-live-gui](https://github.com/Minteea/floating-live-gui)
|
|
14
|
+
|
|
15
|
+
## 使用方法
|
|
16
|
+
|
|
17
|
+
### npm 安装
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
npm install floating-live
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
```javascript
|
|
24
|
+
// 导入FloatingLive本体
|
|
25
|
+
import { FloatingLive } from "floating-live";
|
|
26
|
+
// 导入bilibili房间生成插件
|
|
27
|
+
import bilibili from "@floating-live/bilibili";
|
|
28
|
+
|
|
29
|
+
// 创建一个FloatingLive实例
|
|
30
|
+
const live = new FloatingLive();
|
|
31
|
+
// 注册插件
|
|
32
|
+
live.plugin.register(bilibili);
|
|
33
|
+
|
|
34
|
+
// 添加房间并自动打开
|
|
35
|
+
live.room.add("bilibili", 6, true);
|
|
36
|
+
```
|
package/dist/FloatingLive.d.ts
CHANGED
|
@@ -13,8 +13,6 @@ export declare class FloatingLive extends App {
|
|
|
13
13
|
/** 获取房间 */
|
|
14
14
|
get(key: string): LiveRoom | import("./live/index.js").InvalidLiveRoom | undefined;
|
|
15
15
|
has(key: string): boolean;
|
|
16
|
-
/** 获取房间信息 */
|
|
17
|
-
data(key: string): import("./live/index.js").LiveRoomData | undefined;
|
|
18
16
|
/** 更新房间信息 */
|
|
19
17
|
update(key: string): void;
|
|
20
18
|
/** 打开房间连接 */
|
package/dist/FloatingLive.js
CHANGED
package/dist/app.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CommandOptions, CommandCallOptions, AppCommandMap, CommandFunction } from "./command/index.js";
|
|
1
|
+
import { CommandOptions, CommandCallOptions, AppCommandMap, CommandFunction, AppCommandAliasMap } from "./command/index.js";
|
|
2
2
|
import { CommandManager } from "./command/manager.js";
|
|
3
3
|
import { AppEventDetailMap, AppEventEmitOptions, AppEventListener } from "./event/index.js";
|
|
4
4
|
import { AppHookMap, HookCallOptions, HookContext, HookFunction, HookUseOptions } from "./hook/index.js";
|
|
@@ -31,6 +31,7 @@ export declare class App extends CustomEventEmitter implements PluginContext {
|
|
|
31
31
|
getPluginExposes(pluginName: string): any;
|
|
32
32
|
hasPlugin(pluginName: string): boolean;
|
|
33
33
|
registerCommand<T extends keyof AppCommandMap>(name: T, func: CommandFunction<AppCommandMap[T]>, options?: CommandOptions): void;
|
|
34
|
+
registerCommandAlias<T extends keyof AppCommandAliasMap>(name: T, targetName: AppCommandAliasMap[T], options?: CommandOptions): void;
|
|
34
35
|
unregisterCommand(name: string): void;
|
|
35
36
|
hasCommand(name: string): boolean;
|
|
36
37
|
call<T extends keyof AppCommandMap>(name: T, ...args: Parameters<AppCommandMap[T]>): ReturnType<AppCommandMap[T]>;
|
package/dist/app.js
CHANGED
|
@@ -16,7 +16,7 @@ export class App extends CustomEventEmitter {
|
|
|
16
16
|
this.valueManager = new ValueManager(this);
|
|
17
17
|
this.pluginManager = new PluginManager(this);
|
|
18
18
|
// 初始化命令
|
|
19
|
-
this.registerCommand("command.
|
|
19
|
+
this.registerCommand("command.getData", () => this.commandManager.getData());
|
|
20
20
|
this.registerCommand("get", (e, name) => this.getValue(name));
|
|
21
21
|
this.registerCommand("set", (e, name, value) => this.setValue(name, value));
|
|
22
22
|
}
|
|
@@ -66,6 +66,9 @@ export class App extends CustomEventEmitter {
|
|
|
66
66
|
registerCommand(name, func, options) {
|
|
67
67
|
this.commandManager.register(name, func, options);
|
|
68
68
|
}
|
|
69
|
+
registerCommandAlias(name, targetName, options) {
|
|
70
|
+
this.commandManager.registerAlias(name, targetName, options);
|
|
71
|
+
}
|
|
69
72
|
unregisterCommand(name) {
|
|
70
73
|
this.commandManager.unregister(name);
|
|
71
74
|
}
|
|
@@ -7,16 +7,20 @@ export declare class CommandManager {
|
|
|
7
7
|
constructor(app: App);
|
|
8
8
|
/** 注册命令 */
|
|
9
9
|
register(name: string, call: CommandFunction<any>, options?: CommandOptions): void;
|
|
10
|
+
/** 注册命令别名 */
|
|
11
|
+
registerAlias(name: string, targetName: string, options?: CommandOptions): void;
|
|
10
12
|
/** 注销命令 */
|
|
11
13
|
unregister(name: string): void;
|
|
12
14
|
/** 调用命令 */
|
|
13
15
|
call(name: string, ...args: any[]): any;
|
|
14
16
|
/** 调用命令(可配置) */
|
|
15
17
|
callWithOptions(name: string, options: CommandCallOptions, ...args: any[]): any;
|
|
18
|
+
/** 从命令别名调用命令 */
|
|
19
|
+
private _callAliasWithOptions;
|
|
16
20
|
/** 检测命令是否存在 */
|
|
17
21
|
has(name: string): boolean;
|
|
18
22
|
/** 获取数据 */
|
|
19
|
-
|
|
23
|
+
getData(): {
|
|
20
24
|
name: string;
|
|
21
25
|
pluginName: string | undefined;
|
|
22
26
|
}[];
|
package/dist/command/manager.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { appError } from "../error/index.js";
|
|
2
|
+
// 错误列表
|
|
3
|
+
// command:notFound 命令不存在
|
|
4
|
+
// command:alreadyExists 命令已存在
|
|
5
|
+
// command:aliasNotFound 命令别名指向的命令不存在
|
|
6
|
+
// command:aliasTargetUncallable 命令别名不可指向其他命令别名
|
|
2
7
|
export class CommandManager {
|
|
3
8
|
/** 功能列表 */
|
|
4
9
|
list = new Map();
|
|
@@ -12,6 +17,12 @@ export class CommandManager {
|
|
|
12
17
|
this.list.set(name, { call, pluginName });
|
|
13
18
|
this.app.emit("command:register", { name });
|
|
14
19
|
}
|
|
20
|
+
/** 注册命令别名 */
|
|
21
|
+
registerAlias(name, targetName, options) {
|
|
22
|
+
const { pluginName } = options || {};
|
|
23
|
+
this.list.set(name, { targetName, pluginName });
|
|
24
|
+
this.app.emit("command:register", { name });
|
|
25
|
+
}
|
|
15
26
|
/** 注销命令 */
|
|
16
27
|
unregister(name) {
|
|
17
28
|
this.list.delete(name);
|
|
@@ -25,13 +36,42 @@ export class CommandManager {
|
|
|
25
36
|
callWithOptions(name, options, ...args) {
|
|
26
37
|
const command = this.list.get(name);
|
|
27
38
|
if (!command) {
|
|
28
|
-
throw appError("command:
|
|
29
|
-
message:
|
|
39
|
+
throw appError("command:notFound", {
|
|
40
|
+
message: `命令不存在[${name}]`,
|
|
30
41
|
target: `command/${name}`,
|
|
42
|
+
action: "command.call",
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
const { call } = command;
|
|
47
|
+
if (!call) {
|
|
48
|
+
return this._callAliasWithOptions(name, command.targetName, options, ...args);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
return call({ source: options.source, client: options.client }, ...args);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/** 从命令别名调用命令 */
|
|
56
|
+
_callAliasWithOptions(name, targetName, options, ...args) {
|
|
57
|
+
const tcommand = this.list.get(targetName);
|
|
58
|
+
if (!tcommand) {
|
|
59
|
+
throw appError("command:aliasNotFound", {
|
|
60
|
+
message: `命令别名[${name}]指向的命令不存在[${targetName}]`,
|
|
61
|
+
target: `command/${name}>${targetName}`,
|
|
62
|
+
action: "command.call",
|
|
31
63
|
});
|
|
32
64
|
}
|
|
33
65
|
else {
|
|
34
|
-
|
|
66
|
+
const { call } = tcommand;
|
|
67
|
+
if (!call) {
|
|
68
|
+
throw appError("command:aliasTargetUncallable", {
|
|
69
|
+
message: `命令别名[${name}]不可指向其他命令别名[${targetName}]`,
|
|
70
|
+
target: `command/${name}>${targetName}>${tcommand.targetName}`,
|
|
71
|
+
action: "command.call",
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
return call({ source: options.source, client: options.client }, ...args);
|
|
35
75
|
}
|
|
36
76
|
}
|
|
37
77
|
/** 检测命令是否存在 */
|
|
@@ -39,7 +79,7 @@ export class CommandManager {
|
|
|
39
79
|
return this.list.has(name);
|
|
40
80
|
}
|
|
41
81
|
/** 获取数据 */
|
|
42
|
-
|
|
82
|
+
getData() {
|
|
43
83
|
return [...this.list].map(([name, { pluginName }]) => ({
|
|
44
84
|
name,
|
|
45
85
|
pluginName,
|
package/dist/command/types.d.ts
CHANGED
|
@@ -19,27 +19,36 @@ export interface CommandItem {
|
|
|
19
19
|
call: CommandFunction<any>;
|
|
20
20
|
pluginName?: string;
|
|
21
21
|
}
|
|
22
|
+
export interface CommandAliasItem {
|
|
23
|
+
call?: undefined;
|
|
24
|
+
targetName: string;
|
|
25
|
+
pluginName?: string;
|
|
26
|
+
}
|
|
27
|
+
/** 命令函数类型表 */
|
|
22
28
|
export interface AppCommandMap {
|
|
23
29
|
get: <T extends keyof AppValueMap>(name: T) => AppValueMap[T];
|
|
24
30
|
set: <T extends keyof AppValueMap>(name: T, value: AppValueMap[T]) => boolean;
|
|
25
|
-
/**
|
|
26
|
-
"value.
|
|
31
|
+
/** 获取注册值数据 */
|
|
32
|
+
"value.getData": () => {
|
|
27
33
|
name: string;
|
|
28
34
|
value: any;
|
|
29
35
|
}[];
|
|
30
|
-
/**
|
|
31
|
-
"command.
|
|
36
|
+
/** 获取命令数据 */
|
|
37
|
+
"command.getData": () => {
|
|
32
38
|
name: string;
|
|
33
39
|
}[];
|
|
34
|
-
/**
|
|
35
|
-
"plugin.
|
|
40
|
+
/** 获取插件数据 */
|
|
41
|
+
"plugin.getData": () => {
|
|
36
42
|
pluginName: string;
|
|
37
43
|
}[];
|
|
38
|
-
/** 获取hook
|
|
39
|
-
"hook.
|
|
44
|
+
/** 获取hook数据 */
|
|
45
|
+
"hook.getData": () => {
|
|
40
46
|
name: string;
|
|
41
47
|
list: {
|
|
42
48
|
pluginName?: string;
|
|
43
49
|
}[];
|
|
44
50
|
}[];
|
|
45
51
|
}
|
|
52
|
+
/** 命令别名映射 */
|
|
53
|
+
export interface AppCommandAliasMap {
|
|
54
|
+
}
|
package/dist/error/index.d.ts
CHANGED
|
@@ -2,12 +2,14 @@ export * from "./types.js";
|
|
|
2
2
|
export interface AppError extends Error {
|
|
3
3
|
/** 错误发生信息 */
|
|
4
4
|
cause: {
|
|
5
|
-
/**
|
|
6
|
-
|
|
5
|
+
/** 错误代码 */
|
|
6
|
+
code: string;
|
|
7
7
|
/** 错误目标对象 */
|
|
8
8
|
target?: string;
|
|
9
9
|
/** 错误原因 */
|
|
10
10
|
reason?: string | Error | AppError;
|
|
11
|
+
/** 调用行为 */
|
|
12
|
+
action?: string;
|
|
11
13
|
};
|
|
12
14
|
}
|
|
13
15
|
export interface AppErrorOptions {
|
|
@@ -17,8 +19,10 @@ export interface AppErrorOptions {
|
|
|
17
19
|
target?: string;
|
|
18
20
|
/** 错误原因 */
|
|
19
21
|
reason?: string | Error | AppError;
|
|
22
|
+
/** 调用行为 */
|
|
23
|
+
action?: string;
|
|
20
24
|
/** 错误构造函数 */
|
|
21
25
|
errorConstructor?: ErrorConstructor;
|
|
22
26
|
[key: string]: unknown;
|
|
23
27
|
}
|
|
24
|
-
export declare function appError(
|
|
28
|
+
export declare function appError(code: string, { message, target, reason, action, errorConstructor, }: AppErrorOptions): AppError;
|
package/dist/error/index.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
export * from "./types.js";
|
|
2
|
-
export function appError(
|
|
2
|
+
export function appError(code, { message, target, reason, action, errorConstructor = Error, }) {
|
|
3
3
|
return new errorConstructor(message, {
|
|
4
4
|
cause: {
|
|
5
|
-
|
|
5
|
+
code,
|
|
6
6
|
target,
|
|
7
7
|
reason,
|
|
8
|
+
action,
|
|
8
9
|
},
|
|
9
10
|
});
|
|
10
11
|
}
|
|
12
|
+
// 错误码分类
|
|
13
|
+
// http:xxx http状态码
|
|
14
|
+
// node:xxx nodejs错误码
|
package/dist/event/types.d.ts
CHANGED
package/dist/hook/manager.d.ts
CHANGED
package/dist/hook/manager.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { appError } from "../error/index.js";
|
|
2
|
+
// 错误列表
|
|
3
|
+
// hook:functionAlreadyExists 钩子函数已存在
|
|
4
|
+
// hook:functionNotFound 钩子函数不存在
|
|
2
5
|
export class HookManager {
|
|
3
6
|
list = new Map();
|
|
4
7
|
pluginMap = new Map();
|
|
5
8
|
app;
|
|
6
9
|
constructor(app) {
|
|
7
10
|
this.app = app;
|
|
8
|
-
app.registerCommand("hook.
|
|
11
|
+
app.registerCommand("hook.getData", () => this.getData());
|
|
9
12
|
}
|
|
10
13
|
/** 挂载钩子函数 */
|
|
11
14
|
use(name, call, options) {
|
|
@@ -16,10 +19,10 @@ export class HookManager {
|
|
|
16
19
|
this.list.set(name, hooks);
|
|
17
20
|
}
|
|
18
21
|
else if (hooks.includes(call)) {
|
|
19
|
-
throw appError("hook:
|
|
20
|
-
message:
|
|
21
|
-
reason: "重复挂载同一函数",
|
|
22
|
+
throw appError("hook:functionAlreadyExists", {
|
|
23
|
+
message: `无法重复挂载同一钩子函数: ${name}`,
|
|
22
24
|
target: `hook/${name}`,
|
|
25
|
+
action: "hook.use",
|
|
23
26
|
});
|
|
24
27
|
}
|
|
25
28
|
hooks.push({ call, pluginName });
|
|
@@ -29,10 +32,10 @@ export class HookManager {
|
|
|
29
32
|
let hooks = this.list.get(name);
|
|
30
33
|
const index = hooks?.findIndex((item) => item.call == call) ?? -1;
|
|
31
34
|
if (!hooks || index < 0)
|
|
32
|
-
throw appError("hook:
|
|
33
|
-
message:
|
|
34
|
-
reason: "卸载不存在的钩子函数",
|
|
35
|
+
throw appError("hook:functionNotFound", {
|
|
36
|
+
message: `无法卸载不存在的钩子函数: ${name}`,
|
|
35
37
|
target: `hook/${name}`,
|
|
38
|
+
action: "hook.unuse",
|
|
36
39
|
});
|
|
37
40
|
hooks.splice(index, 1);
|
|
38
41
|
}
|
|
@@ -64,7 +67,7 @@ export class HookManager {
|
|
|
64
67
|
}
|
|
65
68
|
return ctx;
|
|
66
69
|
}
|
|
67
|
-
|
|
70
|
+
getData() {
|
|
68
71
|
return [...this.list].map(([name, fnList]) => ({
|
|
69
72
|
name,
|
|
70
73
|
list: fnList.map(({ pluginName }) => ({ pluginName })),
|
package/dist/live/message.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { DanmakuMode, UserInfo, ImageInfo, GiftInfo, UserType } from "./messageInfo.js";
|
|
2
2
|
import { LiveRoomStatus, LiveRoomStatsInfo, LiveRoomDetailInfo } from "./room.js";
|
|
3
|
+
export interface LiveMessageExtensions {
|
|
4
|
+
}
|
|
3
5
|
export declare namespace LiveMessage {
|
|
4
6
|
interface Base {
|
|
5
7
|
/** 平台名称 */
|
|
@@ -12,15 +14,22 @@ export declare namespace LiveMessage {
|
|
|
12
14
|
type: string;
|
|
13
15
|
/** 时间戳 */
|
|
14
16
|
timestamp: number;
|
|
15
|
-
/** 消息id
|
|
17
|
+
/** 消息id
|
|
18
|
+
*
|
|
19
|
+
* 须保证不重复性,规范id格式如下:
|
|
20
|
+
*
|
|
21
|
+
* 用户相关消息:platform:roomId-type:userId-uniqueId
|
|
22
|
+
*
|
|
23
|
+
* 房间相关消息:platform:roomId-type-uniqueId
|
|
24
|
+
* */
|
|
16
25
|
id: string;
|
|
17
|
-
/**
|
|
18
|
-
|
|
26
|
+
/** 拓展属性 */
|
|
27
|
+
extension?: LiveMessageExtensions;
|
|
19
28
|
}
|
|
20
29
|
/** 聊天消息 */
|
|
21
30
|
interface Comment extends Base {
|
|
22
31
|
type: "comment";
|
|
23
|
-
|
|
32
|
+
data: {
|
|
24
33
|
/** 用户信息 */
|
|
25
34
|
user: UserInfo;
|
|
26
35
|
/** 文本内容 */
|
|
@@ -44,7 +53,7 @@ export declare namespace LiveMessage {
|
|
|
44
53
|
/** 礼物消息 */
|
|
45
54
|
interface Gift extends Base {
|
|
46
55
|
type: "gift";
|
|
47
|
-
|
|
56
|
+
data: {
|
|
48
57
|
/** 用户信息 */
|
|
49
58
|
user: UserInfo;
|
|
50
59
|
/** 礼物信息 */
|
|
@@ -54,7 +63,7 @@ export declare namespace LiveMessage {
|
|
|
54
63
|
/** 互动消息(进入直播间、点赞、关注、分享、加入粉丝团) */
|
|
55
64
|
interface Interact extends Base {
|
|
56
65
|
type: "entry" | "like" | "follow" | "share" | "join";
|
|
57
|
-
|
|
66
|
+
data: {
|
|
58
67
|
/** 用户信息 */
|
|
59
68
|
user: UserInfo;
|
|
60
69
|
/** 信息标签 */
|
|
@@ -64,7 +73,7 @@ export declare namespace LiveMessage {
|
|
|
64
73
|
/** 粉丝vip开通消息 */
|
|
65
74
|
interface Membership extends Base {
|
|
66
75
|
type: "membership";
|
|
67
|
-
|
|
76
|
+
data: {
|
|
68
77
|
/** 用户信息 */
|
|
69
78
|
user: UserInfo;
|
|
70
79
|
/** 礼物信息 */
|
|
@@ -77,12 +86,12 @@ export declare namespace LiveMessage {
|
|
|
77
86
|
duration: number;
|
|
78
87
|
};
|
|
79
88
|
}
|
|
80
|
-
/**
|
|
89
|
+
/** 付费留言消息 */
|
|
81
90
|
interface Superchat extends Base {
|
|
82
91
|
type: "superchat";
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
|
|
92
|
+
data: {
|
|
93
|
+
/** 留言代码,用于撤回消息 */
|
|
94
|
+
token: string | number;
|
|
86
95
|
/** 用户信息 */
|
|
87
96
|
user: UserInfo;
|
|
88
97
|
/** 文本内容 */
|
|
@@ -95,10 +104,17 @@ export declare namespace LiveMessage {
|
|
|
95
104
|
duration: number;
|
|
96
105
|
};
|
|
97
106
|
}
|
|
107
|
+
/** 付费留言删除消息 */
|
|
108
|
+
interface SuperchatDelete extends Base {
|
|
109
|
+
type: "superchat_delete";
|
|
110
|
+
data: {
|
|
111
|
+
token: string;
|
|
112
|
+
};
|
|
113
|
+
}
|
|
98
114
|
/** 禁言消息 */
|
|
99
115
|
interface Block extends Base {
|
|
100
116
|
type: "block";
|
|
101
|
-
|
|
117
|
+
data: {
|
|
102
118
|
/** 用户信息 */
|
|
103
119
|
user: UserInfo;
|
|
104
120
|
/** 操作者 */
|
|
@@ -110,7 +126,7 @@ export declare namespace LiveMessage {
|
|
|
110
126
|
/** 直播开播消息 */
|
|
111
127
|
interface LiveStart extends Base {
|
|
112
128
|
type: "live_start";
|
|
113
|
-
|
|
129
|
+
data: {
|
|
114
130
|
/** 直播id */
|
|
115
131
|
id: string;
|
|
116
132
|
};
|
|
@@ -118,7 +134,7 @@ export declare namespace LiveMessage {
|
|
|
118
134
|
/** 直播结束 */
|
|
119
135
|
interface LiveEnd extends Base {
|
|
120
136
|
type: "live_end";
|
|
121
|
-
|
|
137
|
+
data: {
|
|
122
138
|
/** 直播状态 */
|
|
123
139
|
status: LiveRoomStatus;
|
|
124
140
|
};
|
|
@@ -126,72 +142,21 @@ export declare namespace LiveMessage {
|
|
|
126
142
|
/** 直播切断消息 */
|
|
127
143
|
interface LiveCut extends Base {
|
|
128
144
|
type: "live_cut";
|
|
129
|
-
|
|
145
|
+
data: {
|
|
130
146
|
/** 切断消息 */
|
|
131
147
|
message: string;
|
|
148
|
+
status: LiveRoomStatus;
|
|
132
149
|
};
|
|
133
150
|
}
|
|
134
151
|
/** 直播数据更新 */
|
|
135
152
|
interface LiveStats extends Base {
|
|
136
153
|
type: "live_stats";
|
|
137
|
-
|
|
154
|
+
data: LiveRoomStatsInfo;
|
|
138
155
|
}
|
|
139
156
|
/** 直播展示信息更新 */
|
|
140
157
|
interface LiveDetail extends Base {
|
|
141
158
|
type: "live_detail";
|
|
142
|
-
|
|
143
|
-
}
|
|
144
|
-
/** 主播抽奖 */
|
|
145
|
-
interface Lottery extends Base {
|
|
146
|
-
type: "lottery";
|
|
147
|
-
info: {
|
|
148
|
-
title: string;
|
|
149
|
-
role: "user" | "anchor";
|
|
150
|
-
user?: UserInfo;
|
|
151
|
-
gift?: GiftInfo;
|
|
152
|
-
id: string | number;
|
|
153
|
-
award?: GiftInfo | GiftInfo[];
|
|
154
|
-
value?: number;
|
|
155
|
-
valueType?: string | number;
|
|
156
|
-
price?: number;
|
|
157
|
-
currency?: string;
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
/** 主播抽奖结果 */
|
|
161
|
-
interface LotteryResult extends Base {
|
|
162
|
-
type: "lottery_result";
|
|
163
|
-
info: {
|
|
164
|
-
title: string;
|
|
165
|
-
role: "user" | "anchor";
|
|
166
|
-
id: string | number;
|
|
167
|
-
result: {
|
|
168
|
-
user: UserInfo;
|
|
169
|
-
award: GiftInfo | GiftInfo[];
|
|
170
|
-
}[];
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
/** 发送红包 */
|
|
174
|
-
interface Redpacket extends Base {
|
|
175
|
-
type: "redpacket";
|
|
176
|
-
info: {
|
|
177
|
-
id: string | number;
|
|
178
|
-
gifts?: GiftInfo[];
|
|
179
|
-
value?: number;
|
|
180
|
-
currency?: string | number;
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
/** 红包抽奖结果 */
|
|
184
|
-
interface RedpacketResult extends Base {
|
|
185
|
-
type: "redpacket_result";
|
|
186
|
-
info: {
|
|
187
|
-
id: string | number;
|
|
188
|
-
result: {
|
|
189
|
-
user: UserInfo;
|
|
190
|
-
gift?: GiftInfo;
|
|
191
|
-
value?: number;
|
|
192
|
-
currency?: string | number;
|
|
193
|
-
}[];
|
|
194
|
-
};
|
|
159
|
+
data: LiveRoomDetailInfo;
|
|
195
160
|
}
|
|
196
|
-
type All = Comment | Gift | Interact | Membership | Superchat | Block | LiveStart | LiveEnd | LiveCut | LiveDetail | LiveStats
|
|
161
|
+
type All = Comment | Gift | Interact | Membership | Superchat | Block | LiveStart | LiveEnd | LiveCut | LiveDetail | LiveStats;
|
|
197
162
|
}
|
|
@@ -13,8 +13,8 @@ export interface UserInfo {
|
|
|
13
13
|
type?: UserType;
|
|
14
14
|
/** 粉丝vip等级 */
|
|
15
15
|
membership?: boolean | number;
|
|
16
|
-
/** vip等级 */
|
|
17
|
-
|
|
16
|
+
/** 平台vip等级 */
|
|
17
|
+
premium?: boolean | number;
|
|
18
18
|
/** 用户等级 */
|
|
19
19
|
level?: number;
|
|
20
20
|
}
|
|
@@ -50,18 +50,20 @@ export interface GiftInfo {
|
|
|
50
50
|
num: number;
|
|
51
51
|
/** 礼物价值(总价,按平台货币计算) */
|
|
52
52
|
value?: number;
|
|
53
|
-
/**
|
|
53
|
+
/** 平台货币类型 */
|
|
54
54
|
valueType?: string | number;
|
|
55
|
+
/** 显示的平台货币数量 */
|
|
56
|
+
coins?: number;
|
|
55
57
|
/** 平台货币名称 */
|
|
56
|
-
|
|
57
|
-
/** 礼物连击数 */
|
|
58
|
-
combo?: number;
|
|
59
|
-
/** 礼物连击id */
|
|
60
|
-
comboId?: string;
|
|
58
|
+
coinName?: string;
|
|
61
59
|
/** 礼物金额(总价,按消费现金计算) */
|
|
62
60
|
price?: number;
|
|
63
61
|
/** 礼物金额货币 */
|
|
64
62
|
currency?: string;
|
|
63
|
+
/** 礼物连击数 */
|
|
64
|
+
combo?: number;
|
|
65
|
+
/** 礼物连击id */
|
|
66
|
+
comboId?: string;
|
|
65
67
|
/** 行为 */
|
|
66
68
|
action?: string;
|
|
67
69
|
/** 随机礼物信息 */
|