buzzk 2.3.7 → 2.3.9
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 +17 -2
- package/lib/chat.js +17 -2
- package/lib/oauth.js +3 -2
- package/lib/tool.js +24 -8
- package/lib/val.js +0 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -32,6 +32,21 @@
|
|
|
32
32
|
|
|
33
33
|
---
|
|
34
34
|
|
|
35
|
+
## ✒️ 마이그레이션 가이드 (v.2.3.x -> v.2.3.8)
|
|
36
|
+
|
|
37
|
+
<details>
|
|
38
|
+
<summary>펼쳐보기</summary>
|
|
39
|
+
|
|
40
|
+
buzzk.oauth
|
|
41
|
+
|
|
42
|
+
| <img src="https://github.com/Emin-G/Img/blob/main/tags/tag_change-min.png?raw=true" alt="BUZZK" width="70"> | buzzk.oauth.get("Code 값") |
|
|
43
|
+
|--|--|
|
|
44
|
+
| | buzzk.oauth.get("Code 값", "State 값") |
|
|
45
|
+
|
|
46
|
+
</details>
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
35
50
|
## ✒️ 마이그레이션 가이드 (v.2.0.x -> v.2.1.0)
|
|
36
51
|
|
|
37
52
|
<details>
|
|
@@ -148,7 +163,7 @@
|
|
|
148
163
|
|
|
149
164
|
async function test () {
|
|
150
165
|
|
|
151
|
-
let oauth = buzzk.oauth.get("code 값");
|
|
166
|
+
let oauth = buzzk.oauth.get("code 값", "state 값");
|
|
152
167
|
|
|
153
168
|
let chat = new buzzkChat(oauth.access);
|
|
154
169
|
await chat.connect(); //채팅창 연결
|
|
@@ -212,7 +227,7 @@ dotenv와 함께 사용하는 것을 매우 권장합니다.
|
|
|
212
227
|
|
|
213
228
|
✅ Official API
|
|
214
229
|
|
|
215
|
-
let oauth = await buzzk.oauth.get("Code 값");
|
|
230
|
+
let oauth = await buzzk.oauth.get("Code 값", "State 값");
|
|
216
231
|
console.log(oauth);
|
|
217
232
|
|
|
218
233
|
<details>
|
package/lib/chat.js
CHANGED
|
@@ -248,9 +248,24 @@ class chzzkChat {
|
|
|
248
248
|
}
|
|
249
249
|
|
|
250
250
|
let chatRes = await USER.post(this.accessToken, "open/v1/chats/send", JSON.stringify(reqMessage));
|
|
251
|
-
if (!chatRes || chatRes.code != 200) return resolve(false);
|
|
252
251
|
|
|
253
|
-
|
|
252
|
+
//rate-limit
|
|
253
|
+
if (chatRes && chatRes.code == 429) {
|
|
254
|
+
let chatRetry = Math.floor(Math.random() * 500) + 500;
|
|
255
|
+
|
|
256
|
+
setTimeout(async () => {
|
|
257
|
+
let retRes = await USER.post(this.accessToken, "open/v1/chats/send", JSON.stringify(reqMessage));
|
|
258
|
+
|
|
259
|
+
if (!retRes || retRes.code != 200) return resolve(false);
|
|
260
|
+
return resolve(true);
|
|
261
|
+
}, chatRetry);
|
|
262
|
+
}
|
|
263
|
+
//rate-limit
|
|
264
|
+
|
|
265
|
+
else {
|
|
266
|
+
if (!chatRes || chatRes.code != 200) return resolve(false);
|
|
267
|
+
return resolve(true);
|
|
268
|
+
}
|
|
254
269
|
});
|
|
255
270
|
}
|
|
256
271
|
|
package/lib/oauth.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const { USER, CLIENT } = require("./tool.js");
|
|
2
|
-
const { AUTH
|
|
2
|
+
const { AUTH } = require("./val.js");
|
|
3
3
|
|
|
4
4
|
const channel = require("./channel.js");
|
|
5
5
|
|
|
@@ -28,9 +28,10 @@ class chzzkToken {
|
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* @param {string} code
|
|
31
|
+
* @param {string} state
|
|
31
32
|
* @returns {Promise<chzzkTokenData>}
|
|
32
33
|
*/
|
|
33
|
-
async function get (code) {
|
|
34
|
+
async function get (code, state) {
|
|
34
35
|
return new Promise(async (resolve, reject) => {
|
|
35
36
|
let options = {
|
|
36
37
|
grantType: "authorization_code",
|
package/lib/tool.js
CHANGED
|
@@ -23,7 +23,9 @@ function clientGet (path) {
|
|
|
23
23
|
|
|
24
24
|
.catch((error) => {
|
|
25
25
|
console.log(error);
|
|
26
|
-
|
|
26
|
+
|
|
27
|
+
if (error && error.status) return resolve({"code": error.status});
|
|
28
|
+
else return resolve({"code": 500});
|
|
27
29
|
});
|
|
28
30
|
|
|
29
31
|
});
|
|
@@ -50,7 +52,9 @@ function clientPost (path, body) {
|
|
|
50
52
|
|
|
51
53
|
.catch((error) => {
|
|
52
54
|
console.log(error);
|
|
53
|
-
|
|
55
|
+
|
|
56
|
+
if (error && error.status) return resolve({"code": error.status});
|
|
57
|
+
else return resolve({"code": 500});
|
|
54
58
|
});
|
|
55
59
|
|
|
56
60
|
});
|
|
@@ -75,7 +79,9 @@ function userGet (token, path) {
|
|
|
75
79
|
|
|
76
80
|
.catch((error) => {
|
|
77
81
|
console.log(error);
|
|
78
|
-
|
|
82
|
+
|
|
83
|
+
if (error && error.status) return resolve({"code": error.status});
|
|
84
|
+
else return resolve({"code": 500});
|
|
79
85
|
});
|
|
80
86
|
|
|
81
87
|
});
|
|
@@ -101,7 +107,9 @@ function userPost (token, path, body) {
|
|
|
101
107
|
|
|
102
108
|
.catch((error) => {
|
|
103
109
|
console.log(error);
|
|
104
|
-
|
|
110
|
+
|
|
111
|
+
if (error && error.status) return resolve({"code": error.status});
|
|
112
|
+
else return resolve({"code": 500});
|
|
105
113
|
});
|
|
106
114
|
|
|
107
115
|
});
|
|
@@ -125,7 +133,9 @@ function reqChzzk (path) {
|
|
|
125
133
|
|
|
126
134
|
.catch((error) => {
|
|
127
135
|
console.log(error);
|
|
128
|
-
|
|
136
|
+
|
|
137
|
+
if (error && error.status) return resolve({"code": error.status});
|
|
138
|
+
else return resolve({"code": 500});
|
|
129
139
|
});
|
|
130
140
|
|
|
131
141
|
});
|
|
@@ -149,7 +159,9 @@ function exChzzk (method, path) {
|
|
|
149
159
|
|
|
150
160
|
.catch((error) => {
|
|
151
161
|
console.log(error);
|
|
152
|
-
|
|
162
|
+
|
|
163
|
+
if (error && error.status) return resolve({"code": error.status});
|
|
164
|
+
else return resolve({"code": 500});
|
|
153
165
|
});
|
|
154
166
|
|
|
155
167
|
});
|
|
@@ -172,7 +184,9 @@ function reqGame (path) {
|
|
|
172
184
|
|
|
173
185
|
.catch((error) => {
|
|
174
186
|
console.log(error);
|
|
175
|
-
|
|
187
|
+
|
|
188
|
+
if (error && error.status) return resolve({"code": error.status});
|
|
189
|
+
else return resolve({"code": 500});
|
|
176
190
|
});
|
|
177
191
|
|
|
178
192
|
});
|
|
@@ -195,7 +209,9 @@ function reqNaver (path) {
|
|
|
195
209
|
|
|
196
210
|
.catch((error) => {
|
|
197
211
|
console.log(error);
|
|
198
|
-
|
|
212
|
+
|
|
213
|
+
if (error && error.status) return resolve({"code": error.status});
|
|
214
|
+
else return resolve({"code": 500});
|
|
199
215
|
});
|
|
200
216
|
|
|
201
217
|
});
|
package/lib/val.js
CHANGED
|
@@ -3,8 +3,6 @@ const chzzkBaseURL = "https://api.chzzk.naver.com/";
|
|
|
3
3
|
const gameBaseURL = "https://comm-api.game.naver.com/";
|
|
4
4
|
const naverBaseURL = "https://apis.naver.com/";
|
|
5
5
|
|
|
6
|
-
const state = "zxclDasdfA25";
|
|
7
|
-
|
|
8
6
|
let NID = {
|
|
9
7
|
AUT: null,
|
|
10
8
|
SES: null
|
|
@@ -38,7 +36,6 @@ module.exports = {
|
|
|
38
36
|
chzzkBaseURL: chzzkBaseURL,
|
|
39
37
|
gameBaseURL: gameBaseURL,
|
|
40
38
|
naverBaseURL: naverBaseURL,
|
|
41
|
-
state: state,
|
|
42
39
|
NID: NID,
|
|
43
40
|
AUTH: AUTH,
|
|
44
41
|
login: login,
|