floating-live 0.14.0 → 0.14.2
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 +1 -1
- package/package.json +1 -1
- package/plugin/acfun/index.js +1 -1
- package/plugin/bilibili/index.js +1 -1
- package/plugin/msgSave/index.js +1 -1
- package/plugin/msgSave/msgSave.js +2 -2
- package/src/abstract/Reglist.d.ts +1 -1
- package/src/index.d.ts +2 -2
- package/src/index.js +2 -2
- package/src/module/ModAuth.js +1 -1
- package/src/module/ModCommand.d.ts +1 -1
- package/src/module/ModCommand.js +1 -1
- package/src/module/{ModRooms.d.ts → ModRoom.d.ts} +1 -1
- package/src/module/{ModRooms.js → ModRoom.js} +6 -6
- package/src/module/ModState.d.ts +6 -0
- package/src/module/ModState.js +12 -0
package/README.md
CHANGED
package/package.json
CHANGED
package/plugin/acfun/index.js
CHANGED
package/plugin/bilibili/index.js
CHANGED
|
@@ -18,7 +18,7 @@ module.exports = () => {
|
|
|
18
18
|
return {
|
|
19
19
|
name: "bilibili",
|
|
20
20
|
register: (ctx) => {
|
|
21
|
-
ctx.
|
|
21
|
+
ctx.room.generator.register("bilibili", (id, open, config) => {
|
|
22
22
|
return new room_1.default(Number(id), open, config);
|
|
23
23
|
});
|
|
24
24
|
ctx.auth.options.register("bilibili", authConfig);
|
package/plugin/msgSave/index.js
CHANGED
|
@@ -15,7 +15,7 @@ const messageSave = () => {
|
|
|
15
15
|
});
|
|
16
16
|
// 直播状态改变时,更新保存信息
|
|
17
17
|
ctx.on("room:status", (roomKey, status, { timestamp }) => {
|
|
18
|
-
const { platform, id } = ctx.
|
|
18
|
+
const { platform, id } = ctx.room.get(roomKey).info;
|
|
19
19
|
saveMessage.setSaveInfo({
|
|
20
20
|
platform,
|
|
21
21
|
room: id,
|
|
@@ -121,7 +121,7 @@ class MsgSave {
|
|
|
121
121
|
}
|
|
122
122
|
/** 创建保存信息,用于记录信息可能不存在的情况 */
|
|
123
123
|
createSaveInfo({ platform, room, }) {
|
|
124
|
-
const { status, timestamp } = this.main.
|
|
124
|
+
const { status, timestamp } = this.main.room.get(`${platform}:${room}`)
|
|
125
125
|
?.info || { status: __1.RoomStatus.off, timestamp: 0 };
|
|
126
126
|
const saveInfoConfig = {
|
|
127
127
|
platform,
|
|
@@ -153,7 +153,7 @@ class MsgSave {
|
|
|
153
153
|
statusChanged: saveInfo.statusChanged,
|
|
154
154
|
index: saveInfo.totalCount,
|
|
155
155
|
part: saveInfo.part,
|
|
156
|
-
roomInfo: this.main.
|
|
156
|
+
roomInfo: this.main.room.get(roomKey)?.info,
|
|
157
157
|
};
|
|
158
158
|
fs_extra_1.default.writeFileSync(file, JSON.stringify(message) + ",", {
|
|
159
159
|
encoding: "utf8",
|
|
@@ -6,7 +6,7 @@ export declare class Reglist<T> {
|
|
|
6
6
|
/** 插件与功能名称绑定表 */
|
|
7
7
|
private readonly pluginIdMap;
|
|
8
8
|
private readonly name;
|
|
9
|
-
|
|
9
|
+
protected readonly main: FloatingLive;
|
|
10
10
|
constructor(main: FloatingLive, name: string);
|
|
11
11
|
/** 注册一个对象 */
|
|
12
12
|
register(id: string, item: T): void;
|
package/src/index.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { EventEmitter } from "events";
|
|
3
3
|
import { ModPlugin } from "./module/ModPlugin";
|
|
4
|
-
import {
|
|
4
|
+
import { ModRoom } from "./module/ModRoom";
|
|
5
5
|
import { ModAuth } from "./module/ModAuth";
|
|
6
6
|
import { ModMessage } from "./module/ModMessage";
|
|
7
7
|
import { ModState } from "./module/ModState";
|
|
8
8
|
import ModCommand from "./module/ModCommand";
|
|
9
9
|
export declare class FloatingLive extends EventEmitter {
|
|
10
10
|
/** 房间控制模块 */
|
|
11
|
-
|
|
11
|
+
room: ModRoom;
|
|
12
12
|
/** 消息处理模块 */
|
|
13
13
|
message: ModMessage;
|
|
14
14
|
/** 用户登录凭据模块 */
|
package/src/index.js
CHANGED
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.FloatingLive = void 0;
|
|
7
7
|
const events_1 = require("events");
|
|
8
8
|
const ModPlugin_1 = require("./module/ModPlugin");
|
|
9
|
-
const
|
|
9
|
+
const ModRoom_1 = require("./module/ModRoom");
|
|
10
10
|
const ModAuth_1 = require("./module/ModAuth");
|
|
11
11
|
const ModMessage_1 = require("./module/ModMessage");
|
|
12
12
|
const ModState_1 = require("./module/ModState");
|
|
@@ -19,7 +19,7 @@ class FloatingLive extends events_1.EventEmitter {
|
|
|
19
19
|
this.command = new ModCommand_1.default(this);
|
|
20
20
|
this.state = new ModState_1.ModState(this);
|
|
21
21
|
this.plugin = new ModPlugin_1.ModPlugin(this);
|
|
22
|
-
this.
|
|
22
|
+
this.room = new ModRoom_1.ModRoom(this);
|
|
23
23
|
this.message = new ModMessage_1.ModMessage(this);
|
|
24
24
|
this.auth = new ModAuth_1.ModAuth(this);
|
|
25
25
|
this.init();
|
package/src/module/ModAuth.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FloatingLive } from "..";
|
|
2
2
|
import { Reglist } from "../abstract/Reglist";
|
|
3
|
-
export default class ModCommand extends Reglist<(
|
|
3
|
+
export default class ModCommand extends Reglist<(...args: any[]) => any> {
|
|
4
4
|
constructor(main: FloatingLive);
|
|
5
5
|
/** 批量注册命令 */
|
|
6
6
|
batchRegister(list: Record<string, (...args: any) => any>): void;
|
package/src/module/ModCommand.js
CHANGED
|
@@ -3,7 +3,7 @@ import { LiveRoom } from "../abstract/LiveRoom";
|
|
|
3
3
|
import { FloatingLive } from "..";
|
|
4
4
|
import { RoomInfo } from "../types";
|
|
5
5
|
/** 直播间监听实例控制器 */
|
|
6
|
-
export declare class
|
|
6
|
+
export declare class ModRoom {
|
|
7
7
|
readonly main: FloatingLive;
|
|
8
8
|
private roomMap;
|
|
9
9
|
private auths;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.ModRoom = void 0;
|
|
4
4
|
const Reglist_1 = require("../abstract/Reglist");
|
|
5
5
|
/** 直播间监听实例控制器 */
|
|
6
|
-
class
|
|
6
|
+
class ModRoom {
|
|
7
7
|
constructor(main) {
|
|
8
8
|
this.roomMap = new Map();
|
|
9
9
|
this.auths = new Map();
|
|
10
10
|
this.configs = new Map();
|
|
11
11
|
this.main = main;
|
|
12
|
-
this.generator = new Reglist_1.Reglist(this.main, "
|
|
13
|
-
this.main.state.register("
|
|
12
|
+
this.generator = new Reglist_1.Reglist(this.main, "room.generator");
|
|
13
|
+
this.main.state.register("room", () => {
|
|
14
14
|
const list = [];
|
|
15
15
|
this.roomMap.forEach((room) => {
|
|
16
16
|
list.push(room.info);
|
|
17
17
|
});
|
|
18
|
-
return list;
|
|
18
|
+
return { list };
|
|
19
19
|
});
|
|
20
20
|
this.main.command.batchRegister({
|
|
21
21
|
add: (platform, id, open) => {
|
|
@@ -156,4 +156,4 @@ class ModRooms {
|
|
|
156
156
|
room?.opened && room.close();
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
|
-
exports.
|
|
159
|
+
exports.ModRoom = ModRoom;
|
package/src/module/ModState.d.ts
CHANGED
|
@@ -3,4 +3,10 @@ import { Reglist } from "../abstract/Reglist";
|
|
|
3
3
|
export declare class ModState extends Reglist<() => object> {
|
|
4
4
|
constructor(main: FloatingLive);
|
|
5
5
|
generate(): Record<string, any>;
|
|
6
|
+
/** 设置一个值 */
|
|
7
|
+
set(name: string, value: any): void;
|
|
8
|
+
/** 在数组中添加一个值 */
|
|
9
|
+
arrayPush(name: string, value: any): void;
|
|
10
|
+
/** 在数组中移除一个值 */
|
|
11
|
+
arrayRemove(name: string, key: string, val: string): void;
|
|
6
12
|
}
|
package/src/module/ModState.js
CHANGED
|
@@ -13,5 +13,17 @@ class ModState extends Reglist_1.Reglist {
|
|
|
13
13
|
});
|
|
14
14
|
return state;
|
|
15
15
|
}
|
|
16
|
+
/** 设置一个值 */
|
|
17
|
+
set(name, value) {
|
|
18
|
+
this.main.emit("state:set", name, value);
|
|
19
|
+
}
|
|
20
|
+
/** 在数组中添加一个值 */
|
|
21
|
+
arrayPush(name, value) {
|
|
22
|
+
this.main.emit("state:array_push", name, value);
|
|
23
|
+
}
|
|
24
|
+
/** 在数组中移除一个值 */
|
|
25
|
+
arrayRemove(name, key, val) {
|
|
26
|
+
this.main.emit("state:array_remove", name, key, val);
|
|
27
|
+
}
|
|
16
28
|
}
|
|
17
29
|
exports.ModState = ModState;
|