buzzk 2.3.8 → 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 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
- return resolve(true);
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/tool.js CHANGED
@@ -23,7 +23,9 @@ function clientGet (path) {
23
23
 
24
24
  .catch((error) => {
25
25
  console.log(error);
26
- return resolve({"code": 500});
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
- return resolve({"code": 500});
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
- return resolve({"code": 500});
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
- return resolve({"code": 500});
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
- return resolve({"code": 500});
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
- return resolve({"code": 500});
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
- return resolve({"code": 500});
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
- return resolve({"code": 500});
212
+
213
+ if (error && error.status) return resolve({"code": error.status});
214
+ else return resolve({"code": 500});
199
215
  });
200
216
 
201
217
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "buzzk",
3
3
  "displayName": "BUZZK",
4
- "version": "2.3.8",
4
+ "version": "2.3.9",
5
5
  "description": "뿌지직 (BUZZK) - 치지직(CHZZK) 챗봇을 더욱 쉽게 개발할 수 있도록 돕는 비공식 라이브러리.",
6
6
  "main": "lib/index.js",
7
7
  "type": "commonjs",