dimsum-chat 0.4.2 → 0.4.4
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 +8 -0
- package/dist/dimsum-chat.js +192 -136
- package/dist/dimsum-chat.umd.cjs +3 -3
- package/dist/parser.d.ts +3 -1
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/dimsum-chat.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
1
|
+
var T = Object.defineProperty;
|
|
2
|
+
var I = (r, t, i) => t in r ? T(r, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : r[t] = i;
|
|
3
|
+
var b = (r, t, i) => (I(r, typeof t != "symbol" ? t + "" : t, i), i);
|
|
4
4
|
const A = {
|
|
5
5
|
type: "LIVE_OPEN_PLATFORM_DM",
|
|
6
6
|
content: {
|
|
@@ -32,12 +32,12 @@ const A = {
|
|
|
32
32
|
}
|
|
33
33
|
}, _ = [A, B], m = class m {
|
|
34
34
|
constructor() {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
35
|
+
b(this, "AUTH_HOST", "https://dimsum-widget-auth-1301031323.cos.ap-guangzhou.myqcloud.com");
|
|
36
|
+
b(this, "WHITELIST_WIDGETS", ["dimsum-bonk-2024-widget", "douyin-bonk-2024-widget"]);
|
|
37
|
+
b(this, "MAX_RETRY_COUNT", 3);
|
|
38
|
+
b(this, "authenticatedPlatformAndRoomId");
|
|
39
|
+
b(this, "isPiracy", !1);
|
|
40
|
+
b(this, "retryCount", 0);
|
|
41
41
|
}
|
|
42
42
|
static getInstance() {
|
|
43
43
|
return m.instance || (m.instance = new m()), m.instance;
|
|
@@ -48,33 +48,33 @@ const A = {
|
|
|
48
48
|
checkAuthentication(t, i, s) {
|
|
49
49
|
if (t = this.updateWidgetId(t), !this.WHITELIST_WIDGETS.includes(t) || this.authenticatedPlatformAndRoomId === `${i}-${s}`)
|
|
50
50
|
return;
|
|
51
|
-
const
|
|
51
|
+
const e = () => {
|
|
52
52
|
this.retryCount++, this.retryCount < this.MAX_RETRY_COUNT ? setTimeout(() => {
|
|
53
53
|
this.checkAuthentication(t, i, s);
|
|
54
54
|
}, 1e3) : this.isPiracy = !0;
|
|
55
|
-
},
|
|
56
|
-
return fetch(
|
|
57
|
-
console.log("checkAuthentication", p.status), p.status === 200 ? (this.authenticatedPlatformAndRoomId = `${i}-${s}`, this.isPiracy = !1) :
|
|
55
|
+
}, n = `${this.AUTH_HOST}/${t}/whitelist/${i}/${s}`;
|
|
56
|
+
return fetch(n).then((p) => {
|
|
57
|
+
console.log("checkAuthentication", p.status), p.status === 200 ? (this.authenticatedPlatformAndRoomId = `${i}-${s}`, this.isPiracy = !1) : e();
|
|
58
58
|
}).catch(() => {
|
|
59
|
-
console.log("checkAuthentication error"),
|
|
59
|
+
console.log("checkAuthentication error"), e();
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
62
|
passMessage(t) {
|
|
63
63
|
try {
|
|
64
64
|
if (t.type === "DimSumChatRoomInfo") {
|
|
65
|
-
const i = t.content.platform ?? t.content.platfrom, s = t.content.roomId,
|
|
66
|
-
this.checkAuthentication(
|
|
65
|
+
const i = t.content.platform ?? t.content.platfrom, s = t.content.roomId, e = window.location.pathname.split("/")[1];
|
|
66
|
+
this.checkAuthentication(e, i, s);
|
|
67
67
|
}
|
|
68
68
|
if (t.type === "INTERACT_WORD") {
|
|
69
|
-
const i = typeof t.content == "object" ? t.content : JSON.parse(t.content), s = "bilibili",
|
|
70
|
-
this.checkAuthentication(
|
|
69
|
+
const i = typeof t.content == "object" ? t.content : JSON.parse(t.content), s = "bilibili", e = String(i.data.roomid), n = window.location.pathname.split("/")[1];
|
|
70
|
+
this.checkAuthentication(n, s, e);
|
|
71
71
|
}
|
|
72
72
|
if (t.type === "LIVE_OPEN_PLATFORM_DM" || t.type === "LIVE_OPEN_PLATFORM_SEND_GIFT") {
|
|
73
73
|
const i = typeof t.content == "object" ? t.content : JSON.parse(t.content);
|
|
74
74
|
if (i.data.room_id === void 0)
|
|
75
75
|
return t;
|
|
76
|
-
const s = "bilibili",
|
|
77
|
-
this.checkAuthentication(
|
|
76
|
+
const s = "bilibili", e = String(i.data.room_id), n = window.location.pathname.split("/")[1];
|
|
77
|
+
this.checkAuthentication(n, s, e);
|
|
78
78
|
}
|
|
79
79
|
if (this.isPiracy)
|
|
80
80
|
return _[Math.floor(Math.random() * _.length)];
|
|
@@ -84,9 +84,9 @@ const A = {
|
|
|
84
84
|
return t;
|
|
85
85
|
}
|
|
86
86
|
};
|
|
87
|
-
|
|
88
|
-
let
|
|
89
|
-
const
|
|
87
|
+
b(m, "instance");
|
|
88
|
+
let l = m;
|
|
89
|
+
const k = {
|
|
90
90
|
type: "LIVE_OPEN_PLATFORM_DM",
|
|
91
91
|
content: {
|
|
92
92
|
cmd: "LIVE_OPEN_PLATFORM_DM",
|
|
@@ -97,7 +97,7 @@ const M = {
|
|
|
97
97
|
guard_level: 1
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
|
-
},
|
|
100
|
+
}, M = {
|
|
101
101
|
type: "LIVE_OPEN_PLATFORM_DM",
|
|
102
102
|
content: {
|
|
103
103
|
cmd: "LIVE_OPEN_PLATFORM_DM",
|
|
@@ -108,22 +108,22 @@ const M = {
|
|
|
108
108
|
guard_level: 1
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
|
-
},
|
|
112
|
-
connected:
|
|
113
|
-
welcome:
|
|
111
|
+
}, z = {
|
|
112
|
+
connected: k,
|
|
113
|
+
welcome: M
|
|
114
114
|
};
|
|
115
|
-
function
|
|
115
|
+
function E() {
|
|
116
116
|
const t = window.location.pathname.split("/");
|
|
117
117
|
return t.length > 1 ? t[1] : "unknown base name";
|
|
118
118
|
}
|
|
119
|
-
function
|
|
119
|
+
function L(r) {
|
|
120
120
|
let t;
|
|
121
|
-
switch (
|
|
121
|
+
switch (r.type) {
|
|
122
122
|
case "DimSumChatWidgetInfoRequest":
|
|
123
123
|
t = {
|
|
124
124
|
type: "DimSumChatWidgetInfoResponse",
|
|
125
125
|
content: {
|
|
126
|
-
base:
|
|
126
|
+
base: E(),
|
|
127
127
|
url: window.location.href
|
|
128
128
|
}
|
|
129
129
|
};
|
|
@@ -132,8 +132,8 @@ function k(a) {
|
|
|
132
132
|
}
|
|
133
133
|
const x = class x {
|
|
134
134
|
constructor() {
|
|
135
|
-
|
|
136
|
-
|
|
135
|
+
b(this, "webSocket");
|
|
136
|
+
b(this, "messageListeners");
|
|
137
137
|
this.webSocket = null, this.messageListeners = [];
|
|
138
138
|
}
|
|
139
139
|
static getInstance() {
|
|
@@ -143,7 +143,7 @@ const x = class x {
|
|
|
143
143
|
this.webSocket || (this.webSocket = new WebSocket(t), this.webSocket.onmessage = this.handleMessage.bind(this), this.webSocket.onopen = () => {
|
|
144
144
|
console.log("connected"), setTimeout(() => {
|
|
145
145
|
this.messageListeners.forEach(
|
|
146
|
-
(i) => i(JSON.stringify(
|
|
146
|
+
(i) => i(JSON.stringify(z.connected))
|
|
147
147
|
);
|
|
148
148
|
}, 100);
|
|
149
149
|
}, this.webSocket.onclose = () => {
|
|
@@ -153,15 +153,15 @@ const x = class x {
|
|
|
153
153
|
});
|
|
154
154
|
}
|
|
155
155
|
handleMessage(t) {
|
|
156
|
-
var
|
|
156
|
+
var n;
|
|
157
157
|
const i = t.data;
|
|
158
158
|
this.messageListeners.forEach((p) => p(i));
|
|
159
|
-
const s = JSON.parse(i),
|
|
160
|
-
|
|
159
|
+
const s = JSON.parse(i), e = L(s);
|
|
160
|
+
e && ((n = this.webSocket) == null || n.send(JSON.stringify(e)));
|
|
161
161
|
}
|
|
162
162
|
addMessageListener(t) {
|
|
163
163
|
this.messageListeners.push(t), setTimeout(() => {
|
|
164
|
-
t(JSON.stringify(
|
|
164
|
+
t(JSON.stringify(z.welcome));
|
|
165
165
|
}, 100);
|
|
166
166
|
}
|
|
167
167
|
removeMessageListener(t) {
|
|
@@ -169,23 +169,23 @@ const x = class x {
|
|
|
169
169
|
i !== -1 && this.messageListeners.splice(i, 1);
|
|
170
170
|
}
|
|
171
171
|
};
|
|
172
|
-
|
|
173
|
-
let
|
|
172
|
+
b(x, "instance");
|
|
173
|
+
let j = x;
|
|
174
174
|
function S() {
|
|
175
|
-
const
|
|
175
|
+
const r = new URL(window.location.href), t = r.protocol === "https:" ? "wss:" : "ws:", i = r.host;
|
|
176
176
|
return `${t}//${i}/websocket`;
|
|
177
177
|
}
|
|
178
|
-
function
|
|
178
|
+
function N(r) {
|
|
179
179
|
const t = new URL(window.location.href), i = t.protocol, s = t.host;
|
|
180
|
-
return `${i}//${s}/bface/${
|
|
180
|
+
return `${i}//${s}/bface/${r}`;
|
|
181
181
|
}
|
|
182
|
-
function
|
|
182
|
+
function U(r, t = {}) {
|
|
183
183
|
const {
|
|
184
184
|
customWsServer: i = S()
|
|
185
|
-
} = t, s =
|
|
186
|
-
|
|
187
|
-
const p = JSON.parse(
|
|
188
|
-
|
|
185
|
+
} = t, s = l.getInstance(), e = j.getInstance();
|
|
186
|
+
e.connect(i), e.addMessageListener((n) => {
|
|
187
|
+
const p = JSON.parse(n), d = s.passMessage(p), f = new v(d);
|
|
188
|
+
r(d, f);
|
|
189
189
|
});
|
|
190
190
|
}
|
|
191
191
|
const C = [
|
|
@@ -449,7 +449,7 @@ const C = [
|
|
|
449
449
|
["[糖葫芦]", "https://p3-pc-sign.douyinpic.com/obj/tos-cn-i-tsj2vxp0zn/d4aa8a0ff46a445e861ad8fb78c07140?x-expires=2023614000&x-signature=FvN4ytTGjC7Mww8KX4BRIg9wcTE%3D"],
|
|
450
450
|
["[虎头]", "https://p3-pc-sign.douyinpic.com/obj/tos-cn-i-tsj2vxp0zn/7569ffeaa3894b8b8ea843c0e5a05f63?x-expires=2023614000&x-signature=m%2Bi3d034xBQkuBqx4xrvzru5q6A%3D"],
|
|
451
451
|
["[iloveyou]", "https://p3-pc-sign.douyinpic.com/obj/tos-cn-i-tsj2vxp0zn/798bcfd9811f4fcd97df92af06c87a0e?x-expires=2023614000&x-signature=DuK8xhX7glgLx44H53PrhM32D44%3D"]
|
|
452
|
-
],
|
|
452
|
+
], D = [
|
|
453
453
|
["[dog]", "http://i0.hdslb.com/bfs/live/4428c84e694fbf4e0ef6c06e958d9352c3582740.png"],
|
|
454
454
|
["[花]", "http://i0.hdslb.com/bfs/live/7dd2ef03e13998575e4d8a803c6e12909f94e72b.png"],
|
|
455
455
|
["[妙]", "http://i0.hdslb.com/bfs/live/08f735d950a0fba267dda140673c9ab2edf6410d.png"],
|
|
@@ -740,11 +740,11 @@ const C = [
|
|
|
740
740
|
["[抱拳]", "https://bd.a.yximgs.com/bs2/emotion/1704790113221third_party_s1296853443.png"],
|
|
741
741
|
["[早上好]", "https://ali2.a.yximgs.com/bs2/emotion/1704790167344third_party_s1296853922.png"],
|
|
742
742
|
["[胡思乱想]", "https://ali2.a.yximgs.com/bs2/emotion/1704790657229third_party_s1296858542.png"]
|
|
743
|
-
],
|
|
743
|
+
], h = class h {
|
|
744
744
|
constructor(t) {
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
745
|
+
b(this, "rawType");
|
|
746
|
+
b(this, "rawContent");
|
|
747
|
+
b(this, "_cachedValues", {});
|
|
748
748
|
this.rawType = t.type;
|
|
749
749
|
try {
|
|
750
750
|
typeof t.content == "string" ? this.rawContent = JSON.parse(t.content) : this.rawContent = t.content;
|
|
@@ -752,13 +752,13 @@ const C = [
|
|
|
752
752
|
this.rawContent = t.content;
|
|
753
753
|
}
|
|
754
754
|
const i = this, s = Object.getPrototypeOf(this);
|
|
755
|
-
Object.getOwnPropertyNames(s).forEach((
|
|
756
|
-
const
|
|
757
|
-
|
|
755
|
+
Object.getOwnPropertyNames(s).forEach((e) => {
|
|
756
|
+
const n = Object.getOwnPropertyDescriptor(s, e);
|
|
757
|
+
n && typeof n.get == "function" && Object.defineProperty(i, e, {
|
|
758
758
|
get: function() {
|
|
759
|
-
return i.getCachedValue(
|
|
759
|
+
return i.getCachedValue(e, () => {
|
|
760
760
|
var p;
|
|
761
|
-
return (p =
|
|
761
|
+
return (p = n.get) == null ? void 0 : p.call(i);
|
|
762
762
|
});
|
|
763
763
|
},
|
|
764
764
|
enumerable: !0,
|
|
@@ -767,7 +767,12 @@ const C = [
|
|
|
767
767
|
});
|
|
768
768
|
}
|
|
769
769
|
getCachedValue(t, i) {
|
|
770
|
-
|
|
770
|
+
try {
|
|
771
|
+
return this._cachedValues[t] || (this._cachedValues[t] = i()), this._cachedValues[t];
|
|
772
|
+
} catch (s) {
|
|
773
|
+
console.error(s);
|
|
774
|
+
return;
|
|
775
|
+
}
|
|
771
776
|
}
|
|
772
777
|
/**
|
|
773
778
|
* The live platform to which the message belongs.
|
|
@@ -782,6 +787,8 @@ const C = [
|
|
|
782
787
|
return "douyin";
|
|
783
788
|
if (this.rawType.startsWith("Kuaishou"))
|
|
784
789
|
return "kuaishou";
|
|
790
|
+
if (this.rawType.startsWith("Chzzk"))
|
|
791
|
+
return "chzzk";
|
|
785
792
|
if (i.test(this.rawType))
|
|
786
793
|
return "acfun";
|
|
787
794
|
}
|
|
@@ -798,7 +805,8 @@ const C = [
|
|
|
798
805
|
"CommonActionSignalComment",
|
|
799
806
|
"WebcastChatMessage",
|
|
800
807
|
"DANMU_MSG",
|
|
801
|
-
"KuaishouCommentFeeds"
|
|
808
|
+
"KuaishouCommentFeeds",
|
|
809
|
+
"ChzzkChatMessage"
|
|
802
810
|
],
|
|
803
811
|
gift: [
|
|
804
812
|
"LIVE_OPEN_PLATFORM_SEND_GIFT",
|
|
@@ -823,11 +831,13 @@ const C = [
|
|
|
823
831
|
],
|
|
824
832
|
guard: [
|
|
825
833
|
"LIVE_OPEN_PLATFORM_GUARD",
|
|
826
|
-
"GUARD_BUY"
|
|
834
|
+
"GUARD_BUY",
|
|
835
|
+
"ChzzkSubscriptionMessage"
|
|
827
836
|
],
|
|
828
837
|
superchat: [
|
|
829
838
|
"LIVE_OPEN_PLATFORM_SUPER_CHAT",
|
|
830
|
-
"SUPER_CHAT_MESSAGE"
|
|
839
|
+
"SUPER_CHAT_MESSAGE",
|
|
840
|
+
"ChzzkDonationMessage"
|
|
831
841
|
],
|
|
832
842
|
enter: [
|
|
833
843
|
"CommonActionSignalUserEnterRoom",
|
|
@@ -879,6 +889,8 @@ const C = [
|
|
|
879
889
|
return this.rawContent.user.nickName;
|
|
880
890
|
if (this.platform === "kuaishou" && "user" in this.rawContent)
|
|
881
891
|
return this.rawContent.user.userName;
|
|
892
|
+
if (this.platform === "chzzk" && this.rawContent.profile)
|
|
893
|
+
return JSON.parse(this.rawContent.profile).nickname;
|
|
882
894
|
}
|
|
883
895
|
/**
|
|
884
896
|
* User ID.
|
|
@@ -906,6 +918,8 @@ const C = [
|
|
|
906
918
|
return this.rawContent.user.id;
|
|
907
919
|
if (this.platform === "kuaishou" && "user" in this.rawContent)
|
|
908
920
|
return this.rawContent.user.principalId;
|
|
921
|
+
if (this.platform === "chzzk" && "uid" in this.rawContent)
|
|
922
|
+
return this.rawContent.uid;
|
|
909
923
|
}
|
|
910
924
|
get clubLevel() {
|
|
911
925
|
if (this.platform === "bilibili" || this.platform === "openblive") {
|
|
@@ -929,6 +943,7 @@ const C = [
|
|
|
929
943
|
return this.rawContent.user.fansClub.data.level;
|
|
930
944
|
}
|
|
931
945
|
get clubName() {
|
|
946
|
+
var t, i;
|
|
932
947
|
if (this.platform === "bilibili" || this.platform === "openblive") {
|
|
933
948
|
if (this.rawType === "DANMU_MSG")
|
|
934
949
|
return this.rawContent.info[3][1];
|
|
@@ -942,12 +957,12 @@ const C = [
|
|
|
942
957
|
}
|
|
943
958
|
}
|
|
944
959
|
if (this.platform === "acfun") {
|
|
945
|
-
let
|
|
946
|
-
if ("gift" in this.rawContent && (
|
|
947
|
-
return JSON.parse(
|
|
960
|
+
let s;
|
|
961
|
+
if ("gift" in this.rawContent && (s = this.rawContent.gift.userInfo), "userInfo" in this.rawContent && (s = this.rawContent.userInfo), s && s.badge.length > 0)
|
|
962
|
+
return JSON.parse(s.badge).medalInfo.clubName;
|
|
948
963
|
}
|
|
949
964
|
if (this.platform === "douyin" && "user" in this.rawContent)
|
|
950
|
-
return this.rawContent.user.fansClub.data.clubName;
|
|
965
|
+
return (i = (t = this.rawContent.user.fansClub) == null ? void 0 : t.data) == null ? void 0 : i.clubName;
|
|
951
966
|
}
|
|
952
967
|
get acfunClubUid() {
|
|
953
968
|
if (this.platform === "acfun") {
|
|
@@ -998,7 +1013,8 @@ const C = [
|
|
|
998
1013
|
bilibili: () => this.rawContent.info[1],
|
|
999
1014
|
openblive: () => this.rawContent.data.msg,
|
|
1000
1015
|
douyin: () => this.rawContent.content,
|
|
1001
|
-
kuaishou: () => this.rawContent.content
|
|
1016
|
+
kuaishou: () => this.rawContent.content,
|
|
1017
|
+
chzzk: () => this.rawContent.msg
|
|
1002
1018
|
};
|
|
1003
1019
|
return this.type === "comment" && t[this.platform] ? t[this.platform]() : this.type === "superchat" ? this.superChatComment : void 0;
|
|
1004
1020
|
}
|
|
@@ -1013,61 +1029,72 @@ const C = [
|
|
|
1013
1029
|
const {
|
|
1014
1030
|
stickerStyle: i = "",
|
|
1015
1031
|
stickerClass: s = "",
|
|
1016
|
-
emotStyle:
|
|
1017
|
-
emotClass:
|
|
1032
|
+
emotStyle: e = "",
|
|
1033
|
+
emotClass: n = "",
|
|
1018
1034
|
acfunCustomStickers: p = [],
|
|
1019
|
-
acfunCustomHtmlBuilder:
|
|
1020
|
-
} = t,
|
|
1035
|
+
acfunCustomHtmlBuilder: d
|
|
1036
|
+
} = t, f = {
|
|
1021
1037
|
acfun: () => {
|
|
1022
|
-
let o =
|
|
1038
|
+
let o = g(this.rawContent.content);
|
|
1023
1039
|
if ("emotionUrl" in this.rawContent && this.rawContent.emotionUrl)
|
|
1024
1040
|
return `<img src="${this.rawContent.emotionUrl}" alt="" style="${i}" class="${s}">`;
|
|
1025
|
-
let
|
|
1026
|
-
return p.forEach((
|
|
1027
|
-
o.includes(
|
|
1028
|
-
}),
|
|
1029
|
-
<img src="${
|
|
1041
|
+
let a;
|
|
1042
|
+
return p.forEach((c) => {
|
|
1043
|
+
o.includes(c.keyWord) && (a = c.path);
|
|
1044
|
+
}), a != null ? d != null ? d(a, o) : `<div style="display:flex;">
|
|
1045
|
+
<img src="${a}" alt="" style="${i}" class="${s}">
|
|
1030
1046
|
<div style="flex-grow:1;">${o}</div>
|
|
1031
|
-
</div>` :
|
|
1047
|
+
</div>` : g(this.rawContent.content);
|
|
1032
1048
|
},
|
|
1033
1049
|
bilibili: () => {
|
|
1034
1050
|
if (typeof this.rawContent.info[0][13] == "object")
|
|
1035
1051
|
return `<img src="${this.rawContent.info[0][13].url}" alt="" style="${i}" class="${s}">`;
|
|
1036
|
-
const o = this.rawContent.info[0][15].extra,
|
|
1037
|
-
let
|
|
1038
|
-
const
|
|
1039
|
-
for (let
|
|
1040
|
-
const F = new RegExp(`\\${
|
|
1041
|
-
|
|
1052
|
+
const o = this.rawContent.info[0][15].extra, a = JSON.parse(o);
|
|
1053
|
+
let c = g(a.content);
|
|
1054
|
+
const u = a.emots;
|
|
1055
|
+
for (let y in u) {
|
|
1056
|
+
const F = new RegExp(`\\${y}`, "g");
|
|
1057
|
+
c = c.replace(F, `<img src="${u[y].url}" alt="" style="${e}" class="${n}">`);
|
|
1042
1058
|
}
|
|
1043
|
-
return
|
|
1059
|
+
return c;
|
|
1044
1060
|
},
|
|
1045
1061
|
openblive: () => {
|
|
1046
1062
|
if (this.rawContent.data.emoji_img_url)
|
|
1047
1063
|
return `<img src="${this.rawContent.data.emoji_img_url}" alt="" style="${i}" class="${s}">`;
|
|
1048
|
-
let o =
|
|
1049
|
-
return
|
|
1050
|
-
const
|
|
1051
|
-
o = o.replace(
|
|
1064
|
+
let o = g(this.rawContent.data.msg);
|
|
1065
|
+
return D.forEach((a) => {
|
|
1066
|
+
const c = new RegExp(`\\${a[0]}`, "g");
|
|
1067
|
+
o = o.replace(c, `<img src="${a[1]}" alt="" style="${e}" class="${n}">`);
|
|
1052
1068
|
}), o;
|
|
1053
1069
|
},
|
|
1054
1070
|
douyin: () => {
|
|
1055
|
-
let o =
|
|
1056
|
-
return C.forEach((
|
|
1057
|
-
const
|
|
1058
|
-
o = o.replace(
|
|
1071
|
+
let o = g(this.rawContent.content);
|
|
1072
|
+
return C.forEach((a) => {
|
|
1073
|
+
const c = new RegExp(`\\${a[0]}`, "g");
|
|
1074
|
+
o = o.replace(c, `<img src="${a[1]}" alt="" style="${e}" class="${n}">`);
|
|
1059
1075
|
}), o;
|
|
1060
1076
|
},
|
|
1061
1077
|
kuaishou: () => {
|
|
1062
|
-
let o =
|
|
1063
|
-
return w.forEach((
|
|
1064
|
-
const
|
|
1065
|
-
o = o.replace(
|
|
1078
|
+
let o = g(this.rawContent.content);
|
|
1079
|
+
return w.forEach((a) => {
|
|
1080
|
+
const c = new RegExp(`\\${a[0]}`, "g");
|
|
1081
|
+
o = o.replace(c, `<img src="${a[1]}" alt="" style="${e}" class="${n}">`);
|
|
1066
1082
|
}), o;
|
|
1083
|
+
},
|
|
1084
|
+
chzzk: () => {
|
|
1085
|
+
let o = g(this.rawContent.msg);
|
|
1086
|
+
if (this.rawContent.extras) {
|
|
1087
|
+
const c = JSON.parse(this.rawContent.extras).emojis || {};
|
|
1088
|
+
for (let u in c) {
|
|
1089
|
+
const y = new RegExp(`\\{:${u}:}`, "g");
|
|
1090
|
+
o = o.replace(y, `<img src="${c[u]}" alt="" style="${e}" class="${n}">`);
|
|
1091
|
+
}
|
|
1092
|
+
return o;
|
|
1093
|
+
}
|
|
1067
1094
|
}
|
|
1068
1095
|
};
|
|
1069
|
-
if (this.type === "comment" &&
|
|
1070
|
-
return
|
|
1096
|
+
if (this.type === "comment" && f[this.platform])
|
|
1097
|
+
return f[this.platform]();
|
|
1071
1098
|
}
|
|
1072
1099
|
/**
|
|
1073
1100
|
* Custom comment content builder.
|
|
@@ -1079,30 +1106,39 @@ const C = [
|
|
|
1079
1106
|
CommentBuilder(t) {
|
|
1080
1107
|
const i = {
|
|
1081
1108
|
acfun: () => {
|
|
1082
|
-
let s =
|
|
1083
|
-
return t(s,
|
|
1109
|
+
let s = g(this.rawContent.content), e = "emotionUrl" in this.rawContent && this.rawContent.emotionUrl ? this.rawContent.emotionUrl : void 0;
|
|
1110
|
+
return t(s, e);
|
|
1084
1111
|
},
|
|
1085
1112
|
bilibili: () => {
|
|
1086
|
-
let s,
|
|
1113
|
+
let s, e = [];
|
|
1087
1114
|
typeof this.rawContent.info[0][13] == "object" && (s = this.rawContent.info[0][13].url);
|
|
1088
|
-
const
|
|
1089
|
-
for (let o in
|
|
1090
|
-
|
|
1091
|
-
return t(
|
|
1115
|
+
const n = this.rawContent.info[0][15].extra, p = JSON.parse(n), d = g(p.content), f = p.emots;
|
|
1116
|
+
for (let o in f)
|
|
1117
|
+
e.push([o, f[o].url]);
|
|
1118
|
+
return t(d, s, e);
|
|
1092
1119
|
},
|
|
1093
1120
|
openblive: () => {
|
|
1094
1121
|
let s;
|
|
1095
1122
|
this.rawContent.data.emoji_img_url && (s = this.rawContent.data.emoji_img_url);
|
|
1096
|
-
const
|
|
1097
|
-
return t(
|
|
1123
|
+
const e = g(this.rawContent.data.msg);
|
|
1124
|
+
return t(e, s, D);
|
|
1098
1125
|
},
|
|
1099
1126
|
douyin: () => {
|
|
1100
|
-
const s =
|
|
1127
|
+
const s = g(this.rawContent.content);
|
|
1101
1128
|
return t(s, void 0, C);
|
|
1102
1129
|
},
|
|
1103
1130
|
kuaishou: () => {
|
|
1104
|
-
const s =
|
|
1131
|
+
const s = g(this.rawContent.content);
|
|
1105
1132
|
return t(s, void 0, w);
|
|
1133
|
+
},
|
|
1134
|
+
chzzk: () => {
|
|
1135
|
+
let s = g(this.rawContent.msg), e = [];
|
|
1136
|
+
if (this.rawContent.extras) {
|
|
1137
|
+
const p = JSON.parse(this.rawContent.extras).emojis || {};
|
|
1138
|
+
for (let d in p)
|
|
1139
|
+
e.push([`{:${d}:}`, p[d]]);
|
|
1140
|
+
}
|
|
1141
|
+
return t(s, void 0, e);
|
|
1106
1142
|
}
|
|
1107
1143
|
};
|
|
1108
1144
|
if (this.type === "comment" && i[this.platform])
|
|
@@ -1123,6 +1159,10 @@ const C = [
|
|
|
1123
1159
|
return this.rawContent.data.privilege_type;
|
|
1124
1160
|
}
|
|
1125
1161
|
}
|
|
1162
|
+
if (this.platform === "chzzk") {
|
|
1163
|
+
const t = this.chzzkTier;
|
|
1164
|
+
return t && t <= 3 && t >= 1 ? 4 - t : 0;
|
|
1165
|
+
}
|
|
1126
1166
|
}
|
|
1127
1167
|
get guardNum() {
|
|
1128
1168
|
if (this.platform === "bilibili" || this.platform === "openblive") {
|
|
@@ -1131,12 +1171,22 @@ const C = [
|
|
|
1131
1171
|
if ("data" in this.rawContent && "guard_num" in this.rawContent.data)
|
|
1132
1172
|
return this.rawContent.guard_num;
|
|
1133
1173
|
}
|
|
1174
|
+
if (this.platform === "chzzk")
|
|
1175
|
+
return this.chzzkTierMonth;
|
|
1134
1176
|
}
|
|
1135
1177
|
// 可能是单价(未确认),舰长价格198实际可能为138
|
|
1136
1178
|
get guardPrice() {
|
|
1137
1179
|
if ((this.platform === "bilibili" || this.platform === "openblive") && "data" in this.rawContent && "price" in this.rawContent.data)
|
|
1138
1180
|
return this.rawContent.data.price / 1e3;
|
|
1139
1181
|
}
|
|
1182
|
+
get chzzkTier() {
|
|
1183
|
+
if (this.platform === "chzzk" && this.rawType === "ChzzkSubscriptionMessage" && this.rawContent.extras)
|
|
1184
|
+
return JSON.parse(this.rawContent.extras).tierNo;
|
|
1185
|
+
}
|
|
1186
|
+
get chzzkTierMonth() {
|
|
1187
|
+
if (this.platform === "chzzk" && this.rawType === "ChzzkSubscriptionMessage" && this.rawContent.extras)
|
|
1188
|
+
return JSON.parse(this.rawContent.extras).month;
|
|
1189
|
+
}
|
|
1140
1190
|
get giftName() {
|
|
1141
1191
|
const t = {
|
|
1142
1192
|
acfun: () => this.rawContent.giftInfo.name,
|
|
@@ -1155,16 +1205,16 @@ const C = [
|
|
|
1155
1205
|
openblive: () => this.rawContent.data.gift_num,
|
|
1156
1206
|
douyin: () => {
|
|
1157
1207
|
if (this.rawContent.sendType === 4) {
|
|
1158
|
-
const s = this.rawContent.comboCount,
|
|
1159
|
-
let
|
|
1160
|
-
return
|
|
1208
|
+
const s = this.rawContent.comboCount, e = this.rawContent.groupId, n = this.rawContent.giftId, p = this.uid, d = `${e}_${p}_${n}`;
|
|
1209
|
+
let f = 0;
|
|
1210
|
+
return h.douyinGiftGroup.has(d) && (f = h.douyinGiftGroup.get(d) ?? 0), h.douyinGiftGroup.set(d, s), h.douyinGiftGroup.size > 1024 && h.douyinGiftGroup.delete(h.douyinGiftGroup.keys().next().value ?? ""), s - f;
|
|
1161
1211
|
}
|
|
1162
1212
|
return this.rawContent.groupCount;
|
|
1163
1213
|
},
|
|
1164
1214
|
kuaishou: () => {
|
|
1165
|
-
const s = this.rawContent.batchSize * this.rawContent.comboCount,
|
|
1166
|
-
let
|
|
1167
|
-
return
|
|
1215
|
+
const s = this.rawContent.batchSize * this.rawContent.comboCount, e = this.rawContent.mergeKey;
|
|
1216
|
+
let n = 0;
|
|
1217
|
+
return h.kuaishouGiftGroup.has(e) && (n = h.kuaishouGiftGroup.get(e) ?? 0), h.kuaishouGiftGroup.set(e, s), h.kuaishouGiftGroup.size > 1024 && h.kuaishouGiftGroup.delete(h.kuaishouGiftGroup.keys().next().value ?? ""), s - n;
|
|
1168
1218
|
}
|
|
1169
1219
|
};
|
|
1170
1220
|
if (this.type === "gift" && t[this.platform])
|
|
@@ -1197,7 +1247,8 @@ const C = [
|
|
|
1197
1247
|
get superChatComment() {
|
|
1198
1248
|
const t = {
|
|
1199
1249
|
bilibili: () => this.rawContent.data.message,
|
|
1200
|
-
openblive: () => this.rawContent.data.message
|
|
1250
|
+
openblive: () => this.rawContent.data.message,
|
|
1251
|
+
chzzk: () => this.rawContent.msg
|
|
1201
1252
|
};
|
|
1202
1253
|
if (this.type === "superchat" && t[this.platform])
|
|
1203
1254
|
return t[this.platform]();
|
|
@@ -1205,7 +1256,11 @@ const C = [
|
|
|
1205
1256
|
get superChatPrice() {
|
|
1206
1257
|
const t = {
|
|
1207
1258
|
bilibili: () => this.rawContent.data.price,
|
|
1208
|
-
openblive: () => this.rawContent.data.rmb
|
|
1259
|
+
openblive: () => this.rawContent.data.rmb,
|
|
1260
|
+
chzzk: () => {
|
|
1261
|
+
if (this.rawContent.extras)
|
|
1262
|
+
return JSON.parse(this.rawContent.extras).payAmount;
|
|
1263
|
+
}
|
|
1209
1264
|
};
|
|
1210
1265
|
if (this.type === "superchat" && t[this.platform])
|
|
1211
1266
|
return t[this.platform]();
|
|
@@ -1222,29 +1277,30 @@ const C = [
|
|
|
1222
1277
|
const {
|
|
1223
1278
|
douyinSteps: i = [7, 11, 15],
|
|
1224
1279
|
kuaishouSteps: s = [7, 11, 15],
|
|
1225
|
-
acfunSteps:
|
|
1226
|
-
acfunClubUid:
|
|
1280
|
+
acfunSteps: e = [7, 11, 15],
|
|
1281
|
+
acfunClubUid: n = 0
|
|
1227
1282
|
} = t, p = (o) => {
|
|
1228
1283
|
if (this.clubLevel === void 0)
|
|
1229
1284
|
return 0;
|
|
1230
|
-
const
|
|
1231
|
-
return
|
|
1232
|
-
},
|
|
1285
|
+
const a = o.findIndex((c) => this.clubLevel <= c);
|
|
1286
|
+
return a !== -1 ? a : o.length;
|
|
1287
|
+
}, d = () => this.guardLevel && this.guardLevel > 0 ? 4 - this.guardLevel : 0, f = {
|
|
1233
1288
|
douyin: () => p(i),
|
|
1234
1289
|
kuaishou: () => p(s),
|
|
1235
|
-
acfun: () =>
|
|
1236
|
-
bilibili: () =>
|
|
1237
|
-
openblive: () =>
|
|
1290
|
+
acfun: () => n > 0 && this.acfunClubUid !== n ? 0 : p(e),
|
|
1291
|
+
bilibili: () => d(),
|
|
1292
|
+
openblive: () => d(),
|
|
1293
|
+
chzzk: () => this.chzzkTier ?? 0
|
|
1238
1294
|
};
|
|
1239
|
-
if (
|
|
1240
|
-
return
|
|
1295
|
+
if (f[this.platform])
|
|
1296
|
+
return f[this.platform]();
|
|
1241
1297
|
}
|
|
1242
1298
|
};
|
|
1243
1299
|
// groupId_userId_giftId : comboCount
|
|
1244
|
-
|
|
1245
|
-
let
|
|
1246
|
-
function
|
|
1247
|
-
return
|
|
1300
|
+
b(h, "douyinGiftGroup", /* @__PURE__ */ new Map()), b(h, "kuaishouGiftGroup", /* @__PURE__ */ new Map());
|
|
1301
|
+
let v = h;
|
|
1302
|
+
function g(r) {
|
|
1303
|
+
return r.replace(/[&<>"']/g, function(t) {
|
|
1248
1304
|
switch (t) {
|
|
1249
1305
|
case "&":
|
|
1250
1306
|
return "&";
|
|
@@ -1262,9 +1318,9 @@ function h(a) {
|
|
|
1262
1318
|
});
|
|
1263
1319
|
}
|
|
1264
1320
|
export {
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1321
|
+
v as Parser,
|
|
1322
|
+
j as WebSocketManager,
|
|
1323
|
+
N as getBfaceURL,
|
|
1268
1324
|
S as getWebSocketURL,
|
|
1269
|
-
|
|
1325
|
+
U as onMessage
|
|
1270
1326
|
};
|