@alemonjs/kook 0.2.3 → 0.2.5
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/dist/assets/index.css +1 -0
- package/dist/assets/index.js +49 -0
- package/dist/index.html +15 -0
- package/lib/desktop.d.ts +3 -0
- package/lib/desktop.js +59 -0
- package/lib/index.d.ts +9 -0
- package/lib/index.js +5 -1
- package/lib/sdk/platform/kook/sdk/api.d.ts +276 -0
- package/lib/sdk/platform/kook/sdk/message/INTERACTION.d.ts +8 -0
- package/lib/sdk/platform/kook/sdk/message/MEMBER_ADD.d.ts +10 -0
- package/lib/sdk/platform/kook/sdk/message/MEMBER_REMOVE.d.ts +10 -0
- package/lib/sdk/platform/kook/sdk/message/MESSAGES_DIRECT.d.ts +10 -0
- package/lib/sdk/platform/kook/sdk/message/MESSAGES_PUBLIC.d.ts +10 -0
- package/lib/sdk/platform/kook/sdk/message/REACTIONS.d.ts +10 -0
- package/lib/sdk/platform/kook/sdk/message.d.ts +18 -0
- package/lib/sdk/platform/kook/sdk/typings.d.ts +192 -0
- package/lib/sdk/platform/kook/sdk/wss.d.ts +26 -0
- package/lib/sdk/platform/kook/sdk/wss.types.d.ts +12 -0
- package/package.json +25 -9
package/lib/desktop.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { readFileSync } from 'fs';
|
|
2
|
+
import { dirname, join } from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
import { getConfig, getConfigValue } from 'alemonjs';
|
|
5
|
+
|
|
6
|
+
// 当前目录
|
|
7
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
// 被激活的时候。
|
|
9
|
+
const activate = context => {
|
|
10
|
+
// 创建一个 webview。
|
|
11
|
+
const webView = context.createSidebarWebView(context);
|
|
12
|
+
// 当命令被触发的时候。
|
|
13
|
+
context.onCommand('open.kook', () => {
|
|
14
|
+
const dir = join(__dirname, '../', 'dist', 'index.html');
|
|
15
|
+
const scriptReg = /<script.*?src="(.+?)".*?>/;
|
|
16
|
+
const styleReg = /<link.*?href="(.+?)".*?>/;
|
|
17
|
+
// 创建 webview 路径
|
|
18
|
+
const styleUri = context.createExtensionDir(join(__dirname, '../', 'dist', 'assets', 'index.css'));
|
|
19
|
+
const scriptUri = context.createExtensionDir(join(__dirname, '../', 'dist', 'assets', 'index.js'));
|
|
20
|
+
// 确保路径存在
|
|
21
|
+
const html = readFileSync(dir, 'utf-8')
|
|
22
|
+
.replace(scriptReg, `<script type="module" crossorigin src="${scriptUri}"></script>`)
|
|
23
|
+
.replace(styleReg, `<link rel="stylesheet" crossorigin href="${styleUri}">`);
|
|
24
|
+
// 立即渲染 webview
|
|
25
|
+
webView.loadWebView(html);
|
|
26
|
+
});
|
|
27
|
+
// 监听 webview 的消息。
|
|
28
|
+
webView.onMessage(data => {
|
|
29
|
+
try {
|
|
30
|
+
if (data.type === 'kook.form.save') {
|
|
31
|
+
const CIG = data.data;
|
|
32
|
+
const config = getConfig();
|
|
33
|
+
const value = config.value ?? {};
|
|
34
|
+
value['kook'] = {
|
|
35
|
+
token: CIG.token ?? '',
|
|
36
|
+
// master_key 12121,1313,1313,13 转为数组
|
|
37
|
+
master_key: CIG.master_key.split(',')
|
|
38
|
+
};
|
|
39
|
+
config.saveValue(value);
|
|
40
|
+
context.notification('KOOK 配置保存成功~');
|
|
41
|
+
}
|
|
42
|
+
else if (data.type === 'kook.init') {
|
|
43
|
+
let config = getConfigValue();
|
|
44
|
+
if (!config)
|
|
45
|
+
config = {};
|
|
46
|
+
// 发送消息
|
|
47
|
+
webView.postMessage({
|
|
48
|
+
type: 'kook.init',
|
|
49
|
+
data: config.qq_bot ?? {}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
catch (e) {
|
|
54
|
+
console.error(e);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export { activate };
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as alemonjs from 'alemonjs';
|
|
2
|
+
import { KOOKClient } from './sdk/platform/kook/sdk/wss.js';
|
|
3
|
+
|
|
4
|
+
type Client = typeof KOOKClient.prototype;
|
|
5
|
+
declare const platform = "kook";
|
|
6
|
+
declare const client: Client;
|
|
7
|
+
declare const _default: () => alemonjs.ClientAPI;
|
|
8
|
+
|
|
9
|
+
export { type Client, client, _default as default, platform };
|
package/lib/index.js
CHANGED
|
@@ -22,7 +22,9 @@ const client = new Proxy({}, {
|
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
24
|
var index = defineBot(() => {
|
|
25
|
-
|
|
25
|
+
let value = getConfigValue();
|
|
26
|
+
if (!value)
|
|
27
|
+
value = {};
|
|
26
28
|
const config = value[platform];
|
|
27
29
|
// 创建客户端
|
|
28
30
|
const client = new KOOKClient({
|
|
@@ -62,6 +64,7 @@ var index = defineBot(() => {
|
|
|
62
64
|
});
|
|
63
65
|
// 定义消
|
|
64
66
|
const e = {
|
|
67
|
+
name: 'private.message.create',
|
|
65
68
|
// 事件类型
|
|
66
69
|
Platform: platform,
|
|
67
70
|
// 用户Id
|
|
@@ -139,6 +142,7 @@ var index = defineBot(() => {
|
|
|
139
142
|
});
|
|
140
143
|
// 定义消
|
|
141
144
|
const e = {
|
|
145
|
+
name: 'message.create',
|
|
142
146
|
// 事件类型
|
|
143
147
|
Platform: platform,
|
|
144
148
|
//
|
|
@@ -0,0 +1,276 @@
|
|
|
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(file: string | Buffer | Readable, Name?: string): Promise<false | {
|
|
34
|
+
data: {
|
|
35
|
+
url: string;
|
|
36
|
+
};
|
|
37
|
+
}>;
|
|
38
|
+
/**
|
|
39
|
+
* 发送buffer资源
|
|
40
|
+
* @param id 私信传频道id,公信传子频道id
|
|
41
|
+
* @param message {消息编号,图片,内容}
|
|
42
|
+
* @returns
|
|
43
|
+
*/
|
|
44
|
+
postFile(file: Buffer, Name?: string): Promise<false | {
|
|
45
|
+
data: {
|
|
46
|
+
url: string;
|
|
47
|
+
};
|
|
48
|
+
}>;
|
|
49
|
+
/**
|
|
50
|
+
* 转存
|
|
51
|
+
* @param formdata
|
|
52
|
+
* @returns
|
|
53
|
+
*/
|
|
54
|
+
createUrl(formdata: any): Promise<{
|
|
55
|
+
data: {
|
|
56
|
+
url: string;
|
|
57
|
+
};
|
|
58
|
+
}>;
|
|
59
|
+
/**
|
|
60
|
+
* *********
|
|
61
|
+
* 消息api
|
|
62
|
+
* *********
|
|
63
|
+
*/
|
|
64
|
+
/**
|
|
65
|
+
* 创建消息
|
|
66
|
+
* @param data
|
|
67
|
+
* @returns
|
|
68
|
+
*/
|
|
69
|
+
createMessage(data: SendMessageParams): Promise<{
|
|
70
|
+
data: {
|
|
71
|
+
msg_id: string;
|
|
72
|
+
msg_timestamp: number;
|
|
73
|
+
nonce: string;
|
|
74
|
+
};
|
|
75
|
+
}>;
|
|
76
|
+
/**
|
|
77
|
+
* 创建私聊消息
|
|
78
|
+
*/
|
|
79
|
+
/**
|
|
80
|
+
* 创建消息
|
|
81
|
+
* @param target_id
|
|
82
|
+
* @returns
|
|
83
|
+
*/
|
|
84
|
+
userChatCreate(target_id: string): Promise<{
|
|
85
|
+
data: {
|
|
86
|
+
code: string;
|
|
87
|
+
last_read_time: number;
|
|
88
|
+
latest_msg_time: number;
|
|
89
|
+
unread_count: number;
|
|
90
|
+
is_friend: boolean;
|
|
91
|
+
is_blocked: boolean;
|
|
92
|
+
is_target_blocked: boolean;
|
|
93
|
+
target_info: {
|
|
94
|
+
id: string;
|
|
95
|
+
username: string;
|
|
96
|
+
online: boolean;
|
|
97
|
+
avatar: string;
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
}>;
|
|
101
|
+
/**
|
|
102
|
+
* 创建消息
|
|
103
|
+
* @param data
|
|
104
|
+
* @returns
|
|
105
|
+
*/
|
|
106
|
+
createDirectMessage(data: SendDirectMessageParams): Promise<{
|
|
107
|
+
data: {
|
|
108
|
+
msg_id: string;
|
|
109
|
+
msg_timestamp: number;
|
|
110
|
+
nonce: string;
|
|
111
|
+
};
|
|
112
|
+
}>;
|
|
113
|
+
/**
|
|
114
|
+
* 删除指定消息
|
|
115
|
+
* @param msg_id
|
|
116
|
+
* @returns
|
|
117
|
+
*/
|
|
118
|
+
messageDelete(msg_id: string): Promise<{
|
|
119
|
+
data: {
|
|
120
|
+
code: number;
|
|
121
|
+
message: string;
|
|
122
|
+
data: any[];
|
|
123
|
+
};
|
|
124
|
+
}>;
|
|
125
|
+
/**
|
|
126
|
+
* 重编辑指定消息
|
|
127
|
+
* @param data
|
|
128
|
+
* @returns
|
|
129
|
+
*/
|
|
130
|
+
messageUpdate(data: {
|
|
131
|
+
msg_id: string;
|
|
132
|
+
content: any;
|
|
133
|
+
quote?: string;
|
|
134
|
+
temp_target_id?: string;
|
|
135
|
+
}): Promise<{
|
|
136
|
+
data: {
|
|
137
|
+
code: number;
|
|
138
|
+
message: string;
|
|
139
|
+
data: any[];
|
|
140
|
+
};
|
|
141
|
+
}>;
|
|
142
|
+
/**
|
|
143
|
+
* 删回应
|
|
144
|
+
* @param data
|
|
145
|
+
* @returns
|
|
146
|
+
*/
|
|
147
|
+
messageDeleteReaction(data: {
|
|
148
|
+
msg_id: string;
|
|
149
|
+
emoji: string;
|
|
150
|
+
user_id: string;
|
|
151
|
+
}): Promise<{
|
|
152
|
+
code: number;
|
|
153
|
+
message: string;
|
|
154
|
+
data: any[];
|
|
155
|
+
}>;
|
|
156
|
+
/**
|
|
157
|
+
* 发回应
|
|
158
|
+
* @param data
|
|
159
|
+
* @returns
|
|
160
|
+
*/
|
|
161
|
+
messageAddReaction(data: {
|
|
162
|
+
msg_id: string;
|
|
163
|
+
emoji: string;
|
|
164
|
+
}): Promise<{
|
|
165
|
+
code: number;
|
|
166
|
+
message: string;
|
|
167
|
+
data: any[];
|
|
168
|
+
}>;
|
|
169
|
+
/**
|
|
170
|
+
* 某个回应的所有用户
|
|
171
|
+
* @param data
|
|
172
|
+
* @returns
|
|
173
|
+
*/
|
|
174
|
+
messageReactionList(params: {
|
|
175
|
+
msg_id: string;
|
|
176
|
+
emoji: string;
|
|
177
|
+
}): Promise<{
|
|
178
|
+
code: number;
|
|
179
|
+
message: string;
|
|
180
|
+
data: {
|
|
181
|
+
id: string;
|
|
182
|
+
username: string;
|
|
183
|
+
identify_num: string;
|
|
184
|
+
online: boolean;
|
|
185
|
+
status: number;
|
|
186
|
+
avatar: string;
|
|
187
|
+
bot: boolean;
|
|
188
|
+
tag_info: {
|
|
189
|
+
color: string;
|
|
190
|
+
text: string;
|
|
191
|
+
};
|
|
192
|
+
nickname: string;
|
|
193
|
+
reaction_time: number;
|
|
194
|
+
};
|
|
195
|
+
}>;
|
|
196
|
+
/**
|
|
197
|
+
* **********
|
|
198
|
+
* user
|
|
199
|
+
* *********
|
|
200
|
+
*/
|
|
201
|
+
/**
|
|
202
|
+
* 得到当前信息
|
|
203
|
+
* @param guild_id
|
|
204
|
+
* @param user_id
|
|
205
|
+
* @returns
|
|
206
|
+
*/
|
|
207
|
+
userMe(): Promise<{
|
|
208
|
+
code: number;
|
|
209
|
+
message: string;
|
|
210
|
+
data: {
|
|
211
|
+
id: string;
|
|
212
|
+
username: string;
|
|
213
|
+
identify_num: string;
|
|
214
|
+
online: false;
|
|
215
|
+
os: string;
|
|
216
|
+
status: number;
|
|
217
|
+
avatar: string;
|
|
218
|
+
banner: string;
|
|
219
|
+
bot: true;
|
|
220
|
+
mobile_verified: true;
|
|
221
|
+
client_id: string;
|
|
222
|
+
mobile_prefix: string;
|
|
223
|
+
mobile: string;
|
|
224
|
+
invited_count: number;
|
|
225
|
+
};
|
|
226
|
+
}>;
|
|
227
|
+
/**
|
|
228
|
+
* 得到用户信息
|
|
229
|
+
* @param guild_id
|
|
230
|
+
* @param user_id
|
|
231
|
+
* @returns
|
|
232
|
+
*/
|
|
233
|
+
userView(guild_id: string, user_id: string): Promise<{
|
|
234
|
+
code: number;
|
|
235
|
+
message: string;
|
|
236
|
+
data: {
|
|
237
|
+
id: string;
|
|
238
|
+
username: string;
|
|
239
|
+
identify_num: string;
|
|
240
|
+
online: false;
|
|
241
|
+
status: 0;
|
|
242
|
+
bot: true;
|
|
243
|
+
avatar: string;
|
|
244
|
+
vip_avatar: string;
|
|
245
|
+
mobile_verified: true;
|
|
246
|
+
roles: number[];
|
|
247
|
+
joined_at: number;
|
|
248
|
+
active_time: number;
|
|
249
|
+
};
|
|
250
|
+
}>;
|
|
251
|
+
/**
|
|
252
|
+
* 踢出
|
|
253
|
+
* @param guild_id
|
|
254
|
+
* @param user_id
|
|
255
|
+
* @returns
|
|
256
|
+
*/
|
|
257
|
+
guildKickout(guild_id: string, user_id: string): Promise<{
|
|
258
|
+
code: number;
|
|
259
|
+
message: string;
|
|
260
|
+
data: any;
|
|
261
|
+
}>;
|
|
262
|
+
/**
|
|
263
|
+
* 创建角色
|
|
264
|
+
* @param channel_id
|
|
265
|
+
* @param type
|
|
266
|
+
* @param value
|
|
267
|
+
* @returns
|
|
268
|
+
*/
|
|
269
|
+
channelRoleCreate(channel_id: string, type: string, value: string): Promise<{
|
|
270
|
+
code: number;
|
|
271
|
+
message: string;
|
|
272
|
+
data: any;
|
|
273
|
+
}>;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
export { KOOKAPI };
|
|
@@ -0,0 +1,18 @@
|
|
|
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 };
|
|
@@ -0,0 +1,192 @@
|
|
|
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 ["exited_guild", "joined_guild", "joined_channel", "exited_channel", "updated_channel", "pinned_message", "guild_member_online", "added_reaction", "deleted_reaction", "updated_message", "message_btn_click"];
|
|
191
|
+
|
|
192
|
+
export { type Author, type ChannelData, type EditingData, type EventData, type Extra, type KMarkdown, type MessageChannelType, type MessageType, type OnLineData, type SendDirectMessageParams, type SendMessageParams, type StatementData, type SystemData, SystemDataEnum, type memberData, type overheadData };
|
|
@@ -0,0 +1,26 @@
|
|
|
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 };
|