buzzk 1.6.1 → 1.6.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/lib/chat.js +4 -3
- package/package.json +1 -1
package/lib/chat.js
CHANGED
|
@@ -36,6 +36,7 @@ class chzzkChat {
|
|
|
36
36
|
|
|
37
37
|
//Get ChatID
|
|
38
38
|
let cidRes = await getStatus(this.channelID);
|
|
39
|
+
if (!cidRes) return resolve(null);
|
|
39
40
|
this.#chatID = cidRes.chatID;
|
|
40
41
|
//Get ChatID
|
|
41
42
|
|
|
@@ -348,7 +349,7 @@ class chzzkChat {
|
|
|
348
349
|
|
|
349
350
|
//Get ChatID
|
|
350
351
|
let cidRes = await getStatus(this.channelID);
|
|
351
|
-
if (cidRes.chatID && cidRes.chatID != this.#chatID) {
|
|
352
|
+
if (cidRes && cidRes.chatID && cidRes.chatID != this.#chatID) {
|
|
352
353
|
this.#chatID = cidRes.chatID;
|
|
353
354
|
|
|
354
355
|
//Reconnect
|
|
@@ -364,7 +365,7 @@ class chzzkChat {
|
|
|
364
365
|
//Get ChatID
|
|
365
366
|
|
|
366
367
|
let interval;
|
|
367
|
-
if (cidRes.polling && cidRes.polling.callPeriodMilliSecond) interval = cidRes.polling.callPeriodMilliSecond;
|
|
368
|
+
if (cidRes && cidRes.polling && cidRes.polling.callPeriodMilliSecond) interval = cidRes.polling.callPeriodMilliSecond;
|
|
368
369
|
else interval = 10000;
|
|
369
370
|
|
|
370
371
|
setTimeout(() => {
|
|
@@ -380,7 +381,7 @@ class chzzkChat {
|
|
|
380
381
|
"ver": "2",
|
|
381
382
|
"cmd": 0
|
|
382
383
|
};
|
|
383
|
-
this.#ws.send(JSON.stringify(pingOpt));
|
|
384
|
+
if (this.#ws.readyState == WebSocket.OPEN) this.#ws.send(JSON.stringify(pingOpt));
|
|
384
385
|
|
|
385
386
|
setTimeout(() => {
|
|
386
387
|
return this.#ping();
|