floating-live 0.14.10 → 0.15.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.
Files changed (64) hide show
  1. package/LICENSE +5 -670
  2. package/{src/abstract → dist/core}/LiveRoom.d.ts +1 -1
  3. package/{src/abstract → dist/core}/LiveRoom.js +6 -6
  4. package/{src/abstract → dist/core}/Reglist.d.ts +1 -1
  5. package/dist/core/index.d.ts +2 -0
  6. package/dist/core/index.js +18 -0
  7. package/dist/index.d.ts +6 -0
  8. package/{index.js → dist/index.js} +7 -7
  9. package/{src → dist}/module/ModAuth.d.ts +2 -2
  10. package/{src → dist}/module/ModAuth.js +1 -1
  11. package/{src → dist}/module/ModCommand.d.ts +2 -2
  12. package/{src → dist}/module/ModCommand.js +1 -1
  13. package/{src → dist}/module/ModMessage.d.ts +2 -2
  14. package/{src → dist}/module/ModMessage.js +1 -1
  15. package/{src → dist}/module/ModPlugin.d.ts +1 -1
  16. package/{src → dist}/module/ModRoom.d.ts +3 -3
  17. package/{src → dist}/module/ModRoom.js +1 -1
  18. package/{src → dist}/module/ModState.d.ts +2 -2
  19. package/{src → dist}/module/ModState.js +1 -1
  20. package/{src → dist}/types/message.d.ts +2 -2
  21. package/{src → dist}/types/plugin.d.ts +1 -1
  22. package/{src → dist}/types/room.d.ts +1 -1
  23. package/package.json +26 -5
  24. package/index.d.ts +0 -6
  25. package/plugin/acfun/acfunLive.d.ts +0 -74
  26. package/plugin/acfun/acfunLive.js +0 -279
  27. package/plugin/acfun/index.d.ts +0 -3
  28. package/plugin/acfun/index.js +0 -16
  29. package/plugin/bilibili/index.d.ts +0 -6
  30. package/plugin/bilibili/index.js +0 -45
  31. package/plugin/bilibili/parser.d.ts +0 -6
  32. package/plugin/bilibili/parser.js +0 -397
  33. package/plugin/bilibili/room.d.ts +0 -77
  34. package/plugin/bilibili/room.js +0 -261
  35. package/plugin/bilibili/types.d.ts +0 -424
  36. package/plugin/bilibili/types.js +0 -2
  37. package/plugin/bilibili/utils.d.ts +0 -16
  38. package/plugin/bilibili/utils.js +0 -125
  39. package/plugin/chatPrint/chatPrint.d.ts +0 -20
  40. package/plugin/chatPrint/chatPrint.js +0 -116
  41. package/plugin/chatPrint/index.d.ts +0 -7
  42. package/plugin/chatPrint/index.js +0 -10
  43. package/plugin/consoleEvent/index.d.ts +0 -6
  44. package/plugin/consoleEvent/index.js +0 -51
  45. package/plugin/msgSave/index.d.ts +0 -10
  46. package/plugin/msgSave/index.js +0 -81
  47. package/plugin/msgSave/msgSave.d.ts +0 -83
  48. package/plugin/msgSave/msgSave.js +0 -168
  49. package/test/type/bilibili_getInfoByRoom.d.ts +0 -492
  50. /package/{src/abstract → dist/core}/Reglist.js +0 -0
  51. /package/{src/enum.d.ts → dist/enums.d.ts} +0 -0
  52. /package/{src/enum.js → dist/enums.js} +0 -0
  53. /package/{src/index.d.ts → dist/live.d.ts} +0 -0
  54. /package/{src/index.js → dist/live.js} +0 -0
  55. /package/{src → dist}/module/ModPlugin.js +0 -0
  56. /package/{src → dist}/types/auth.d.ts +0 -0
  57. /package/{src → dist}/types/auth.js +0 -0
  58. /package/{src → dist}/types/index.d.ts +0 -0
  59. /package/{src → dist}/types/index.js +0 -0
  60. /package/{src → dist}/types/message.js +0 -0
  61. /package/{src → dist}/types/plugin.js +0 -0
  62. /package/{src → dist}/types/room.js +0 -0
  63. /package/{src → dist}/utils.d.ts +0 -0
  64. /package/{src → dist}/utils.js +0 -0
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  import { EventEmitter } from "events";
3
- import { RoomStatus } from "../enum";
3
+ import { RoomStatus } from "../enums";
4
4
  import { RoomDetail, RoomInfo, RoomStatsInfo } from "../types";
5
5
  import { Message, UserInfo } from "../types/message";
6
6
  export declare abstract class LiveRoom extends EventEmitter implements RoomInfo {
@@ -2,12 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LiveRoom = void 0;
4
4
  const events_1 = require("events");
5
- const enum_1 = require("../enum");
5
+ const enums_1 = require("../enums");
6
6
  class LiveRoom extends events_1.EventEmitter {
7
7
  constructor() {
8
8
  super();
9
9
  /** 直播状态 */
10
- this.status = enum_1.RoomStatus.off;
10
+ this.status = enums_1.RoomStatus.off;
11
11
  /** 时间戳 */
12
12
  this.timestamp = 0;
13
13
  /** 房间是否打开 */
@@ -25,9 +25,9 @@ class LiveRoom extends events_1.EventEmitter {
25
25
  // 直播结束消息 => 先发送消息再更改状态
26
26
  switch (msg.type) {
27
27
  case "live_start":
28
- this.status = enum_1.RoomStatus.live;
28
+ this.status = enums_1.RoomStatus.live;
29
29
  this.timestamp = msg.timestamp;
30
- this.emit("status", enum_1.RoomStatus.live, {
30
+ this.emit("status", enums_1.RoomStatus.live, {
31
31
  timestamp: msg.timestamp,
32
32
  id: msg.info.id,
33
33
  });
@@ -43,9 +43,9 @@ class LiveRoom extends events_1.EventEmitter {
43
43
  case "live_end":
44
44
  case "live_cut":
45
45
  this.emit("msg", msg);
46
- this.status = msg.status || enum_1.RoomStatus.off;
46
+ this.status = msg.status || enums_1.RoomStatus.off;
47
47
  this.timestamp = msg.timestamp;
48
- this.emit("status", msg.status || enum_1.RoomStatus.off, {
48
+ this.emit("status", msg.status || enums_1.RoomStatus.off, {
49
49
  timestamp: msg.timestamp,
50
50
  });
51
51
  return;
@@ -1,4 +1,4 @@
1
- import { FloatingLive } from "..";
1
+ import { FloatingLive } from "../live";
2
2
  /** 插件可注册对象模块 */
3
3
  export declare class Reglist<T> {
4
4
  /** 功能列表 */
@@ -0,0 +1,2 @@
1
+ export * from "./LiveRoom";
2
+ export * from "./Reglist";
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./LiveRoom"), exports);
18
+ __exportStar(require("./Reglist"), exports);
@@ -0,0 +1,6 @@
1
+ export { FloatingLive } from "./live";
2
+ export * from "./types";
3
+ export * from "./enums";
4
+ export * from "./core/LiveRoom";
5
+ export * from "./core/Reglist";
6
+ export * from "./utils";
@@ -15,10 +15,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.FloatingLive = void 0;
18
- var src_1 = require("./src");
19
- Object.defineProperty(exports, "FloatingLive", { enumerable: true, get: function () { return src_1.FloatingLive; } });
20
- __exportStar(require("./src/types"), exports);
21
- __exportStar(require("./src/enum"), exports);
22
- __exportStar(require("./src/abstract/LiveRoom"), exports);
23
- __exportStar(require("./src/abstract/Reglist"), exports);
24
- __exportStar(require("./src/utils"), exports);
18
+ var live_1 = require("./live");
19
+ Object.defineProperty(exports, "FloatingLive", { enumerable: true, get: function () { return live_1.FloatingLive; } });
20
+ __exportStar(require("./types"), exports);
21
+ __exportStar(require("./enums"), exports);
22
+ __exportStar(require("./core/LiveRoom"), exports);
23
+ __exportStar(require("./core/Reglist"), exports);
24
+ __exportStar(require("./utils"), exports);
@@ -1,5 +1,5 @@
1
- import { Reglist } from "../abstract/Reglist";
2
- import { FloatingLive } from "..";
1
+ import { Reglist } from "../core/Reglist";
2
+ import { FloatingLive } from "../live";
3
3
  import { AuthOptions } from "../types/auth";
4
4
  export declare class ModAuth {
5
5
  options: Reglist<AuthOptions>;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ModAuth = void 0;
4
- const Reglist_1 = require("../abstract/Reglist");
4
+ const Reglist_1 = require("../core/Reglist");
5
5
  class ModAuth {
6
6
  constructor(main) {
7
7
  this.status = {};
@@ -1,5 +1,5 @@
1
- import { FloatingLive } from "..";
2
- import { Reglist } from "../abstract/Reglist";
1
+ import { FloatingLive } from "../live";
2
+ import { Reglist } from "../core/Reglist";
3
3
  export default class ModCommand extends Reglist<(...args: any[]) => any> {
4
4
  constructor(main: FloatingLive);
5
5
  /** 批量注册命令 */
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const Reglist_1 = require("../abstract/Reglist");
3
+ const Reglist_1 = require("../core/Reglist");
4
4
  class ModCommand extends Reglist_1.Reglist {
5
5
  constructor(main) {
6
6
  super(main, "command");
@@ -1,6 +1,6 @@
1
1
  import { Message } from "../types/message";
2
- import { FloatingLive } from "..";
3
- import { Reglist } from "../abstract/Reglist";
2
+ import { FloatingLive } from "../live";
3
+ import { Reglist } from "../core/Reglist";
4
4
  export declare class ModMessage {
5
5
  main: FloatingLive;
6
6
  handler: Reglist<(msg: Message.All) => void>;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ModMessage = void 0;
4
- const Reglist_1 = require("../abstract/Reglist");
4
+ const Reglist_1 = require("../core/Reglist");
5
5
  class ModMessage {
6
6
  constructor(main) {
7
7
  this.main = main;
@@ -1,4 +1,4 @@
1
- import { FloatingLive } from "..";
1
+ import { FloatingLive } from "../live";
2
2
  import { FloatingLivePlugin } from "../types/plugin";
3
3
  export declare class ModPlugin<T extends FloatingLive> {
4
4
  private current;
@@ -1,6 +1,6 @@
1
- import { Reglist } from "../abstract/Reglist";
2
- import { LiveRoom } from "../abstract/LiveRoom";
3
- import { FloatingLive } from "..";
1
+ import { Reglist } from "../core/Reglist";
2
+ import { LiveRoom } from "../core/LiveRoom";
3
+ import { FloatingLive } from "../live";
4
4
  import { RoomInfo } from "../types";
5
5
  /** 直播间监听实例控制器 */
6
6
  export declare class ModRoom {
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ModRoom = void 0;
4
- const Reglist_1 = require("../abstract/Reglist");
4
+ const Reglist_1 = require("../core/Reglist");
5
5
  /** 直播间监听实例控制器 */
6
6
  class ModRoom {
7
7
  constructor(main) {
@@ -1,5 +1,5 @@
1
- import { FloatingLive } from "..";
2
- import { Reglist } from "../abstract/Reglist";
1
+ import { FloatingLive } from "../live";
2
+ import { Reglist } from "../core/Reglist";
3
3
  export declare class ModState extends Reglist<() => object> {
4
4
  constructor(main: FloatingLive);
5
5
  generate(): Record<string, any>;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ModState = void 0;
4
- const Reglist_1 = require("../abstract/Reglist");
4
+ const Reglist_1 = require("../core/Reglist");
5
5
  class ModState extends Reglist_1.Reglist {
6
6
  constructor(main) {
7
7
  super(main, "state");
@@ -1,5 +1,5 @@
1
- import { ImageSize, UserType } from "../enum";
2
- import { DanmakuMode, RoomStatus } from "../enum";
1
+ import { ImageSize, UserType } from "../enums";
2
+ import { DanmakuMode, RoomStatus } from "../enums";
3
3
  import { RoomDetail, RoomStatsInfo } from "./room";
4
4
  export declare namespace Message {
5
5
  interface Base {
@@ -1,4 +1,4 @@
1
- import { FloatingLive } from "..";
1
+ import { FloatingLive } from "../live";
2
2
  /** 插件模块, 加载时调用 */
3
3
  export declare type FloatingLivePlugin<C extends object = object, E extends object | void = object | void> = () => {
4
4
  /** 插件名称 */
@@ -1,4 +1,4 @@
1
- import { RoomStatus } from "../enum";
1
+ import { RoomStatus } from "../enums";
2
2
  import { UserInfo } from "./message";
3
3
  export interface RoomInfo {
4
4
  /** 平台id */
package/package.json CHANGED
@@ -1,14 +1,32 @@
1
1
  {
2
2
  "name": "floating-live",
3
- "version": "0.14.10",
3
+ "version": "0.15.0-beta.0",
4
4
  "type": "commonjs",
5
- "main": "index.js",
6
- "types": "index.d.ts",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
7
  "author": "Minteea",
8
8
  "license": "GPLv3",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "require": "./dist/index.js"
13
+ },
14
+ "./core": {
15
+ "types": "./dist/core/index.d.ts",
16
+ "require": "./dist/core/index.js"
17
+ },
18
+ "./types": {
19
+ "types": "./dist/types/index.d.ts",
20
+ "require": "./dist/types/index.js"
21
+ },
22
+ "./enums": {
23
+ "types": "./dist/enum.d.ts",
24
+ "require": "./dist/enum.js"
25
+ }
26
+ },
9
27
  "scripts": {
10
28
  "tsc": "tsc -b",
11
- "clear": "rimraf index.js index.d.ts src/**/*.js src/**/*.d.ts plugin/**/*.js plugin/**/*.d.ts",
29
+ "clear": "rimraf dist",
12
30
  "test": "npm run clear && ts-node demo/demo.ts",
13
31
  "build-test": "npm run build && node demo/demo.js",
14
32
  "build": "npm run clear && npm run tsc",
@@ -29,5 +47,8 @@
29
47
  "rimraf": "^3.0.2",
30
48
  "ts-node": "^10.9.1",
31
49
  "typescript": "^4.8.4"
50
+ },
51
+ "peerDependencies": {
52
+ "events": "^3.3.0"
32
53
  }
33
- }
54
+ }
package/index.d.ts DELETED
@@ -1,6 +0,0 @@
1
- export { FloatingLive } from "./src";
2
- export * from "./src/types";
3
- export * from "./src/enum";
4
- export * from "./src/abstract/LiveRoom";
5
- export * from "./src/abstract/Reglist";
6
- export * from "./src/utils";
@@ -1,74 +0,0 @@
1
- import { RoomDetail } from "../..";
2
- import { MedalInfo, UserInfo } from "../..";
3
- import AcClient from "acfun-live-danmaku/client";
4
- import { LiveRoom, RoomStatsInfo } from "../..";
5
- declare type ZtLiveUserInfo = {
6
- userIdentity: {
7
- managerType?: number;
8
- };
9
- badge?: string;
10
- nickname: string;
11
- userId: string;
12
- avatar: [
13
- {
14
- url: string;
15
- }
16
- ];
17
- };
18
- declare class acfunLive extends LiveRoom {
19
- /** 平台id */
20
- readonly platform: string;
21
- /** 房间id */
22
- readonly id: number;
23
- /** 直播展示信息 */
24
- detail: RoomDetail;
25
- /** 直播数据信息 */
26
- stats: RoomStatsInfo;
27
- /** 主播信息 */
28
- anchor: UserInfo;
29
- /** 直播间弹幕api模块 */
30
- client: AcClient | null;
31
- /** 是否为打开状态 */
32
- opened: boolean;
33
- /** 是否连接上服务器 */
34
- connected: boolean;
35
- private wsInit;
36
- /** 直播间是否可用 */
37
- get available(): boolean;
38
- constructor(id: number, open?: boolean);
39
- getInfo(): Promise<void>;
40
- /** 开启直播间监听 */
41
- open(): Promise<void>;
42
- /** 初始化直播服务端监听 */
43
- private initWS;
44
- /** 关闭直播间监听 */
45
- close(): void;
46
- destroy(): void;
47
- /** 根据守护徽章字符串获取粉丝牌信息 */
48
- getMedal(badge?: string): MedalInfo | null;
49
- getUser(user: ZtLiveUserInfo): UserInfo;
50
- /** 文本信息(Comment) */
51
- msg_Comment(data: {
52
- sendTimeMs: string;
53
- userInfo: ZtLiveUserInfo;
54
- content: any;
55
- }): void;
56
- /** 礼物信息(Gift) */
57
- msg_Gift(data: {
58
- sendTimeMs: string;
59
- user: ZtLiveUserInfo;
60
- giftName: any;
61
- giftId: string;
62
- count: number;
63
- value: string;
64
- }): void;
65
- /** 互动信息 */
66
- msg_Interact(data: {
67
- sendTimeMs: string;
68
- userInfo: ZtLiveUserInfo;
69
- }, type: "entry" | "like" | "follow" | "share" | "join"): void;
70
- msg_LiveClosed(): void;
71
- msg_LiveBanned(): void;
72
- msg_DisplayInfo(data: any): void;
73
- }
74
- export default acfunLive;
@@ -1,279 +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 acfun_live_danmaku_1 = __importDefault(require("acfun-live-danmaku"));
7
- const __1 = require("../..");
8
- const __2 = require("../..");
9
- // 获取当前时间戳,以替代无法从数据中获取时间戳的情况,精度为1s
10
- function getDateTimestamp() {
11
- return Math.floor(Date.now() / 1000) * 1000;
12
- }
13
- function stringToNumber(num) {
14
- if (num.slice(-1) == "万") {
15
- return Math.round(parseFloat(num) * 10000);
16
- }
17
- else {
18
- return parseFloat(num);
19
- }
20
- }
21
- class acfunLive extends __1.LiveRoom {
22
- constructor(id, open = false) {
23
- super();
24
- /** 平台id */
25
- this.platform = "acfun";
26
- /** 直播展示信息 */
27
- this.detail = {
28
- /** 直播标题 */
29
- title: "",
30
- /** 分区 */
31
- area: [],
32
- /** 封面 */
33
- cover: "",
34
- };
35
- /** 直播数据信息 */
36
- this.stats = {
37
- /** 点赞数 */
38
- like: 0,
39
- /** 在线观看数 */
40
- online: 0,
41
- };
42
- /** 主播信息 */
43
- this.anchor = { name: "", id: 0 };
44
- /** 直播间弹幕api模块 */
45
- this.client = null;
46
- /** 是否为打开状态 */
47
- this.opened = false;
48
- /** 是否连接上服务器 */
49
- this.connected = false;
50
- this.wsInit = false;
51
- this.platform = "acfun";
52
- this.id = id; // 直播间号
53
- this.anchor.id = id; // 主播uid
54
- this.getInfo().then(() => {
55
- if (open)
56
- this.open();
57
- });
58
- }
59
- /** 直播间是否可用 */
60
- get available() {
61
- return Boolean(this.client);
62
- }
63
- async getInfo() {
64
- if (!this.client) {
65
- this.client = (await (0, acfun_live_danmaku_1.default)(this.id)) || null;
66
- if (this.client) {
67
- this.status = __2.RoomStatus.live;
68
- this.timestamp = this.client.liveStartTime;
69
- this.detail.title = this.client.caption; // bug
70
- this.detail.cover = `https://tx2.a.kwimgs.com/bs2/ztlc/cover_${this.client.liveId}_raw.jpg`;
71
- }
72
- await fetch(`https://live.acfun.cn/rest/pc-direct/user/userInfo?userId=${this.id}`, {
73
- method: "GET",
74
- })
75
- .then((response) => response.json())
76
- .then((res) => {
77
- let { headUrl, name } = res.profile;
78
- this.anchor.avatar = headUrl;
79
- this.anchor.name = name;
80
- this.emit("info", this.info);
81
- })
82
- .catch((error) => {
83
- this.emit("info_error", error);
84
- });
85
- }
86
- // 暂不能在连接房间后更新信息
87
- }
88
- /** 开启直播间监听 */
89
- async open() {
90
- if (this.opened || !this.available)
91
- return;
92
- if (!this.wsInit) {
93
- this.initWS();
94
- }
95
- //启动websocket连接
96
- this.opened = true;
97
- this.client.wsStart();
98
- this.emit("open");
99
- }
100
- /** 初始化直播服务端监听 */
101
- async initWS() {
102
- if (!this.client)
103
- return;
104
- let client = this.client;
105
- client.on("EnterRoomAck", () => {
106
- console.log("[acfun-live-danmaku] 已连接AcFun直播间");
107
- this.status = __2.RoomStatus.live;
108
- });
109
- client.on("RecentComment", (comments) => {
110
- //当前弹幕列表
111
- });
112
- client.on("Comment", (danmaku) => {
113
- //收到的弹幕
114
- this.msg_Comment(danmaku);
115
- });
116
- client.on("Gift", (msg) => {
117
- this.msg_Gift(msg);
118
- });
119
- client.on("UserEnterRoom", (msg) => {
120
- this.msg_Interact(msg, "entry");
121
- });
122
- client.on("Like", (msg) => {
123
- this.msg_Interact(msg, "like");
124
- });
125
- // client.on("UserFollowAuthor", (join: any) => { this.msg_Interact(msg, "follow"); });
126
- // client.on("JoinClub", (msg: any) => { this.msg_Interact(msg, "join"); });
127
- client.on("DisplayInfo", (msg) => {
128
- this.msg_DisplayInfo(msg);
129
- });
130
- client.on("LiveClosed", (msg) => {
131
- this.msg_LiveClosed();
132
- });
133
- client.on("LiveBanned", (msg) => {
134
- this.msg_LiveBanned();
135
- });
136
- this.wsInit = true;
137
- }
138
- /** 关闭直播间监听 */
139
- close() {
140
- if (!this.opened)
141
- return;
142
- this.opened = false;
143
- this.client?.wsClose();
144
- this.emit("close");
145
- }
146
- destroy() {
147
- this.close();
148
- this.removeAllListeners();
149
- }
150
- /** 根据守护徽章字符串获取粉丝牌信息 */
151
- getMedal(badge) {
152
- if (badge) {
153
- let medalInfo = JSON.parse(badge).medalInfo;
154
- return {
155
- name: medalInfo.clubName,
156
- id: medalInfo.uperId,
157
- level: medalInfo.level,
158
- };
159
- }
160
- else {
161
- return null;
162
- }
163
- }
164
- getUser(user) {
165
- let identity = 0;
166
- if (user.userIdentity?.managerType == 1) {
167
- identity = __2.UserType.admin;
168
- }
169
- else if (parseInt(user.userId) == this.anchor.id) {
170
- identity = __2.UserType.anchor;
171
- }
172
- return {
173
- name: user.nickname,
174
- id: parseInt(user.userId),
175
- medal: this.getMedal(user.badge),
176
- avatar: user.avatar[0].url,
177
- type: identity,
178
- };
179
- }
180
- /** 文本信息(Comment) */
181
- msg_Comment(data) {
182
- const userInfo = this.getUser(data.userInfo);
183
- let m = {
184
- platform: "acfun",
185
- room: this.id,
186
- id: `${userInfo.id}-${data.sendTimeMs}`,
187
- timestamp: parseInt(data.sendTimeMs),
188
- type: "chat",
189
- info: {
190
- content: data.content,
191
- user: userInfo,
192
- },
193
- };
194
- this.emitMsg(m);
195
- }
196
- /** 礼物信息(Gift) */
197
- msg_Gift(data) {
198
- const userInfo = this.getUser(data.user);
199
- let m = {
200
- platform: "acfun",
201
- room: this.id,
202
- type: "gift",
203
- id: `${userInfo.id}-${data.sendTimeMs}`,
204
- timestamp: parseInt(data.sendTimeMs),
205
- info: {
206
- user: userInfo,
207
- gift: {
208
- name: data.giftName,
209
- id: parseInt(data.giftId),
210
- num: data.count,
211
- currency: data.giftId == "1" ? "banana" : "coin",
212
- value: parseInt(data.value), // 总价值
213
- },
214
- },
215
- };
216
- this.emitMsg(m);
217
- }
218
- /** 互动信息 */
219
- msg_Interact(data, type) {
220
- const userInfo = this.getUser(data.userInfo);
221
- let m = {
222
- platform: "acfun",
223
- room: this.id,
224
- type: type,
225
- id: `${userInfo.id}-${data.sendTimeMs}`,
226
- timestamp: parseInt(data.sendTimeMs),
227
- info: {
228
- user: userInfo,
229
- },
230
- };
231
- this.emitMsg(m);
232
- }
233
- msg_LiveClosed() {
234
- const timestamp = getDateTimestamp();
235
- let m = {
236
- platform: "acfun",
237
- room: this.id,
238
- type: "live_end",
239
- id: `${timestamp}`,
240
- timestamp: timestamp,
241
- info: {
242
- status: __2.RoomStatus.off,
243
- },
244
- };
245
- this.client = null;
246
- this.emitMsg(m);
247
- }
248
- msg_LiveBanned() {
249
- const timestamp = getDateTimestamp();
250
- let m = {
251
- platform: "acfun",
252
- room: this.id,
253
- type: "live_cut",
254
- id: `${timestamp}`,
255
- timestamp: timestamp,
256
- info: {
257
- message: "",
258
- },
259
- };
260
- this.client = null;
261
- this.emitMsg(m);
262
- }
263
- msg_DisplayInfo(data) {
264
- const timestamp = getDateTimestamp();
265
- let m = {
266
- platform: "acfun",
267
- room: this.id,
268
- type: "live_stats",
269
- id: `${timestamp}`,
270
- timestamp: timestamp,
271
- info: {
272
- like: stringToNumber(data.likeCount),
273
- online: stringToNumber(data.watchingCount),
274
- },
275
- };
276
- this.emitMsg(m);
277
- }
278
- }
279
- exports.default = acfunLive;
@@ -1,3 +0,0 @@
1
- import { FloatingLivePlugin } from "../../src/types";
2
- declare const acfun: FloatingLivePlugin;
3
- export = acfun;
@@ -1,16 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- const acfunLive_1 = __importDefault(require("./acfunLive"));
6
- const acfun = () => {
7
- return {
8
- name: "acfun",
9
- register: (ctx) => {
10
- ctx.room.generator.register("acfun", (id, open) => {
11
- return new acfunLive_1.default(Number(id), open);
12
- });
13
- },
14
- };
15
- };
16
- module.exports = acfun;