buzzk 1.2.0 → 1.3.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 +118 -24
- package/lib/channel.js +27 -7
- package/lib/chat.js +3 -3
- package/lib/live.js +12 -6
- package/lib/val.js +0 -1
- package/package.json +10 -2
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
<img
|
|
1
|
+
<img src="https://github.com/Emin-G/Img/blob/main/buzzk/buzzk_pamplet.gif?raw=true" alt="BuzzkThumb" width="100%">
|
|
2
2
|
|
|
3
3
|
# 뿌지직
|
|
4
4
|
|
|
5
5
|
<p align="center">
|
|
6
|
-
<img
|
|
6
|
+
<img src="https://github.com/Emin-G/Img/blob/main/buzzk/buzzk_favi-min.png?raw=true" alt="BUZZK" width="30%">
|
|
7
7
|
</p>
|
|
8
8
|
|
|
9
9
|
<p align="center">
|
|
@@ -15,12 +15,20 @@
|
|
|
15
15
|
|
|
16
16
|
---
|
|
17
17
|
|
|
18
|
-
## 업데이트 내역
|
|
18
|
+
## 📖 업데이트 내역
|
|
19
19
|
|
|
20
|
-
-
|
|
20
|
+
- 함수 이름 수정
|
|
21
|
+
|
|
22
|
+
**하단의 1.3.0 마이그레이션 가이드 참고**
|
|
21
23
|
|
|
22
24
|
>
|
|
23
25
|
|
|
26
|
+
- channelID로 채널 정보 가져오기 함수 추가
|
|
27
|
+
- ws 라이브러리 종속성 추가
|
|
28
|
+
|
|
29
|
+
>
|
|
30
|
+
|
|
31
|
+
- 자동완성 기능 지원
|
|
24
32
|
- 팔로우 / 언팔로우 기능 추가
|
|
25
33
|
- live.getLiveDetail의 Return 값에 chatLimit 추가 (팔로우 대상 채팅 등...)
|
|
26
34
|
- 폴링 함수 추가 (chatID 변경 감지)
|
|
@@ -28,12 +36,75 @@
|
|
|
28
36
|
- chat.disconnect 함수 보완
|
|
29
37
|
- 버전 체크 함수 추가
|
|
30
38
|
|
|
31
|
-
##
|
|
39
|
+
## ✒️ 마이그레이션 가이드 (v.1.3.0)
|
|
40
|
+
|
|
41
|
+
<details>
|
|
42
|
+
<summary>펼쳐보기</summary>
|
|
43
|
+
|
|
44
|
+
buzzk.channel
|
|
45
|
+
|
|
46
|
+
| <img src="https://github.com/Emin-G/Img/blob/main/tags/tag_change-min.png?raw=true" alt="BUZZK" width="70"> | buzzk.channel.getChannel |
|
|
47
|
+
|--|--|
|
|
48
|
+
| | buzzk.channel.search |
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
| <img src="https://github.com/Emin-G/Img/blob/main/tags/tag_change-min.png?raw=true" alt="BUZZK" width="70"> | buzzk.channel.followChannel |
|
|
53
|
+
|--|--|
|
|
54
|
+
| | buzzk.channel.follow |
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
| <img src="https://github.com/Emin-G/Img/blob/main/tags/tag_change-min.png?raw=true" alt="BUZZK" width="70"> | buzzk.channel.unFollowChannel |
|
|
59
|
+
|--|--|
|
|
60
|
+
| | buzzk.channel.unFollow |
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
buzzk.live
|
|
65
|
+
|
|
66
|
+
| <img src="https://github.com/Emin-G/Img/blob/main/tags/tag_change-min.png?raw=true" alt="BUZZK" width="70"> | buzzk.live.getLiveDetail |
|
|
67
|
+
|--|--|
|
|
68
|
+
| | buzzk.live.getDetail |
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
| <img src="https://github.com/Emin-G/Img/blob/main/tags/tag_change-min.png?raw=true" alt="BUZZK" width="70"> | buzzk.live.getLiveStatus |
|
|
73
|
+
|--|--|
|
|
74
|
+
| | buzzk.live.getStatus |
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
buzzk.live.getDetail (getLiveDetail)
|
|
79
|
+
|
|
80
|
+
| <img src="https://github.com/Emin-G/Img/blob/main/tags/tag_change-min.png?raw=true" alt="BUZZK" width="70"> | (return).channel.channelName |
|
|
81
|
+
|--|--|
|
|
82
|
+
| | (return).channel.name |
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
| <img src="https://github.com/Emin-G/Img/blob/main/tags/tag_change-min.png?raw=true" alt="BUZZK" width="70"> | (return).channel.channelImageUrl |
|
|
87
|
+
|--|--|
|
|
88
|
+
| | (return).channel.imageURL |
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
| <img src="https://github.com/Emin-G/Img/blob/main/tags/tag_delete-min.png?raw=true" alt="BUZZK" width="70"> | (return).channel.channelId |
|
|
93
|
+
|--|--|
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
| <img src="https://github.com/Emin-G/Img/blob/main/tags/tag_delete-min.png?raw=true" alt="BUZZK" width="70"> | (return).channel.verifiedMark |
|
|
98
|
+
|--|--|
|
|
99
|
+
|
|
100
|
+
</details>
|
|
101
|
+
|
|
102
|
+
## 👋 설치
|
|
32
103
|
|
|
33
104
|
1. `npm install buzzk`
|
|
34
105
|
2. `const buzzk = require("buzzk");`
|
|
35
106
|
|
|
36
|
-
## 빠른. 시작.
|
|
107
|
+
## 🔥 빠른. 시작.
|
|
37
108
|
|
|
38
109
|
const buzzk = require("buzzk");
|
|
39
110
|
buzzk.login("NID_AUT 쿠키 값", "NID_SES 쿠키 값");
|
|
@@ -42,11 +113,11 @@
|
|
|
42
113
|
|
|
43
114
|
async function test () {
|
|
44
115
|
|
|
45
|
-
let chSearch = await buzzk.channel.
|
|
116
|
+
let chSearch = await buzzk.channel.search("녹두로로"); //채널 검색
|
|
46
117
|
|
|
47
118
|
let channel = chSearch[0]; //검색 결과 첫번째 채널
|
|
48
119
|
|
|
49
|
-
const lvDetail = await buzzk.live.
|
|
120
|
+
const lvDetail = await buzzk.live.getDetail(channel.channelID); //현재 방송 정보
|
|
50
121
|
|
|
51
122
|
let chat = new buzzkChat(channel.channelID);
|
|
52
123
|
await chat.connect(); //채팅창 연결
|
|
@@ -54,7 +125,7 @@
|
|
|
54
125
|
let recentChat = await chat.getRecentChat(); //최근 채팅 가져오기 (기본값 50개)
|
|
55
126
|
console.log(recentChat);
|
|
56
127
|
|
|
57
|
-
chat.onMessage((data) => { //채팅이 왔을 때
|
|
128
|
+
chat.onMessage(async (data) => { //채팅이 왔을 때
|
|
58
129
|
for (let o in data) {
|
|
59
130
|
console.log(data[o].message);
|
|
60
131
|
|
|
@@ -67,9 +138,9 @@
|
|
|
67
138
|
|
|
68
139
|
test();
|
|
69
140
|
|
|
70
|
-
## 사용법
|
|
141
|
+
## 🎀 사용법
|
|
71
142
|
|
|
72
|
-
|
|
143
|
+
### login
|
|
73
144
|
|
|
74
145
|
buzzk.login("NID_AUT 쿠키 값", "NID_SES 쿠키 값");
|
|
75
146
|
|
|
@@ -79,13 +150,34 @@ dotenv와 함께 사용하는 것을 매우 권장합니다.
|
|
|
79
150
|
|
|
80
151
|
---
|
|
81
152
|
|
|
82
|
-
|
|
153
|
+
### channel
|
|
83
154
|
|
|
84
|
-
let chSearch = await buzzk.channel.
|
|
155
|
+
let chSearch = await buzzk.channel.search("녹두로로");
|
|
85
156
|
console.log(chSearch);
|
|
86
157
|
|
|
87
158
|
<details>
|
|
88
|
-
<summary>
|
|
159
|
+
<summary>return</summary>
|
|
160
|
+
|
|
161
|
+
- Return
|
|
162
|
+
- 0
|
|
163
|
+
- channelID
|
|
164
|
+
- name
|
|
165
|
+
- description
|
|
166
|
+
- follower
|
|
167
|
+
- imageURL
|
|
168
|
+
- isLive
|
|
169
|
+
- 1
|
|
170
|
+
- 2
|
|
171
|
+
- 3
|
|
172
|
+
- ...
|
|
173
|
+
|
|
174
|
+
</details>
|
|
175
|
+
|
|
176
|
+
let channel = await buzzk.channel.get("channelID 값");
|
|
177
|
+
console.log(channel);
|
|
178
|
+
|
|
179
|
+
<details>
|
|
180
|
+
<summary>return</summary>
|
|
89
181
|
|
|
90
182
|
- Return
|
|
91
183
|
- channelID
|
|
@@ -97,25 +189,27 @@ dotenv와 함께 사용하는 것을 매우 권장합니다.
|
|
|
97
189
|
|
|
98
190
|
</details>
|
|
99
191
|
|
|
100
|
-
await buzzk.channel.
|
|
192
|
+
await buzzk.channel.follow("channelID 값");
|
|
101
193
|
|
|
102
194
|
>
|
|
103
195
|
|
|
104
|
-
await buzzk.channel.
|
|
196
|
+
await buzzk.channel.unFollow("channelID 값");
|
|
105
197
|
|
|
106
198
|
---
|
|
107
199
|
|
|
108
|
-
|
|
200
|
+
### live
|
|
109
201
|
|
|
110
|
-
const lvDetail = await buzzk.live.
|
|
202
|
+
const lvDetail = await buzzk.live.getDetail("channelID 값");
|
|
111
203
|
console.log(lvDetail);
|
|
112
204
|
|
|
113
205
|
<details>
|
|
114
|
-
<summary>
|
|
206
|
+
<summary>return</summary>
|
|
115
207
|
|
|
116
208
|
- Return
|
|
117
209
|
- channelID
|
|
118
210
|
- channel
|
|
211
|
+
- name
|
|
212
|
+
- imageURL
|
|
119
213
|
- chatID
|
|
120
214
|
- chatLimit //팔로워 전용 채팅 등...
|
|
121
215
|
- userCount
|
|
@@ -129,11 +223,11 @@ dotenv와 함께 사용하는 것을 매우 권장합니다.
|
|
|
129
223
|
|
|
130
224
|
</details>
|
|
131
225
|
|
|
132
|
-
const lvStatus = await buzzk.live.
|
|
226
|
+
const lvStatus = await buzzk.live.getStatus("channelID 값");
|
|
133
227
|
console.log(lvStatus);
|
|
134
228
|
|
|
135
229
|
<details>
|
|
136
|
-
<summary>
|
|
230
|
+
<summary>return</summary>
|
|
137
231
|
|
|
138
232
|
- Return
|
|
139
233
|
- channelID
|
|
@@ -149,7 +243,7 @@ dotenv와 함께 사용하는 것을 매우 권장합니다.
|
|
|
149
243
|
|
|
150
244
|
---
|
|
151
245
|
|
|
152
|
-
|
|
246
|
+
### chat
|
|
153
247
|
|
|
154
248
|
const buzzkChat = buzzk.chat;
|
|
155
249
|
let chat = new buzzkChat("channelID 값");
|
|
@@ -161,7 +255,7 @@ dotenv와 함께 사용하는 것을 매우 권장합니다.
|
|
|
161
255
|
console.log(recentChat);
|
|
162
256
|
|
|
163
257
|
<details>
|
|
164
|
-
<summary>
|
|
258
|
+
<summary>return</summary>
|
|
165
259
|
|
|
166
260
|
- Return
|
|
167
261
|
- 0
|
|
@@ -187,7 +281,7 @@ dotenv와 함께 사용하는 것을 매우 권장합니다.
|
|
|
187
281
|
});
|
|
188
282
|
|
|
189
283
|
<details>
|
|
190
|
-
<summary>
|
|
284
|
+
<summary>callback</summary>
|
|
191
285
|
|
|
192
286
|
- Return
|
|
193
287
|
- 0
|
package/lib/channel.js
CHANGED
|
@@ -22,14 +22,14 @@ class chzzkChannel {
|
|
|
22
22
|
* @property {string} description
|
|
23
23
|
* @property {string} follower
|
|
24
24
|
* @property {string} imageURL
|
|
25
|
-
* @property {
|
|
25
|
+
* @property {boolean} isLive
|
|
26
26
|
*/
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* @param {string} keyword
|
|
30
30
|
* @returns {Promise<chzzkChannels>}
|
|
31
31
|
*/
|
|
32
|
-
async function
|
|
32
|
+
async function search (keyword) {
|
|
33
33
|
return new Promise(async (resolve, reject) => {
|
|
34
34
|
|
|
35
35
|
let chSearch = await reqChzzk("service/v1/search/channels?keyword=" + keyword + "&offset=0&size=13&withFirstChannelContent=false");
|
|
@@ -50,11 +50,30 @@ async function getChannel (keyword) {
|
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* @param {string} channelID
|
|
56
|
+
* @returns {Promise<chzzkChannel>}
|
|
57
|
+
*/
|
|
58
|
+
async function get (channelID) {
|
|
59
|
+
return new Promise(async (resolve, reject) => {
|
|
60
|
+
|
|
61
|
+
let chGet = await reqChzzk("service/v1/channels/" + channelID);
|
|
62
|
+
if (chGet.code != 200) return resolve(null);
|
|
63
|
+
chGet = chGet.content;
|
|
64
|
+
|
|
65
|
+
let chRes = new chzzkChannel(chGet.channelId, chGet.channelName, chGet.channelDescription, chGet.followerCount, chGet.channelImageUrl, chGet.openLive);
|
|
66
|
+
|
|
67
|
+
return resolve(chRes);
|
|
68
|
+
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
53
72
|
/**
|
|
54
73
|
* @param {string} channelID
|
|
55
74
|
* @returns {Promise<boolean>}
|
|
56
75
|
*/
|
|
57
|
-
async function
|
|
76
|
+
async function follow (channelID) {
|
|
58
77
|
return new Promise(async (resolve, reject) => {
|
|
59
78
|
|
|
60
79
|
let flRes = await exChzzk("POST", "service/v1/channels/" + channelID + "/follow");
|
|
@@ -68,7 +87,7 @@ async function followChannel (channelID) {
|
|
|
68
87
|
* @param {string} channelID
|
|
69
88
|
* @returns {Promise<boolean>}
|
|
70
89
|
*/
|
|
71
|
-
async function
|
|
90
|
+
async function unFollow (channelID) {
|
|
72
91
|
return new Promise(async (resolve, reject) => {
|
|
73
92
|
|
|
74
93
|
let flRes = await exChzzk("DELETE", "service/v1/channels/" + channelID + "/follow");
|
|
@@ -79,7 +98,8 @@ async function unFollowChannel (channelID) {
|
|
|
79
98
|
}
|
|
80
99
|
|
|
81
100
|
module.exports = {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
101
|
+
search: search,
|
|
102
|
+
get: get,
|
|
103
|
+
follow: follow,
|
|
104
|
+
unFollow: unFollow
|
|
85
105
|
}
|
package/lib/chat.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const {
|
|
1
|
+
const { getStatus } = require("./live.js");
|
|
2
2
|
const { reqGame } = require("./tool.js");
|
|
3
3
|
|
|
4
4
|
const { WebSocket } = require("ws");
|
|
@@ -27,7 +27,7 @@ class chzzkChat {
|
|
|
27
27
|
if (this.#ws) return resolve(null);
|
|
28
28
|
|
|
29
29
|
//Get ChatID
|
|
30
|
-
let cidRes = await
|
|
30
|
+
let cidRes = await getStatus(this.channelID);
|
|
31
31
|
this.#chatID = cidRes.chatID;
|
|
32
32
|
//Get ChatID
|
|
33
33
|
|
|
@@ -271,7 +271,7 @@ class chzzkChat {
|
|
|
271
271
|
this.#pollingStatus = true;
|
|
272
272
|
|
|
273
273
|
//Get ChatID
|
|
274
|
-
let cidRes = await
|
|
274
|
+
let cidRes = await getStatus(this.channelID);
|
|
275
275
|
this.#chatID = cidRes.chatID;
|
|
276
276
|
//Get ChatID
|
|
277
277
|
|
package/lib/live.js
CHANGED
|
@@ -3,7 +3,7 @@ const { reqChzzk } = require("./tool.js");
|
|
|
3
3
|
/**
|
|
4
4
|
* @typedef {Object} chzzkLiveDetail
|
|
5
5
|
* @property {string} channelID
|
|
6
|
-
* @property {
|
|
6
|
+
* @property {channelInfo} channel
|
|
7
7
|
* @property {string} chatID
|
|
8
8
|
* @property {string} chatLimit
|
|
9
9
|
* @property {userCount} userCount
|
|
@@ -15,6 +15,12 @@ const { reqChzzk } = require("./tool.js");
|
|
|
15
15
|
*
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* @typedef {Object} channelInfo
|
|
20
|
+
* @property {string} name
|
|
21
|
+
* @property {string} imageURL
|
|
22
|
+
*/
|
|
23
|
+
|
|
18
24
|
/**
|
|
19
25
|
* @typedef {Object} userCount
|
|
20
26
|
* @property {number} now
|
|
@@ -25,7 +31,7 @@ const { reqChzzk } = require("./tool.js");
|
|
|
25
31
|
* @param {string} channelID
|
|
26
32
|
* @returns {Promise<chzzkLiveDetail>}
|
|
27
33
|
*/
|
|
28
|
-
async function
|
|
34
|
+
async function getDetail (channelID) {
|
|
29
35
|
return new Promise(async (resolve, reject) => {
|
|
30
36
|
|
|
31
37
|
let res = await reqChzzk("service/v2/channels/" + channelID + "/live-detail");
|
|
@@ -34,7 +40,7 @@ async function getLiveDetail (channelID) {
|
|
|
34
40
|
|
|
35
41
|
let lvDetail = {
|
|
36
42
|
channelID: res.channel.channelId,
|
|
37
|
-
channel: res.channel,
|
|
43
|
+
channel: { name: res.channel.channelName, imageURL: res.channel.channelImageUrl },
|
|
38
44
|
chatID: res.chatChannelId,
|
|
39
45
|
chatLimit: res.chatAvailableGroup,
|
|
40
46
|
userCount: { now: res.concurrentUserCount, total: res.accumulateCount },
|
|
@@ -65,7 +71,7 @@ async function getLiveDetail (channelID) {
|
|
|
65
71
|
* @param {string} channelID
|
|
66
72
|
* @returns {Promise<chzzkLiveStatus>}
|
|
67
73
|
*/
|
|
68
|
-
async function
|
|
74
|
+
async function getStatus (channelID) {
|
|
69
75
|
return new Promise(async (resolve, reject) => {
|
|
70
76
|
|
|
71
77
|
let res = await reqChzzk("polling/v2/channels/" + channelID + "/live-status");
|
|
@@ -87,6 +93,6 @@ async function getLiveStatus (channelID) {
|
|
|
87
93
|
}
|
|
88
94
|
|
|
89
95
|
module.exports = {
|
|
90
|
-
|
|
91
|
-
|
|
96
|
+
getDetail: getDetail,
|
|
97
|
+
getStatus: getStatus
|
|
92
98
|
}
|
package/lib/val.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "buzzk",
|
|
3
3
|
"displayName": "BUZZK",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.3.0",
|
|
5
5
|
"description": "뿌지직 (BUZZK) - 치지직(CHZZK) 챗봇을 더욱 쉽게 개발할 수 있도록 돕는 비공식 라이브러리.",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"type": "commonjs",
|
|
@@ -24,5 +24,13 @@
|
|
|
24
24
|
"url": "https://github.com/Emin-G/buzzk/issues"
|
|
25
25
|
},
|
|
26
26
|
"homepage": "https://github.com/Emin-G/buzzk",
|
|
27
|
-
"keywords": [
|
|
27
|
+
"keywords": [
|
|
28
|
+
"chzzk",
|
|
29
|
+
"buzzk",
|
|
30
|
+
"치지직",
|
|
31
|
+
"뿌지직"
|
|
32
|
+
],
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"ws": "^8.16.0"
|
|
35
|
+
}
|
|
28
36
|
}
|