@alemonjs/kook 0.2.7 → 2.1.0-alpha.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.
Files changed (32) hide show
  1. package/lib/config.js +20 -0
  2. package/lib/desktop.d.ts +2 -2
  3. package/lib/desktop.js +54 -55
  4. package/lib/hook.d.ts +38 -0
  5. package/lib/hook.js +24 -0
  6. package/lib/index.d.ts +6 -7
  7. package/lib/index.js +314 -274
  8. package/lib/sdk/api.d.ts +275 -0
  9. package/lib/sdk/{platform/kook/sdk/api.js → api.js} +25 -26
  10. package/lib/sdk/{platform/kook/sdk/config.js → config.js} +1 -1
  11. package/lib/sdk/{platform/kook/sdk/message.js → message.js} +1 -4
  12. package/lib/sdk/typings.d.ts +109 -0
  13. package/package.json +2 -2
  14. package/dist/assets/index.css +0 -1
  15. package/dist/assets/index.js +0 -49
  16. package/dist/index.html +0 -15
  17. package/lib/sdk/core/utils/from.js +0 -42
  18. package/lib/sdk/platform/kook/sdk/api.d.ts +0 -288
  19. package/lib/sdk/platform/kook/sdk/message/INTERACTION.d.ts +0 -8
  20. package/lib/sdk/platform/kook/sdk/message/MEMBER_ADD.d.ts +0 -10
  21. package/lib/sdk/platform/kook/sdk/message/MEMBER_REMOVE.d.ts +0 -10
  22. package/lib/sdk/platform/kook/sdk/message/MESSAGES_DIRECT.d.ts +0 -10
  23. package/lib/sdk/platform/kook/sdk/message/MESSAGES_PUBLIC.d.ts +0 -10
  24. package/lib/sdk/platform/kook/sdk/message/REACTIONS.d.ts +0 -10
  25. package/lib/sdk/platform/kook/sdk/message.d.ts +0 -18
  26. package/lib/sdk/platform/kook/sdk/typings.d.ts +0 -221
  27. package/lib/sdk/platform/kook/sdk/wss.d.ts +0 -26
  28. package/lib/sdk/platform/kook/sdk/wss.types.d.ts +0 -12
  29. /package/lib/{sdk/core → core}/config.js +0 -0
  30. /package/lib/sdk/{platform/kook/sdk/conversation.js → conversation.js} +0 -0
  31. /package/lib/sdk/{platform/kook/sdk/typings.js → typings.js} +0 -0
  32. /package/lib/sdk/{platform/kook/sdk/wss.js → wss.js} +0 -0
@@ -1,288 +0,0 @@
1
- import * as axios from 'axios'
2
- import { AxiosRequestConfig } from 'axios'
3
- import { Readable } from 'stream'
4
- import { SendMessageParams, SendDirectMessageParams } from './typings.js'
5
-
6
- /**
7
- * api接口
8
- */
9
- declare class KOOKAPI {
10
- API_URL: string
11
- /**
12
- * KOOK服务
13
- * @param config
14
- * @returns
15
- */
16
- kookService(opstoin: AxiosRequestConfig): Promise<axios.AxiosResponse<any, any>>
17
- /**
18
- *
19
- * @returns
20
- */
21
- gateway(): Promise<any>
22
- /**
23
- * ************
24
- * 资源床单
25
- * ***********
26
- */
27
- /**
28
- * 发送buffer资源
29
- * @param id 私信传频道id,公信传子频道id
30
- * @param message {消息编号,图片,内容}
31
- * @returns
32
- */
33
- postImage(
34
- file: string | Buffer | Readable,
35
- Name?: string
36
- ): Promise<
37
- | false
38
- | {
39
- data: {
40
- url: string
41
- }
42
- }
43
- >
44
- /**
45
- * 发送buffer资源
46
- * @param id 私信传频道id,公信传子频道id
47
- * @param message {消息编号,图片,内容}
48
- * @returns
49
- */
50
- postFile(
51
- file: Buffer,
52
- Name?: string
53
- ): Promise<
54
- | false
55
- | {
56
- data: {
57
- url: string
58
- }
59
- }
60
- >
61
- /**
62
- * 转存
63
- * @param formdata
64
- * @returns
65
- */
66
- createUrl(formdata: any): Promise<{
67
- data: {
68
- url: string
69
- }
70
- }>
71
- /**
72
- * *********
73
- * 消息api
74
- * *********
75
- */
76
- /**
77
- * 创建消息
78
- * @param data
79
- * @returns
80
- */
81
- createMessage(data: SendMessageParams): Promise<{
82
- data: {
83
- msg_id: string
84
- msg_timestamp: number
85
- nonce: string
86
- }
87
- }>
88
- /**
89
- * 创建私聊消息
90
- */
91
- /**
92
- * 创建消息
93
- * @param target_id
94
- * @returns
95
- */
96
- userChatCreate(target_id: string): Promise<{
97
- data: {
98
- code: string
99
- last_read_time: number
100
- latest_msg_time: number
101
- unread_count: number
102
- is_friend: boolean
103
- is_blocked: boolean
104
- is_target_blocked: boolean
105
- target_info: {
106
- id: string
107
- username: string
108
- online: boolean
109
- avatar: string
110
- }
111
- }
112
- }>
113
- /**
114
- * 创建消息
115
- * @param data
116
- * @returns
117
- */
118
- createDirectMessage(data: SendDirectMessageParams): Promise<{
119
- data: {
120
- msg_id: string
121
- msg_timestamp: number
122
- nonce: string
123
- }
124
- }>
125
- /**
126
- * 删除指定消息
127
- * @param msg_id
128
- * @returns
129
- */
130
- messageDelete(msg_id: string): Promise<{
131
- data: {
132
- code: number
133
- message: string
134
- data: any[]
135
- }
136
- }>
137
- /**
138
- * 重编辑指定消息
139
- * @param data
140
- * @returns
141
- */
142
- messageUpdate(data: {
143
- msg_id: string
144
- content: any
145
- quote?: string
146
- temp_target_id?: string
147
- }): Promise<{
148
- data: {
149
- code: number
150
- message: string
151
- data: any[]
152
- }
153
- }>
154
- /**
155
- * 删回应
156
- * @param data
157
- * @returns
158
- */
159
- messageDeleteReaction(data: { msg_id: string; emoji: string; user_id: string }): Promise<{
160
- code: number
161
- message: string
162
- data: any[]
163
- }>
164
- /**
165
- * 发回应
166
- * @param data
167
- * @returns
168
- */
169
- messageAddReaction(data: { msg_id: string; emoji: string }): Promise<{
170
- code: number
171
- message: string
172
- data: any[]
173
- }>
174
- /**
175
- * 某个回应的所有用户
176
- * @param data
177
- * @returns
178
- */
179
- messageReactionList(params: { msg_id: string; emoji: string }): Promise<{
180
- code: number
181
- message: string
182
- data: {
183
- id: string
184
- username: string
185
- identify_num: string
186
- online: boolean
187
- status: number
188
- avatar: string
189
- bot: boolean
190
- tag_info: {
191
- color: string
192
- text: string
193
- }
194
- nickname: string
195
- reaction_time: number
196
- }
197
- }>
198
- /**
199
- * **********
200
- * user
201
- * *********
202
- */
203
- /**
204
- * 得到当前信息
205
- * @param guild_id
206
- * @param user_id
207
- * @returns
208
- */
209
- userMe(): Promise<{
210
- code: number
211
- message: string
212
- data: {
213
- id: string
214
- username: string
215
- identify_num: string
216
- online: false
217
- os: string
218
- status: number
219
- avatar: string
220
- banner: string
221
- bot: true
222
- mobile_verified: true
223
- client_id: string
224
- mobile_prefix: string
225
- mobile: string
226
- invited_count: number
227
- }
228
- }>
229
- /**
230
- * 得到用户信息
231
- * @param guild_id
232
- * @param user_id
233
- * @returns
234
- */
235
- userView(
236
- guild_id: string,
237
- user_id: string
238
- ): Promise<{
239
- code: number
240
- message: string
241
- data: {
242
- id: string
243
- username: string
244
- identify_num: string
245
- online: false
246
- status: 0
247
- bot: true
248
- avatar: string
249
- vip_avatar: string
250
- mobile_verified: true
251
- roles: number[]
252
- joined_at: number
253
- active_time: number
254
- }
255
- }>
256
- /**
257
- * 踢出
258
- * @param guild_id
259
- * @param user_id
260
- * @returns
261
- */
262
- guildKickout(
263
- guild_id: string,
264
- user_id: string
265
- ): Promise<{
266
- code: number
267
- message: string
268
- data: any
269
- }>
270
- /**
271
- * 创建角色
272
- * @param channel_id
273
- * @param type
274
- * @param value
275
- * @returns
276
- */
277
- channelRoleCreate(
278
- channel_id: string,
279
- type: string,
280
- value: string
281
- ): Promise<{
282
- code: number
283
- message: string
284
- data: any
285
- }>
286
- }
287
-
288
- export { KOOKAPI }
@@ -1,8 +0,0 @@
1
- import { SystemData } from '../typings.js'
2
-
3
- /**
4
- * @param event 按钮数据
5
- */
6
- type INTERACTION_TYPE = SystemData
7
-
8
- export type { INTERACTION_TYPE }
@@ -1,10 +0,0 @@
1
- import { SystemData } from '../typings.js'
2
-
3
- /**
4
- * 当成员加入时
5
- * @param event
6
- * @returns
7
- */
8
- type MEMBER_ADD_TYPE = SystemData
9
-
10
- export type { MEMBER_ADD_TYPE }
@@ -1,10 +0,0 @@
1
- import { SystemData } from '../typings.js'
2
-
3
- /**
4
- * 当成员移除时
5
- * @param event
6
- * @returns
7
- */
8
- type MEMBER_REMOVE_TYPE = SystemData
9
-
10
- export type { MEMBER_REMOVE_TYPE }
@@ -1,10 +0,0 @@
1
- import { EventData } from '../typings.js'
2
-
3
- /**
4
- * 私聊消息
5
- * @param event
6
- * @returns
7
- */
8
- type MESSAGES_DIRECT_TYPE = EventData
9
-
10
- export type { MESSAGES_DIRECT_TYPE }
@@ -1,10 +0,0 @@
1
- import { EventData } from '../typings.js'
2
-
3
- /**
4
- * 群聊消息
5
- * @param event
6
- * @returns
7
- */
8
- type MESSAGES_PUBLIC_TYPE = EventData
9
-
10
- export type { MESSAGES_PUBLIC_TYPE }
@@ -1,10 +0,0 @@
1
- import { SystemData } from '../typings.js'
2
-
3
- /**
4
- *
5
- * @param event
6
- * @returns
7
- */
8
- type REACTIONS_TYPE = SystemData
9
-
10
- export type { REACTIONS_TYPE }
@@ -1,18 +0,0 @@
1
- import { MEMBER_ADD_TYPE } from './message/MEMBER_ADD.js'
2
- import { MEMBER_REMOVE_TYPE } from './message/MEMBER_REMOVE.js'
3
- import { INTERACTION_TYPE } from './message/INTERACTION.js'
4
- import { MESSAGES_DIRECT_TYPE } from './message/MESSAGES_DIRECT.js'
5
- import { MESSAGES_PUBLIC_TYPE } from './message/MESSAGES_PUBLIC.js'
6
- import { REACTIONS_TYPE } from './message/REACTIONS.js'
7
-
8
- type KOOKEventMap = {
9
- MEMBER_ADD: MEMBER_ADD_TYPE
10
- MEMBER_REMOVE: MEMBER_REMOVE_TYPE
11
- INTERACTION: INTERACTION_TYPE
12
- MESSAGES_DIRECT: MESSAGES_DIRECT_TYPE
13
- MESSAGES_PUBLIC: MESSAGES_PUBLIC_TYPE
14
- REACTIONS: REACTIONS_TYPE
15
- ERROR: any
16
- }
17
-
18
- export type { KOOKEventMap }
@@ -1,221 +0,0 @@
1
- type MessageType = 1 | 2 | 3 | 4 | 8 | 9 | 10 | 255
2
- /**
3
- * 消息通道类型, GROUP 为组播消息, PERSON 为单播消息, BROADCAST 为广播消息
4
- */
5
- type MessageChannelType = 'GROUP' | 'PERSON' | 'BROADCAST'
6
- /**
7
- * 会话数据
8
- */
9
- interface EventData {
10
- channel_type: MessageChannelType
11
- type: MessageType
12
- target_id: string
13
- author_id: string
14
- content: string
15
- extra: Extra
16
- msg_id: string
17
- msg_timestamp: number
18
- nonce: string
19
- from_type: number
20
- }
21
- /**
22
- * 消息发送参数
23
- */
24
- interface SendMessageParams {
25
- /**
26
- * 消息类型
27
- */
28
- type?: number
29
- /**
30
- * 频道编号
31
- */
32
- target_id: string
33
- /**
34
- * 消息内容
35
- */
36
- content: string
37
- /**
38
- * 引用--消息id
39
- */
40
- quote?: string
41
- nonce?: string
42
- temp_target_id?: string
43
- }
44
- /**
45
- * 作者信息
46
- */
47
- interface Author {
48
- id: string
49
- username: string
50
- identify_num: string
51
- online: boolean
52
- os: string
53
- status: number
54
- avatar: string
55
- vip_avatar: string
56
- banner: string
57
- nickname: string
58
- roles: string[]
59
- is_vip: boolean
60
- vip_amp: boolean
61
- is_ai_reduce_noise: boolean
62
- is_personal_card_bg: boolean
63
- bot: boolean
64
- decorations_id_map: null | unknown
65
- is_sys: boolean
66
- }
67
- /**
68
- * mk接口
69
- */
70
- interface KMarkdown {
71
- raw_content: string
72
- mention_part: any[]
73
- mention_role_part: any[]
74
- channel_part: any[]
75
- }
76
- /**
77
- * 数据包
78
- */
79
- interface Extra {
80
- type: number
81
- code: string
82
- guild_id: string
83
- guild_type: number
84
- channel_name: string
85
- author: Author
86
- visible_only: null
87
- mention: any[]
88
- mention_all: boolean
89
- mention_roles: any[]
90
- mention_here: boolean
91
- nav_channels: any[]
92
- kmarkdown: KMarkdown
93
- emoji: any[]
94
- last_msg_content: string
95
- send_msg_device: number
96
- }
97
- /**
98
- * 私聊消息
99
- */
100
- interface SendDirectMessageParams {
101
- type?: MessageType
102
- target_id?: string
103
- chat_code?: string
104
- content: string
105
- quote?: string
106
- nonce?: string
107
- }
108
- /**
109
- * 系统数据
110
- */
111
- interface SystemData {
112
- channel_type: MessageChannelType
113
- type: number
114
- target_id: string
115
- author_id: string
116
- content: string
117
- extra: {
118
- type: (typeof SystemDataEnum)[number]
119
- body: overheadData | memberData | ChannelData | StatementData | EditingData | OnLineData
120
- }
121
- msg_id: string
122
- msg_timestamp: number
123
- nonce: string
124
- from_type: number
125
- }
126
- interface OnLineData {
127
- user_id: string
128
- event_time: number
129
- guilds: any[]
130
- }
131
- interface overheadData {
132
- channel_id: string
133
- operator_id: string
134
- msg_id: string
135
- }
136
- interface memberData {
137
- user_id: string
138
- exited_at: number
139
- }
140
- interface ChannelData {
141
- id: string
142
- name: string
143
- user_id: string
144
- guild_id: string
145
- guild_type: number
146
- limit_amount: number
147
- is_category: number
148
- parent_id: string
149
- level: number
150
- slow_mode: number
151
- topic: string
152
- type: number
153
- permission_overwrites: any[]
154
- permission_users: any[]
155
- permission_sync: number
156
- mode: number
157
- has_password: boolean
158
- last_msg_content: string
159
- last_msg_id: string
160
- sync_guild_region: number
161
- region: string
162
- joined_at: number
163
- }
164
- interface StatementData {
165
- channel_id: string
166
- emoji: {
167
- [key: string]: any
168
- }
169
- user_id: string
170
- msg_id: string
171
- }
172
- interface EditingData {
173
- version_id: string
174
- channel_id: string
175
- target_id: string
176
- content: string
177
- mention: string[]
178
- mention_all: boolean
179
- mention_here: boolean
180
- mention_roles: string[]
181
- updated_at: number
182
- kmarkdown: any
183
- last_msg_content: string
184
- embeds: any[]
185
- msg_id: string
186
- }
187
- /**
188
- * 系统数据可枚举
189
- */
190
- declare const SystemDataEnum: readonly [
191
- 'exited_guild',
192
- 'joined_guild',
193
- 'joined_channel',
194
- 'exited_channel',
195
- 'updated_channel',
196
- 'pinned_message',
197
- 'guild_member_online',
198
- 'added_reaction',
199
- 'deleted_reaction',
200
- 'updated_message',
201
- 'message_btn_click'
202
- ]
203
-
204
- export {
205
- type Author,
206
- type ChannelData,
207
- type EditingData,
208
- type EventData,
209
- type Extra,
210
- type KMarkdown,
211
- type MessageChannelType,
212
- type MessageType,
213
- type OnLineData,
214
- type SendDirectMessageParams,
215
- type SendMessageParams,
216
- type StatementData,
217
- type SystemData,
218
- SystemDataEnum,
219
- type memberData,
220
- type overheadData
221
- }
@@ -1,26 +0,0 @@
1
- import { KOOKOptions } from './wss.types.js'
2
- import { KOOKAPI } from './api.js'
3
- import { KOOKEventMap } from './message.js'
4
-
5
- declare class KOOKClient extends KOOKAPI {
6
- #private
7
- /**
8
- *
9
- * @param opstion
10
- */
11
- constructor(opstion: KOOKOptions)
12
- /**
13
- * 注册事件处理程序
14
- * @param key 事件名称
15
- * @param val 事件处理函数
16
- */
17
- on<T extends keyof KOOKEventMap>(key: T, val: (event: KOOKEventMap[T]) => any): this
18
- /**
19
- * 使用获取到的网关连接地址建立 WebSocket 连接
20
- * @param token
21
- * @param conversation
22
- */
23
- connect(): Promise<void>
24
- }
25
-
26
- export { KOOKClient }
@@ -1,12 +0,0 @@
1
- /**
2
- * ****
3
- * ***
4
- */
5
- interface KOOKOptions {
6
- /**
7
- * 钥匙
8
- */
9
- token: string
10
- }
11
-
12
- export type { KOOKOptions }
File without changes
File without changes