buzzk 1.9.11 → 1.9.13

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 (2) hide show
  1. package/lib/chat.js +25 -6
  2. package/package.json +1 -1
package/lib/chat.js CHANGED
@@ -74,7 +74,9 @@ class chzzkChat {
74
74
  //Load Balancing
75
75
 
76
76
  //Connect Web Socket
77
- this.#ws = new WebSocket("wss://kr-ss" + this.#ssID + ".chat.naver.com/chat");
77
+ this.#ws = new WebSocket("wss://kr-ss" + this.#ssID + ".chat.naver.com/chat", {
78
+ handshakeTimeout: 60000
79
+ });
78
80
  this.#status.wsID++;
79
81
  //Connect Web Socket
80
82
 
@@ -94,6 +96,14 @@ class chzzkChat {
94
96
  });
95
97
  }
96
98
 
99
+ getwsID() {
100
+ return this.#status.wsID;
101
+ }
102
+
103
+ getwsStatus() {
104
+ return this.#status.ws;
105
+ }
106
+
97
107
  #openHandler(wsID) {
98
108
  return new Promise(async (resolve, reject) => {
99
109
  this.#ws.on("open", () => {
@@ -112,6 +122,7 @@ class chzzkChat {
112
122
  "accTkn": this.#accTkn,
113
123
  "auth":"SEND",
114
124
  "devName": "BUZZK/" + vm.getVersion(),
125
+ "libVer": vm.getVersion(),
115
126
  "locale": "ko",
116
127
  "osVer": "Windows/10",
117
128
  "timezone": "Asia/Seoul"
@@ -217,7 +228,7 @@ class chzzkChat {
217
228
  //WS Send
218
229
  let date = new Date();
219
230
  let sendOpt = {
220
- "ver": "2",
231
+ "ver": "3",
221
232
  "cmd": 3101,
222
233
  "svcid": this.#svcid,
223
234
  "cid": this.#chatID,
@@ -233,7 +244,13 @@ class chzzkChat {
233
244
  "tid": 3
234
245
  };
235
246
 
236
- this.#ws.send(JSON.stringify(sendOpt));
247
+ try {
248
+ this.#ws.send(JSON.stringify(sendOpt));
249
+ }
250
+
251
+ catch (error) {
252
+ return resolve(false);
253
+ }
237
254
 
238
255
  return resolve(true);
239
256
  //WS Send
@@ -558,7 +575,7 @@ class chzzkChat {
558
575
  }
559
576
  //Get ChatID
560
577
 
561
- let interval = 30000;
578
+ let interval = Math.floor(Math.random() * 20000) + 30000;
562
579
 
563
580
  setTimeout(() => {
564
581
  return this.#polling();
@@ -569,6 +586,8 @@ class chzzkChat {
569
586
  if (!this.#status.ws) return this.#status.ping = false;
570
587
  if (!this.#status.ping || pingID != this.#status.pingID) return;
571
588
 
589
+ let interval = Math.floor(Math.random() * 20000) + 30000;
590
+
572
591
  let pingOpt = {
573
592
  "ver": "3",
574
593
  "cmd": 0
@@ -579,12 +598,12 @@ class chzzkChat {
579
598
  catch (error) {
580
599
  return setTimeout(async () => {
581
600
  return this.#ping(pingID);
582
- }, 30000);
601
+ }, Math.floor(Math.random() * 20000) + 30000);
583
602
  }
584
603
 
585
604
  setTimeout(() => {
586
605
  return this.#ping(pingID);
587
- }, 30000);
606
+ }, interval);
588
607
  }
589
608
  }
590
609
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "buzzk",
3
3
  "displayName": "BUZZK",
4
- "version": "1.9.11",
4
+ "version": "1.9.13",
5
5
  "description": "뿌지직 (BUZZK) - 치지직(CHZZK) 챗봇을 더욱 쉽게 개발할 수 있도록 돕는 비공식 라이브러리.",
6
6
  "main": "lib/index.js",
7
7
  "type": "commonjs",