buzzk 1.6.7 → 1.6.8
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 +4 -0
- package/lib/chat.js +40 -8
- package/package.json +1 -1
package/README.md
CHANGED
package/lib/chat.js
CHANGED
|
@@ -89,8 +89,14 @@ class chzzkChat {
|
|
|
89
89
|
});
|
|
90
90
|
|
|
91
91
|
//WS Message
|
|
92
|
-
this.#ws.on("message", (data) => {
|
|
93
|
-
|
|
92
|
+
this.#ws.on("message", async (data) => {
|
|
93
|
+
try {
|
|
94
|
+
data = await JSON.parse(data);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
catch (error) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
94
100
|
|
|
95
101
|
//Update Var
|
|
96
102
|
if (data.cid) this.#chatID = data.cid;
|
|
@@ -193,8 +199,14 @@ class chzzkChat {
|
|
|
193
199
|
#onMessageHandler (callback) {
|
|
194
200
|
if (!this.#ws) return callback(null);
|
|
195
201
|
|
|
196
|
-
this.#ws.on("message", (data) => {
|
|
197
|
-
|
|
202
|
+
this.#ws.on("message", async (data) => {
|
|
203
|
+
try {
|
|
204
|
+
data = await JSON.parse(data);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
catch (error) {
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
198
210
|
|
|
199
211
|
if (data.cmd == 93101) {
|
|
200
212
|
|
|
@@ -202,7 +214,15 @@ class chzzkChat {
|
|
|
202
214
|
let msgList = new Map();
|
|
203
215
|
|
|
204
216
|
for (let o in data) {
|
|
205
|
-
if (data[o].profile)
|
|
217
|
+
if (data[o].profile) {
|
|
218
|
+
try {
|
|
219
|
+
data[o].profile = await JSON.parse(data[o].profile);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
catch (error) {
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
206
226
|
else {
|
|
207
227
|
data[o].profile = {
|
|
208
228
|
nickname: null,
|
|
@@ -266,15 +286,27 @@ class chzzkChat {
|
|
|
266
286
|
|
|
267
287
|
this.#ws.send(JSON.stringify(reqOpt));
|
|
268
288
|
|
|
269
|
-
this.#ws.on("message", (data) => {
|
|
270
|
-
|
|
289
|
+
this.#ws.on("message", async (data) => {
|
|
290
|
+
try {
|
|
291
|
+
data = await JSON.parse(data);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
catch (error) {
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
271
297
|
|
|
272
298
|
if (data.cmd == 15101) {
|
|
273
299
|
data = data.bdy.messageList;
|
|
274
300
|
let msgList = new Map();
|
|
275
301
|
|
|
276
302
|
for (let o in data) {
|
|
277
|
-
|
|
303
|
+
try {
|
|
304
|
+
data[o].profile = await JSON.parse(data[o].profile);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
catch (error) {
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
278
310
|
|
|
279
311
|
if (!data[o].profile) {
|
|
280
312
|
data[o].profile = {
|