buzzk 1.6.7 โ†’ 1.7.0

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 +10 -8
  2. package/lib/chat.js +48 -12
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -17,6 +17,14 @@
17
17
 
18
18
  ## ๐Ÿ“– ์—…๋ฐ์ดํŠธ ๋‚ด์—ญ
19
19
 
20
+ - ์ฑ„ํŒ… ๋ฐ์ดํ„ฐ์— Role ํ•ญ๋ชฉ ์ถ”๊ฐ€
21
+
22
+ >
23
+
24
+ - JSON์„ Parse ํ•˜๋Š” ์ค‘ ์˜ค๋ฅ˜๊ฐ€ ์ƒ๊ธฐ๋Š” ๋ฌธ์ œ ํ•ด๊ฒฐ
25
+
26
+ >
27
+
20
28
  - User-Agent ์ถ”๊ฐ€ (API ํ˜ธ์ถœ์— ์‹คํŒจํ•˜๋Š” ๋ฌธ์ œ ํ•ด๊ฒฐ)
21
29
 
22
30
  >
@@ -31,14 +39,6 @@
31
39
 
32
40
  - chat.getUserInfo ํ•จ์ˆ˜ ์ถ”๊ฐ€
33
41
 
34
- >
35
-
36
- - ๋ฐฉ์†ก ์‹œ์ž‘ ์‹œ onMessage ํ•จ์ˆ˜๊ฐ€ ์ž‘๋™ํ•˜์ง€ ์•Š๋Š” ๋ฌธ์ œ ์ˆ˜์ •
37
-
38
- >
39
-
40
- - live.getDetail ํ•จ์ˆ˜์˜ Return ๊ฐ’์— category ํ•ญ๋ชฉ ์ถ”๊ฐ€
41
-
42
42
  ## โœ’๏ธ ๋งˆ์ด๊ทธ๋ ˆ์ด์…˜ ๊ฐ€์ด๋“œ (v.1.2.x -> v.1.3.0)
43
43
 
44
44
  <details>
@@ -275,6 +275,7 @@ dotenv์™€ ํ•จ๊ป˜ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์„ ๋งค์šฐ ๊ถŒ์žฅํ•ฉ๋‹ˆ๋‹ค.
275
275
  - id
276
276
  - name
277
277
  - imageURL
278
+ - role
278
279
  - message
279
280
  - time
280
281
  - 1
@@ -301,6 +302,7 @@ dotenv์™€ ํ•จ๊ป˜ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์„ ๋งค์šฐ ๊ถŒ์žฅํ•ฉ๋‹ˆ๋‹ค.
301
302
  - id
302
303
  - name
303
304
  - imageURL
305
+ - role
304
306
  - message
305
307
  - time
306
308
  - 1
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,11 +214,20 @@ 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,
209
- profileImageUrl:null
229
+ profileImageUrl: null,
230
+ role: null
210
231
  };
211
232
  }
212
233
 
@@ -215,7 +236,8 @@ class chzzkChat {
215
236
  author: {
216
237
  id: data[o].uid,
217
238
  name: data[o].profile.nickname,
218
- imageURL: data[o].profile.profileImageUrl
239
+ imageURL: data[o].profile.profileImageUrl,
240
+ role: data[o].profile.userRoleCode
219
241
  },
220
242
  message: data[o].msg,
221
243
  time: data[o].msgTime
@@ -266,20 +288,33 @@ class chzzkChat {
266
288
 
267
289
  this.#ws.send(JSON.stringify(reqOpt));
268
290
 
269
- this.#ws.on("message", (data) => {
270
- data = JSON.parse(data);
291
+ this.#ws.on("message", async (data) => {
292
+ try {
293
+ data = await JSON.parse(data);
294
+ }
295
+
296
+ catch (error) {
297
+ return;
298
+ }
271
299
 
272
300
  if (data.cmd == 15101) {
273
301
  data = data.bdy.messageList;
274
302
  let msgList = new Map();
275
303
 
276
304
  for (let o in data) {
277
- data[o].profile = JSON.parse(data[o].profile);
305
+ try {
306
+ data[o].profile = await JSON.parse(data[o].profile);
307
+ }
308
+
309
+ catch (error) {
310
+ return;
311
+ }
278
312
 
279
313
  if (!data[o].profile) {
280
314
  data[o].profile = {
281
315
  nickname: null,
282
- profileImageUrl: null
316
+ profileImageUrl: null,
317
+ role: null
283
318
  }
284
319
  }
285
320
 
@@ -287,7 +322,8 @@ class chzzkChat {
287
322
  author: {
288
323
  id: data[o].userId,
289
324
  name: data[o].profile.nickname,
290
- imageURL: data[o].profile.profileImageUrl
325
+ imageURL: data[o].profile.profileImageUrl,
326
+ role: data[o].profile.userRoleCode
291
327
  },
292
328
  message: data[o].content,
293
329
  time: data[o].messageTime
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.7.0",
5
5
  "description": "๋ฟŒ์ง€์ง (BUZZK) - ์น˜์ง€์ง(CHZZK) ์ฑ—๋ด‡์„ ๋”์šฑ ์‰ฝ๊ฒŒ ๊ฐœ๋ฐœํ•  ์ˆ˜ ์žˆ๋„๋ก ๋•๋Š” ๋น„๊ณต์‹ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ.",
6
6
  "main": "lib/index.js",
7
7
  "type": "commonjs",