buzzk 1.6.6 โ†’ 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 CHANGED
@@ -17,6 +17,14 @@
17
17
 
18
18
  ## ๐Ÿ“– ์—…๋ฐ์ดํŠธ ๋‚ด์—ญ
19
19
 
20
+ - JSON์„ Parse ํ•˜๋Š” ์ค‘ ์˜ค๋ฅ˜๊ฐ€ ์ƒ๊ธฐ๋Š” ๋ฌธ์ œ ํ•ด๊ฒฐ
21
+
22
+ >
23
+
24
+ - User-Agent ์ถ”๊ฐ€ (API ํ˜ธ์ถœ์— ์‹คํŒจํ•˜๋Š” ๋ฌธ์ œ ํ•ด๊ฒฐ)
25
+
26
+ >
27
+
20
28
  - chat ์˜ ๋ฉ”์„ธ์ง€๋ฅผ ํ•ธ๋“ค๋งํ•˜๋˜ ์ค‘ ์˜๋„์น˜ ์•Š๊ฒŒ ์˜ค๋ฅ˜๊ฐ€ ๋‚˜๋Š” ๋ฌธ์ œ ํ•ด๊ฒฐ
21
29
 
22
30
  >
@@ -35,11 +43,6 @@
35
43
 
36
44
  - live.getDetail ํ•จ์ˆ˜์˜ Return ๊ฐ’์— category ํ•ญ๋ชฉ ์ถ”๊ฐ€
37
45
 
38
- >
39
-
40
- - ์ฑ„ํŒ…์ฐฝ ์—ฐ๊ฒฐ์ด ๋Š๊ธฐ๋˜ ๋ฌธ์ œ ํ•ด๊ฒฐ (Ping ์ถ”๊ฐ€)
41
- - ์ฑ„ํŒ…์ฐฝ ID ๋ณ€๊ฒฝ ์‹œ ์žฌ์—ฐ๊ฒฐ ๊ตฌํ˜„
42
-
43
46
  ## โœ’๏ธ ๋งˆ์ด๊ทธ๋ ˆ์ด์…˜ ๊ฐ€์ด๋“œ (v.1.2.x -> v.1.3.0)
44
47
 
45
48
  <details>
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/lib/tool.js CHANGED
@@ -1,4 +1,5 @@
1
1
  const { chzzkBaseURL, gameBaseURL, NID } = require("./val.js");
2
+ const vm = require("./vm.js");
2
3
 
3
4
  function reqChzzk (path) {
4
5
  return new Promise(async (resolve, reject) => {
@@ -7,7 +8,7 @@ function reqChzzk (path) {
7
8
  method: "GET",
8
9
  headers: {
9
10
  "Cookie": "NID_AUT=" + NID.AUT + ";NID_SES=" + NID.SES,
10
- "User-Agent": "BUZZK Lib (v.1.6.5, Node)"
11
+ "User-Agent": "BuzzkLib/" + vm.getVersion() + " (Node)"
11
12
  }
12
13
  })
13
14
 
@@ -23,7 +24,7 @@ function exChzzk (method, path) {
23
24
  method: method,
24
25
  headers: {
25
26
  "Cookie": "NID_AUT=" + NID.AUT + ";NID_SES=" + NID.SES,
26
- "User-Agent": "BUZZK Lib (v.1.6.5, Node)"
27
+ "User-Agent": "BuzzkLib/" + vm.getVersion() + " (Node)"
27
28
  }
28
29
  })
29
30
 
package/lib/vm.js CHANGED
@@ -1,5 +1,9 @@
1
- async function check () {
1
+ function getVersion () {
2
+ let localPkg = require("../package.json");
3
+ return localPkg.version;
4
+ }
2
5
 
6
+ async function check () {
3
7
  let localPkg = require("../package.json");
4
8
  let remotePkg = await fetch("https://raw.githubusercontent.com/Emin-G/buzzk/master/package.json");
5
9
 
@@ -15,4 +19,8 @@ async function check () {
15
19
  }
16
20
  }
17
21
 
18
- check();
22
+ check();
23
+
24
+ module.exports = {
25
+ getVersion: getVersion
26
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "buzzk",
3
3
  "displayName": "BUZZK",
4
- "version": "1.6.6",
4
+ "version": "1.6.8",
5
5
  "description": "๋ฟŒ์ง€์ง (BUZZK) - ์น˜์ง€์ง(CHZZK) ์ฑ—๋ด‡์„ ๋”์šฑ ์‰ฝ๊ฒŒ ๊ฐœ๋ฐœํ•  ์ˆ˜ ์žˆ๋„๋ก ๋•๋Š” ๋น„๊ณต์‹ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ.",
6
6
  "main": "lib/index.js",
7
7
  "type": "commonjs",