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.
Files changed (3) hide show
  1. package/README.md +4 -0
  2. package/lib/chat.js +40 -8
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -17,6 +17,10 @@
17
17
 
18
18
  ## 📖 업데이트 내역
19
19
 
20
+ - JSON을 Parse 하는 중 오류가 생기는 문제 해결
21
+
22
+ >
23
+
20
24
  - User-Agent 추가 (API 호출에 실패하는 문제 해결)
21
25
 
22
26
  >
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
- data = JSON.parse(data);
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
- data = JSON.parse(data);
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) data[o].profile = JSON.parse(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
- data = JSON.parse(data);
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
- data[o].profile = JSON.parse(data[o].profile);
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 = {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "buzzk",
3
3
  "displayName": "BUZZK",
4
- "version": "1.6.7",
4
+ "version": "1.6.8",
5
5
  "description": "뿌지직 (BUZZK) - 치지직(CHZZK) 챗봇을 더욱 쉽게 개발할 수 있도록 돕는 비공식 라이브러리.",
6
6
  "main": "lib/index.js",
7
7
  "type": "commonjs",