floating-live 0.14.1 → 0.14.3
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/acfunLive.d.ts +1 -1
- package/plugin/acfun/acfunLive.js +1 -0
- package/plugin/acfun/index.js +1 -1
- package/plugin/bilibili/index.js +1 -1
- package/plugin/bilibili/room.d.ts +1 -1
- package/plugin/bilibili/room.js +1 -0
- package/plugin/msgSave/index.js +1 -1
- package/plugin/msgSave/msgSave.js +2 -2
- package/src/abstract/LiveRoom.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} +5 -5
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -36,7 +36,7 @@ declare class acfunLive extends LiveRoom {
|
|
|
36
36
|
/** 直播间是否可用 */
|
|
37
37
|
get available(): boolean;
|
|
38
38
|
constructor(id: number, open?: boolean);
|
|
39
|
-
getInfo(): Promise<
|
|
39
|
+
getInfo(): Promise<import("../..").RoomInfo>;
|
|
40
40
|
/** 开启直播间监听 */
|
|
41
41
|
open(): Promise<void>;
|
|
42
42
|
/** 初始化直播服务端监听 */
|
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/bilibili/room.js
CHANGED
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",
|
|
@@ -32,7 +32,7 @@ export declare abstract class LiveRoom extends EventEmitter implements RoomInfo
|
|
|
32
32
|
/** 关闭连接 */
|
|
33
33
|
abstract close(): void;
|
|
34
34
|
/** 从服务器获取信息 */
|
|
35
|
-
abstract getInfo(): Promise<
|
|
35
|
+
abstract getInfo(): Promise<RoomInfo>;
|
|
36
36
|
/** 销毁事件 */
|
|
37
37
|
protected onDestory?(): void;
|
|
38
38
|
/** 销毁 */
|
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,16 +1,16 @@
|
|
|
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);
|
|
@@ -156,4 +156,4 @@ class ModRooms {
|
|
|
156
156
|
room?.opened && room.close();
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
|
-
exports.
|
|
159
|
+
exports.ModRoom = ModRoom;
|