buzzk 1.7.1 โ 1.8.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.
- package/README.md +7 -3
- package/lib/chat.js +96 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,7 +17,11 @@
|
|
|
17
17
|
|
|
18
18
|
## ๐ ์
๋ฐ์ดํธ ๋ด์ญ
|
|
19
19
|
|
|
20
|
-
-
|
|
20
|
+
- ๋ณธ์ธ ์ธ์ฆ ์ฑํ
์ง์ ์ถ๊ฐ
|
|
21
|
+
|
|
22
|
+
>
|
|
23
|
+
|
|
24
|
+
- ์ฑํ
๋ฐ์ดํฐ์ hasMod ํญ๋ชฉ ์ถ๊ฐ
|
|
21
25
|
|
|
22
26
|
>
|
|
23
27
|
|
|
@@ -275,7 +279,7 @@ dotenv์ ํจ๊ป ์ฌ์ฉํ๋ ๊ฒ์ ๋งค์ฐ ๊ถ์ฅํฉ๋๋ค.
|
|
|
275
279
|
- id
|
|
276
280
|
- name
|
|
277
281
|
- imageURL
|
|
278
|
-
-
|
|
282
|
+
- hasMod //๊ด๋ฆฌ ๊ถํ์ ๊ฐ์ก๋์ง (false / true)
|
|
279
283
|
- message
|
|
280
284
|
- time
|
|
281
285
|
- 1
|
|
@@ -302,7 +306,7 @@ dotenv์ ํจ๊ป ์ฌ์ฉํ๋ ๊ฒ์ ๋งค์ฐ ๊ถ์ฅํฉ๋๋ค.
|
|
|
302
306
|
- id
|
|
303
307
|
- name
|
|
304
308
|
- imageURL
|
|
305
|
-
-
|
|
309
|
+
- hasMod //๊ด๋ฆฌ ๊ถํ์ ๊ฐ์ก๋์ง (false / true)
|
|
306
310
|
- message
|
|
307
311
|
- time
|
|
308
312
|
- 1
|
package/lib/chat.js
CHANGED
|
@@ -12,6 +12,7 @@ class chzzkChat {
|
|
|
12
12
|
#ws; //Chat Web Socket
|
|
13
13
|
#ssID; //kr-ss?.chat.naver.com/chat
|
|
14
14
|
#accTkn; //Account Access Token
|
|
15
|
+
#extTkn //for RealName Auth
|
|
15
16
|
#svcid; //game
|
|
16
17
|
#uid;
|
|
17
18
|
#sid;
|
|
@@ -43,7 +44,9 @@ class chzzkChat {
|
|
|
43
44
|
//Get accTkn
|
|
44
45
|
let accRes = await reqGame("nng_main/v1/chats/access-token?channelId=" + this.#chatID + "&chatType=STREAMING");
|
|
45
46
|
if (accRes.code != 200) return resolve(null);
|
|
47
|
+
console.log(accRes);
|
|
46
48
|
this.#accTkn = accRes.content.accessToken;
|
|
49
|
+
this.#extTkn = accRes.content.extraToken;
|
|
47
50
|
//Get accTkn
|
|
48
51
|
|
|
49
52
|
//Load Balancing
|
|
@@ -138,7 +141,8 @@ class chzzkChat {
|
|
|
138
141
|
"chatType":"STREAMING",
|
|
139
142
|
"osType":"PC",
|
|
140
143
|
"streamingChannelId": this.channelID,
|
|
141
|
-
"emojis":""
|
|
144
|
+
"emojis":"",
|
|
145
|
+
"extraToken": this.#extTkn
|
|
142
146
|
}
|
|
143
147
|
|
|
144
148
|
//WS Send
|
|
@@ -184,7 +188,7 @@ class chzzkChat {
|
|
|
184
188
|
* @property {string} id
|
|
185
189
|
* @property {string} name
|
|
186
190
|
* @property {string} imageURL
|
|
187
|
-
* @property {
|
|
191
|
+
* @property {boolean} hasMod
|
|
188
192
|
*/
|
|
189
193
|
|
|
190
194
|
/**
|
|
@@ -193,7 +197,10 @@ class chzzkChat {
|
|
|
193
197
|
onMessage(callback) {
|
|
194
198
|
if (!this.#ws) return callback(null);
|
|
195
199
|
|
|
196
|
-
this.#callbacks[Object.keys(this.#callbacks).length] =
|
|
200
|
+
this.#callbacks[Object.keys(this.#callbacks).length] = {
|
|
201
|
+
type: "message",
|
|
202
|
+
callback: callback
|
|
203
|
+
};
|
|
197
204
|
this.#onMessageHandler(callback);
|
|
198
205
|
}
|
|
199
206
|
|
|
@@ -228,17 +235,94 @@ class chzzkChat {
|
|
|
228
235
|
data[o].profile = {
|
|
229
236
|
nickname: null,
|
|
230
237
|
profileImageUrl: null,
|
|
231
|
-
|
|
238
|
+
userRoleCode: null
|
|
232
239
|
};
|
|
233
240
|
}
|
|
234
241
|
|
|
235
242
|
try {
|
|
243
|
+
let modVal = false;
|
|
244
|
+
if (data[o].profile.userRoleCode === "streamer" || data[o].profile.userRoleCode === "streaming_channel_manager" || data[o].profile.userRoleCode === "streaming_chat_manager") modVal = true;
|
|
245
|
+
|
|
236
246
|
msgList[Object.keys(msgList).length] = {
|
|
237
247
|
author: {
|
|
238
248
|
id: data[o].uid,
|
|
239
249
|
name: data[o].profile.nickname,
|
|
240
250
|
imageURL: data[o].profile.profileImageUrl,
|
|
241
|
-
|
|
251
|
+
hasMod: modVal
|
|
252
|
+
},
|
|
253
|
+
message: data[o].msg,
|
|
254
|
+
time: data[o].msgTime
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
catch(error) {
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
callback(msgList);
|
|
264
|
+
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
onDonation(callback) {
|
|
270
|
+
if (!this.#ws) return callback(null);
|
|
271
|
+
|
|
272
|
+
this.#callbacks[Object.keys(this.#callbacks).length] = {
|
|
273
|
+
type: "donation",
|
|
274
|
+
callback: callback
|
|
275
|
+
};
|
|
276
|
+
this.#onDonationHandler(callback);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
#onDonationHandler (callback) {
|
|
280
|
+
if (!this.#ws) return callback(null);
|
|
281
|
+
|
|
282
|
+
this.#ws.on("message", async (data) => {
|
|
283
|
+
try {
|
|
284
|
+
data = await JSON.parse(data);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
catch (error) {
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
if (data.cmd == 93102) {
|
|
292
|
+
|
|
293
|
+
data = data.bdy;
|
|
294
|
+
let msgList = new Map();
|
|
295
|
+
|
|
296
|
+
for (let o in data) {
|
|
297
|
+
if (data[o].profile) {
|
|
298
|
+
try {
|
|
299
|
+
data[o].profile = await JSON.parse(data[o].profile);
|
|
300
|
+
data[o].extras = await JSON.parse(data[o].extras);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
catch (error) {
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
else {
|
|
308
|
+
data[o].profile = {
|
|
309
|
+
nickname: null,
|
|
310
|
+
profileImageUrl: null,
|
|
311
|
+
userRoleCode: null
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
try {
|
|
316
|
+
let modVal = false;
|
|
317
|
+
if (data[o].profile.userRoleCode === "streamer" || data[o].profile.userRoleCode === "streaming_channel_manager" || data[o].profile.userRoleCode === "streaming_chat_manager") modVal = true;
|
|
318
|
+
|
|
319
|
+
msgList[Object.keys(msgList).length] = {
|
|
320
|
+
amount: data[o].extras.payAmount,
|
|
321
|
+
author: {
|
|
322
|
+
id: data[o].uid,
|
|
323
|
+
name: data[o].profile.nickname,
|
|
324
|
+
imageURL: data[o].profile.profileImageUrl,
|
|
325
|
+
hasMod: modVal
|
|
242
326
|
},
|
|
243
327
|
message: data[o].msg,
|
|
244
328
|
time: data[o].msgTime
|
|
@@ -315,16 +399,19 @@ class chzzkChat {
|
|
|
315
399
|
data[o].profile = {
|
|
316
400
|
nickname: null,
|
|
317
401
|
profileImageUrl: null,
|
|
318
|
-
|
|
402
|
+
userRoleCode: null
|
|
319
403
|
}
|
|
320
404
|
}
|
|
405
|
+
|
|
406
|
+
let modVal = false;
|
|
407
|
+
if (data[o].profile.userRoleCode === "streamer" || data[o].profile.userRoleCode === "streaming_channel_manager" || data[o].profile.userRoleCode === "streaming_chat_manager") modVal = true;
|
|
321
408
|
|
|
322
409
|
msgList[Object.keys(msgList).length] = {
|
|
323
410
|
author: {
|
|
324
411
|
id: data[o].userId,
|
|
325
412
|
name: data[o].profile.nickname,
|
|
326
413
|
imageURL: data[o].profile.profileImageUrl,
|
|
327
|
-
|
|
414
|
+
hasMod: modVal
|
|
328
415
|
},
|
|
329
416
|
message: data[o].content,
|
|
330
417
|
time: data[o].messageTime
|
|
@@ -400,7 +487,8 @@ class chzzkChat {
|
|
|
400
487
|
await this.disconnect();
|
|
401
488
|
await this.connect();
|
|
402
489
|
for (let o in this.#callbacks) {
|
|
403
|
-
this.#onMessageHandler(this.#callbacks[o]);
|
|
490
|
+
if (this.#callbacks[o].type === "message") this.#onMessageHandler(this.#callbacks[o].callback);
|
|
491
|
+
else if (this.#callbacks[o].type === "donation") this.#onDonationHandler(this.#callbacks[o].callback);
|
|
404
492
|
}
|
|
405
493
|
return;
|
|
406
494
|
//Reconnect
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "buzzk",
|
|
3
3
|
"displayName": "BUZZK",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.8.0",
|
|
5
5
|
"description": "๋ฟ์ง์ง (BUZZK) - ์น์ง์ง(CHZZK) ์ฑ๋ด์ ๋์ฑ ์ฝ๊ฒ ๊ฐ๋ฐํ ์ ์๋๋ก ๋๋ ๋น๊ณต์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ.",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"type": "commonjs",
|