floating-live 0.14.11 → 0.15.0-beta.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.
Files changed (65) hide show
  1. package/LICENSE +5 -670
  2. package/README.md +3 -34
  3. package/{src/abstract → dist/core}/LiveRoom.d.ts +1 -3
  4. package/{src/abstract → dist/core}/LiveRoom.js +6 -6
  5. package/{src/abstract → dist/core}/Reglist.d.ts +1 -1
  6. package/dist/core/index.d.ts +2 -0
  7. package/dist/core/index.js +18 -0
  8. package/dist/index.d.ts +6 -0
  9. package/{index.js → dist/index.js} +7 -7
  10. package/{src/index.d.ts → dist/live.d.ts} +0 -3
  11. package/{src/index.js → dist/live.js} +0 -2
  12. package/{src → dist}/module/ModCommand.d.ts +2 -2
  13. package/{src → dist}/module/ModCommand.js +1 -1
  14. package/{src → dist}/module/ModMessage.d.ts +2 -2
  15. package/{src → dist}/module/ModMessage.js +1 -1
  16. package/{src → dist}/module/ModPlugin.d.ts +1 -1
  17. package/{src → dist}/module/ModRoom.d.ts +3 -5
  18. package/{src → dist}/module/ModRoom.js +1 -10
  19. package/{src → dist}/module/ModState.d.ts +2 -2
  20. package/{src → dist}/module/ModState.js +1 -1
  21. package/{src → dist}/types/index.d.ts +0 -1
  22. package/{src → dist}/types/index.js +0 -1
  23. package/{src → dist}/types/message.d.ts +2 -2
  24. package/{src → dist}/types/plugin.d.ts +1 -1
  25. package/{src → dist}/types/room.d.ts +1 -1
  26. package/package.json +29 -15
  27. package/index.d.ts +0 -6
  28. package/plugin/acfun/acfunLive.d.ts +0 -74
  29. package/plugin/acfun/acfunLive.js +0 -279
  30. package/plugin/acfun/index.d.ts +0 -3
  31. package/plugin/acfun/index.js +0 -16
  32. package/plugin/bilibili/index.d.ts +0 -6
  33. package/plugin/bilibili/index.js +0 -45
  34. package/plugin/bilibili/parser.d.ts +0 -6
  35. package/plugin/bilibili/parser.js +0 -397
  36. package/plugin/bilibili/room.d.ts +0 -77
  37. package/plugin/bilibili/room.js +0 -261
  38. package/plugin/bilibili/types.d.ts +0 -424
  39. package/plugin/bilibili/types.js +0 -2
  40. package/plugin/bilibili/utils.d.ts +0 -17
  41. package/plugin/bilibili/utils.js +0 -137
  42. package/plugin/chatPrint/chatPrint.d.ts +0 -20
  43. package/plugin/chatPrint/chatPrint.js +0 -116
  44. package/plugin/chatPrint/index.d.ts +0 -7
  45. package/plugin/chatPrint/index.js +0 -10
  46. package/plugin/consoleEvent/index.d.ts +0 -6
  47. package/plugin/consoleEvent/index.js +0 -51
  48. package/plugin/msgSave/index.d.ts +0 -10
  49. package/plugin/msgSave/index.js +0 -81
  50. package/plugin/msgSave/msgSave.d.ts +0 -83
  51. package/plugin/msgSave/msgSave.js +0 -168
  52. package/src/module/ModAuth.d.ts +0 -10
  53. package/src/module/ModAuth.js +0 -35
  54. package/src/types/auth.d.ts +0 -19
  55. package/src/types/auth.js +0 -2
  56. package/test/type/bilibili_getInfoByRoom.d.ts +0 -492
  57. /package/{src/abstract → dist/core}/Reglist.js +0 -0
  58. /package/{src/enum.d.ts → dist/enums.d.ts} +0 -0
  59. /package/{src/enum.js → dist/enums.js} +0 -0
  60. /package/{src → dist}/module/ModPlugin.js +0 -0
  61. /package/{src → dist}/types/message.js +0 -0
  62. /package/{src → dist}/types/plugin.js +0 -0
  63. /package/{src → dist}/types/room.js +0 -0
  64. /package/{src → dist}/utils.d.ts +0 -0
  65. /package/{src → dist}/utils.js +0 -0
@@ -1,168 +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 __1 = require("../..");
7
- const fs_extra_1 = __importDefault(require("fs-extra"));
8
- const path_1 = __importDefault(require("path"));
9
- function getTimeStr(timestamp) {
10
- let startDate = new Date(timestamp);
11
- return `${startDate.getFullYear()}${(startDate.getMonth() + 1)
12
- .toString()
13
- .padStart(2, "0")}${startDate
14
- .getDate()
15
- .toString()
16
- .padStart(2, "0")}_${startDate
17
- .getHours()
18
- .toString()
19
- .padStart(2, "0")}${startDate
20
- .getMinutes()
21
- .toString()
22
- .padStart(2, "0")}${startDate.getSeconds().toString().padStart(2, "0")}`;
23
- }
24
- /** 获取当次记录状态
25
- * S=直播开始 L=直播中 E=直播结束 O=未开播
26
- */
27
- function getRecordStatus(status, statusChanged) {
28
- if (status == __1.RoomStatus.live) {
29
- /** 已开播 */
30
- return statusChanged ? "S" : "L";
31
- }
32
- else {
33
- /** 未开播 */
34
- return statusChanged ? "E" : "O";
35
- }
36
- }
37
- class SaveInfo {
38
- constructor({ platform, room, status, timestamp, statusChanged, sliceByStatus = false, sliceByCount = 0, }) {
39
- /** 文件是否存在 */
40
- this.exist = false;
41
- /** 记录状态是否已更改 */
42
- this.statusChanged = false;
43
- /** 消息记录数 */
44
- this.count = 0;
45
- /** 总消息记录数 */
46
- this.totalCount = 0;
47
- this.platform = platform;
48
- this.room = room;
49
- this.status = status;
50
- this.timestamp = timestamp;
51
- this.statusChanged = statusChanged;
52
- this.sliceByStatus = sliceByStatus;
53
- this.sliceByCount = sliceByCount;
54
- this.part = sliceByCount && 1;
55
- }
56
- /** 文件id */
57
- get fileId() {
58
- return `${this.platform}_${this.room}-${getTimeStr(this.timestamp || 0)}${this.sliceByStatus ? getRecordStatus(this.status, this.statusChanged) : ""}${this.part ? `.${this.part}` : ""}`;
59
- }
60
- /** 分块 */
61
- slice() {
62
- this.exist = false;
63
- this.count = 0;
64
- this.part += 1;
65
- }
66
- }
67
- class MsgSave {
68
- constructor(main, { filePath, prefix = "", suffix = "", open = true, sliceByStatus = false, sliceByCount = 0, }) {
69
- /** 列表 */
70
- this.list = new Map();
71
- this.paused = !open;
72
- this.main = main;
73
- this.path = filePath;
74
- this.prefix = prefix;
75
- this.suffix = suffix;
76
- this.sliceByStatus = sliceByStatus;
77
- this.sliceByCount = sliceByCount;
78
- }
79
- write(message, { platform, room }) {
80
- if (this.paused)
81
- return;
82
- const roomKey = `${platform}:${room}`;
83
- // 获取保存信息,若信息不存在,则设置一个信息
84
- const saveInfo = this.list.get(roomKey) || this.createSaveInfo({ platform, room });
85
- // 若文件不存在,则创建一个有record_info信息的.floatrec文件
86
- if (!saveInfo.exist)
87
- this.createFile(roomKey);
88
- const file = path_1.default.join(this.path, `${this.prefix}${saveInfo.fileId}${this.suffix}.floatrec`);
89
- fs_extra_1.default.writeFile(file, JSON.stringify(message) + ",", { encoding: "utf8", flag: "a" }, (err) => {
90
- if (err)
91
- throw err;
92
- // console.log('写入成功');
93
- });
94
- // 保存信息递增
95
- saveInfo.count += 1;
96
- // 若单文件保存信息已达最大值,则切分到下一个文件
97
- if (saveInfo.sliceByCount && saveInfo.sliceByCount <= saveInfo.count)
98
- saveInfo.slice();
99
- }
100
- start() {
101
- this.paused = false;
102
- }
103
- pause() {
104
- this.paused = true;
105
- }
106
- /** 设置保存信息 */
107
- setSaveInfo({ platform, room, status, timestamp, statusChanged, }) {
108
- const saveInfo = new SaveInfo({
109
- platform,
110
- room,
111
- status,
112
- timestamp,
113
- statusChanged,
114
- sliceByStatus: this.sliceByStatus,
115
- sliceByCount: this.sliceByCount,
116
- });
117
- const roomKey = `${platform}:${room}`;
118
- if (this.list.get(roomKey)?.fileId == saveInfo.fileId)
119
- return;
120
- this.list.set(roomKey, saveInfo);
121
- }
122
- /** 创建保存信息,用于记录信息可能不存在的情况 */
123
- createSaveInfo({ platform, room, }) {
124
- const { status, timestamp } = this.main.room.get(`${platform}:${room}`)
125
- ?.info || { status: __1.RoomStatus.off, timestamp: 0 };
126
- const saveInfoConfig = {
127
- platform,
128
- room,
129
- status,
130
- timestamp,
131
- statusChanged: false,
132
- sliceByStatus: this.sliceByStatus,
133
- sliceByCount: this.sliceByCount,
134
- };
135
- this.setSaveInfo(saveInfoConfig);
136
- return this.list.get(`${platform}:${room}`);
137
- }
138
- /** 创建记录文件 */
139
- createFile(roomKey) {
140
- const saveInfo = this.list.get(roomKey);
141
- const file = path_1.default.join(this.path, `${this.prefix}${saveInfo.fileId}${this.suffix}.floatrec`);
142
- // 如果文件已存在,则将文件标记为已存在,否则创建一个文件并写入record_info信息
143
- if (fs_extra_1.default.existsSync(file)) {
144
- saveInfo.exist = true;
145
- return;
146
- }
147
- fs_extra_1.default.ensureFileSync(file);
148
- const message = {
149
- type: "record_info",
150
- platform: saveInfo.platform,
151
- room: saveInfo.room,
152
- timestamp: saveInfo.timestamp,
153
- statusChanged: saveInfo.statusChanged,
154
- index: saveInfo.totalCount,
155
- part: saveInfo.part,
156
- roomInfo: this.main.room.get(roomKey)?.info,
157
- };
158
- fs_extra_1.default.writeFileSync(file, JSON.stringify(message) + ",", {
159
- encoding: "utf8",
160
- flag: "a",
161
- });
162
- }
163
- /** 移除记录信息 */
164
- removeSaveInfo(roomKey) {
165
- this.list.delete(roomKey);
166
- }
167
- }
168
- exports.default = MsgSave;
@@ -1,10 +0,0 @@
1
- import { Reglist } from "../abstract/Reglist";
2
- import { FloatingLive } from "..";
3
- import { AuthOptions } from "../types/auth";
4
- export declare class ModAuth {
5
- options: Reglist<AuthOptions>;
6
- status: Record<string, string | number>;
7
- main: FloatingLive;
8
- constructor(main: FloatingLive);
9
- set(name: string, auth: string): void;
10
- }
@@ -1,35 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ModAuth = void 0;
4
- const Reglist_1 = require("../abstract/Reglist");
5
- class ModAuth {
6
- constructor(main) {
7
- this.status = {};
8
- this.options = new Reglist_1.Reglist(main, "auth.options");
9
- this.main = main;
10
- this.main.state.register("auth", () => {
11
- const options = {};
12
- this.options.forEach((val, key) => {
13
- options[key] = val;
14
- });
15
- return {
16
- options: options,
17
- status: this.status,
18
- };
19
- });
20
- this.main.command.batchRegister({
21
- auth: (platform, auth) => {
22
- if (this.main.command.has(`auth.${platform}`)) {
23
- this.main.command.execute(`auth.${platform}`, auth);
24
- }
25
- else {
26
- this.set(platform, auth);
27
- }
28
- },
29
- });
30
- }
31
- set(name, auth) {
32
- this.main.room.setAuth(name, auth);
33
- }
34
- }
35
- exports.ModAuth = ModAuth;
@@ -1,19 +0,0 @@
1
- export interface AuthOptions {
2
- /** 直接输入凭证 */
3
- auth: {
4
- /** 凭证类型 */
5
- type: string;
6
- };
7
- /** 二维码登录 */
8
- qrcode?: {
9
- /** 二维码类型 */
10
- type: "url" | "base64";
11
- };
12
- /** 验证码登录 */
13
- verify?: {
14
- /** 验证码发送等待间隔(秒) */
15
- wait: number;
16
- /** 第三方验证接口 */
17
- captcha?: string;
18
- };
19
- }
package/src/types/auth.js DELETED
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });