@alemonjs/qq-bot 0.0.8 → 0.0.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 +2 -1
- package/lib/api.d.ts +847 -0
- package/lib/api.js +1 -1
- package/lib/client.d.ts +26 -0
- package/lib/desktop.d.ts +3 -0
- package/lib/desktop.js +65 -0
- package/lib/index.d.ts +7 -4
- package/lib/message/AT_MESSAGE_CREATE.d.ts +37 -0
- package/lib/message/C2C_MESSAGE_CREATE.d.ts +11 -0
- package/lib/message/CHANNEL_CREATE.d.ts +17 -0
- package/lib/message/CHANNEL_DELETE.d.ts +22 -0
- package/lib/message/CHANNEL_UPDATE.d.ts +22 -0
- package/lib/message/DIRECT_MESSAGE_CREATE.d.ts +36 -0
- package/lib/message/DIRECT_MESSAGE_DELETE.d.ts +24 -0
- package/lib/message/ERROR.d.ts +3 -0
- package/lib/message/GROUP_AT_MESSAGE_CREATE.d.ts +16 -0
- package/lib/message/GUILD_CREATE.d.ts +22 -0
- package/lib/message/GUILD_DELETE.d.ts +22 -0
- package/lib/message/GUILD_MEMBER_ADD.d.ts +21 -0
- package/lib/message/GUILD_MEMBER_REMOVE.d.ts +21 -0
- package/lib/message/GUILD_MEMBER_UPDATE.d.ts +21 -0
- package/lib/message/GUILD_UPDATE.d.ts +22 -0
- package/lib/message/INTERACTION_CREATE.d.ts +8 -0
- package/lib/message/MESSAGE_CREATE.d.ts +11 -0
- package/lib/message/MESSAGE_DELETE.d.ts +11 -0
- package/lib/message/MESSAGE_REACTION_ADD.d.ts +15 -0
- package/lib/message/MESSAGE_REACTION_REMOVE.d.ts +15 -0
- package/lib/message/PUBLIC_MESSAGE_DELETE.d.ts +21 -0
- package/lib/message/READY.d.ts +11 -0
- package/lib/message.d.ts +49 -0
- package/lib/typing.d.ts +65 -0
- package/package.json +24 -2
package/lib/api.js
CHANGED
|
@@ -82,7 +82,7 @@ class QQBotAPI {
|
|
|
82
82
|
* @returns
|
|
83
83
|
* 0 文本 1 图文 2 md 3 ark 4 embed
|
|
84
84
|
*/
|
|
85
|
-
async usersOpenMessages(openid, data,
|
|
85
|
+
async usersOpenMessages(openid, data, _msg_id) {
|
|
86
86
|
return this.groupService({
|
|
87
87
|
url: `/v2/users/${openid}/messages`,
|
|
88
88
|
method: 'post',
|
package/lib/client.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { QQBotAPI } from './api.js';
|
|
2
|
+
import { QQBotEventMap } from './message.js';
|
|
3
|
+
import { Options } from './typing.js';
|
|
4
|
+
|
|
5
|
+
declare class QQBotClient extends QQBotAPI {
|
|
6
|
+
#private;
|
|
7
|
+
/**
|
|
8
|
+
* 设置配置
|
|
9
|
+
* @param opstion
|
|
10
|
+
*/
|
|
11
|
+
constructor(opstion: Options);
|
|
12
|
+
/**
|
|
13
|
+
* 注册事件处理程序
|
|
14
|
+
* @param key 事件名称
|
|
15
|
+
* @param val 事件处理函数
|
|
16
|
+
*/
|
|
17
|
+
on<T extends keyof QQBotEventMap>(key: T, val: (event: QQBotEventMap[T]) => any): this;
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
* @param cfg
|
|
21
|
+
* @param conversation
|
|
22
|
+
*/
|
|
23
|
+
connect(): void;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { QQBotClient };
|
package/lib/desktop.d.ts
ADDED
package/lib/desktop.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
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.qq-bot', () => {
|
|
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 === 'qq-bot.form.save') {
|
|
31
|
+
const qqBot = data.data;
|
|
32
|
+
const config = getConfig();
|
|
33
|
+
const value = config.value ?? {};
|
|
34
|
+
value['qq-bot'] = {
|
|
35
|
+
app_id: qqBot.app_id ?? '',
|
|
36
|
+
token: qqBot.token ?? '',
|
|
37
|
+
secret: qqBot.secret ?? '',
|
|
38
|
+
// master_key 12121,1313,1313,13 转为数组
|
|
39
|
+
master_key: qqBot.master_key.split(','),
|
|
40
|
+
route: qqBot.route ?? '/webhook',
|
|
41
|
+
port: qqBot.port ?? 17157,
|
|
42
|
+
ws: qqBot.ws != '' && qqBot.ws ? qqBot.ws : null,
|
|
43
|
+
sandbox: qqBot.sandbox ?? false
|
|
44
|
+
};
|
|
45
|
+
config.saveValue(value);
|
|
46
|
+
context.notification('QQ Bot 配置保存成功~');
|
|
47
|
+
}
|
|
48
|
+
else if (data.type === 'qq-bot.init') {
|
|
49
|
+
let config = getConfigValue();
|
|
50
|
+
if (!config)
|
|
51
|
+
config = {};
|
|
52
|
+
// 发送消息
|
|
53
|
+
webView.postMessage({
|
|
54
|
+
type: 'qq-bot.init',
|
|
55
|
+
data: config.qq_bot ?? {}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
catch (e) {
|
|
60
|
+
console.error(e);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export { activate };
|
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import * as alemonjs from 'alemonjs'
|
|
1
|
+
import * as alemonjs from 'alemonjs';
|
|
2
|
+
import { QQBotClient } from './client.js';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
declare const
|
|
4
|
+
type Client = typeof QQBotClient.prototype;
|
|
5
|
+
declare const client: Client;
|
|
6
|
+
declare const platform = "qq-bot";
|
|
7
|
+
declare const _default: () => alemonjs.ClientAPI;
|
|
5
8
|
|
|
6
|
-
export { _default as default, platform }
|
|
9
|
+
export { type Client, client, _default as default, platform };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
type AT_MESSAGE_CREATE_TYPE = {
|
|
2
|
+
attachments?: {
|
|
3
|
+
id: string;
|
|
4
|
+
url: string;
|
|
5
|
+
content_type: string;
|
|
6
|
+
filename: string;
|
|
7
|
+
size: number;
|
|
8
|
+
height: number;
|
|
9
|
+
width: number;
|
|
10
|
+
}[];
|
|
11
|
+
author: {
|
|
12
|
+
avatar: string;
|
|
13
|
+
bot: boolean;
|
|
14
|
+
id: string;
|
|
15
|
+
username: string;
|
|
16
|
+
};
|
|
17
|
+
channel_id: string;
|
|
18
|
+
content: string;
|
|
19
|
+
guild_id: string;
|
|
20
|
+
id: string;
|
|
21
|
+
member: {
|
|
22
|
+
joined_at: string;
|
|
23
|
+
nick: string;
|
|
24
|
+
roles: string[];
|
|
25
|
+
};
|
|
26
|
+
mentions: {
|
|
27
|
+
avatar: string;
|
|
28
|
+
bot: boolean;
|
|
29
|
+
id: string;
|
|
30
|
+
username: string;
|
|
31
|
+
}[];
|
|
32
|
+
seq: number;
|
|
33
|
+
seq_in_channel: string;
|
|
34
|
+
timestamp: string;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export type { AT_MESSAGE_CREATE_TYPE };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
type CHANNEL_CREATE_TYPE = {
|
|
2
|
+
application_id?: string;
|
|
3
|
+
guild_id: string;
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
op_user_id: string;
|
|
7
|
+
owner_id: string;
|
|
8
|
+
parent_id?: string;
|
|
9
|
+
permissions?: string;
|
|
10
|
+
position?: number;
|
|
11
|
+
private_type: number;
|
|
12
|
+
speak_permission: number;
|
|
13
|
+
sub_type: number;
|
|
14
|
+
type: number;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type { CHANNEL_CREATE_TYPE };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 子频道删除
|
|
3
|
+
* @param event
|
|
4
|
+
* @returns
|
|
5
|
+
*/
|
|
6
|
+
type CHANNEL_DELETE_TYPE = {
|
|
7
|
+
application_id?: string;
|
|
8
|
+
guild_id: string;
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
op_user_id: string;
|
|
12
|
+
owner_id: string;
|
|
13
|
+
parent_id?: string;
|
|
14
|
+
permissions?: string;
|
|
15
|
+
position?: number;
|
|
16
|
+
private_type: number;
|
|
17
|
+
speak_permission: number;
|
|
18
|
+
sub_type: number;
|
|
19
|
+
type: number;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type { CHANNEL_DELETE_TYPE };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 子频道更新
|
|
3
|
+
* @param event
|
|
4
|
+
* @returns
|
|
5
|
+
*/
|
|
6
|
+
type CHANNEL_UPDATE_TYPE = {
|
|
7
|
+
application_id?: string;
|
|
8
|
+
guild_id: string;
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
op_user_id: string;
|
|
12
|
+
owner_id: string;
|
|
13
|
+
parent_id?: string;
|
|
14
|
+
permissions?: string;
|
|
15
|
+
position?: number;
|
|
16
|
+
private_type: number;
|
|
17
|
+
speak_permission: number;
|
|
18
|
+
sub_type: number;
|
|
19
|
+
type: number;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type { CHANNEL_UPDATE_TYPE };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 私信
|
|
3
|
+
* @param event
|
|
4
|
+
* @returns
|
|
5
|
+
*/
|
|
6
|
+
type DIRECT_MESSAGE_CREATE_TYPE = {
|
|
7
|
+
attachments?: {
|
|
8
|
+
content_type: string;
|
|
9
|
+
filename: string;
|
|
10
|
+
height: number;
|
|
11
|
+
id: string;
|
|
12
|
+
size: number;
|
|
13
|
+
url: string;
|
|
14
|
+
width: number;
|
|
15
|
+
}[];
|
|
16
|
+
author: {
|
|
17
|
+
avatar: string;
|
|
18
|
+
bot: boolean;
|
|
19
|
+
id: string;
|
|
20
|
+
username: string;
|
|
21
|
+
};
|
|
22
|
+
channel_id: string;
|
|
23
|
+
content: string;
|
|
24
|
+
direct_message: boolean;
|
|
25
|
+
guild_id: string;
|
|
26
|
+
id: string;
|
|
27
|
+
member: {
|
|
28
|
+
joined_at: string;
|
|
29
|
+
};
|
|
30
|
+
seq: number;
|
|
31
|
+
seq_in_channel: string;
|
|
32
|
+
src_guild_id: string;
|
|
33
|
+
timestamp: string;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export type { DIRECT_MESSAGE_CREATE_TYPE };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* *
|
|
3
|
+
* 私信
|
|
4
|
+
* *
|
|
5
|
+
*/
|
|
6
|
+
type DIRECT_MESSAGE_DELETE_TYPE = {
|
|
7
|
+
message: {
|
|
8
|
+
author: {
|
|
9
|
+
bot: boolean;
|
|
10
|
+
id: string;
|
|
11
|
+
username: string;
|
|
12
|
+
};
|
|
13
|
+
channel_id: string;
|
|
14
|
+
direct_message: boolean;
|
|
15
|
+
guild_id: string;
|
|
16
|
+
id: string;
|
|
17
|
+
src_guild_id: string;
|
|
18
|
+
};
|
|
19
|
+
op_user: {
|
|
20
|
+
id: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type { DIRECT_MESSAGE_DELETE_TYPE };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 群消息事件 AT 事件
|
|
3
|
+
*/
|
|
4
|
+
interface GROUP_AT_MESSAGE_CREATE_TYPE {
|
|
5
|
+
author: {
|
|
6
|
+
id: string;
|
|
7
|
+
member_openid: string;
|
|
8
|
+
};
|
|
9
|
+
content: string;
|
|
10
|
+
group_openid: string;
|
|
11
|
+
group_id: string;
|
|
12
|
+
id: string;
|
|
13
|
+
timestamp: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type { GROUP_AT_MESSAGE_CREATE_TYPE };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 机器人加入
|
|
3
|
+
* @param event
|
|
4
|
+
* @returns
|
|
5
|
+
*/
|
|
6
|
+
type GUILD_CREATE_TYPE = {
|
|
7
|
+
description: string;
|
|
8
|
+
icon: string;
|
|
9
|
+
id: string;
|
|
10
|
+
joined_at: string;
|
|
11
|
+
max_members: number;
|
|
12
|
+
member_count: number;
|
|
13
|
+
name: string;
|
|
14
|
+
op_user_id: string;
|
|
15
|
+
owner: boolean;
|
|
16
|
+
owner_id: string;
|
|
17
|
+
union_appid: string;
|
|
18
|
+
union_org_id: string;
|
|
19
|
+
union_world_id: string;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type { GUILD_CREATE_TYPE };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 机器人退出频道
|
|
3
|
+
* @param event
|
|
4
|
+
* @returns
|
|
5
|
+
*/
|
|
6
|
+
type GUILD_DELETE_TYPE = {
|
|
7
|
+
description: string;
|
|
8
|
+
icon: string;
|
|
9
|
+
id: string;
|
|
10
|
+
joined_at: string;
|
|
11
|
+
max_members: number;
|
|
12
|
+
member_count: number;
|
|
13
|
+
name: string;
|
|
14
|
+
op_user_id: string;
|
|
15
|
+
owner: boolean;
|
|
16
|
+
owner_id: string;
|
|
17
|
+
union_appid: string;
|
|
18
|
+
union_org_id: string;
|
|
19
|
+
union_world_id: string;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type { GUILD_DELETE_TYPE };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 当成员加入时
|
|
3
|
+
* @param event
|
|
4
|
+
* @returns
|
|
5
|
+
*/
|
|
6
|
+
type GUILD_MEMBER_ADD_TYPE = {
|
|
7
|
+
guild_id: string;
|
|
8
|
+
joined_at: string;
|
|
9
|
+
nick: string;
|
|
10
|
+
op_user_id: string;
|
|
11
|
+
roles: string[];
|
|
12
|
+
source_type?: string;
|
|
13
|
+
user: {
|
|
14
|
+
avatar: string;
|
|
15
|
+
bot: number;
|
|
16
|
+
id: string;
|
|
17
|
+
username: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export type { GUILD_MEMBER_ADD_TYPE };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 当成员被移除时
|
|
3
|
+
* @param event
|
|
4
|
+
* @returns
|
|
5
|
+
*/
|
|
6
|
+
type GUILD_MEMBER_REMOVE_TYPE = {
|
|
7
|
+
guild_id: string;
|
|
8
|
+
joined_at: string;
|
|
9
|
+
nick: string;
|
|
10
|
+
op_user_id: string;
|
|
11
|
+
roles: string[];
|
|
12
|
+
source_type?: string;
|
|
13
|
+
user: {
|
|
14
|
+
avatar: string;
|
|
15
|
+
bot: number;
|
|
16
|
+
id: string;
|
|
17
|
+
username: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export type { GUILD_MEMBER_REMOVE_TYPE };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 当成员资料变更时
|
|
3
|
+
* @param event
|
|
4
|
+
* @returns
|
|
5
|
+
*/
|
|
6
|
+
type GUILD_MEMBER_UPDATE_TYPE = {
|
|
7
|
+
guild_id: string;
|
|
8
|
+
joined_at: string;
|
|
9
|
+
nick: string;
|
|
10
|
+
op_user_id: string;
|
|
11
|
+
roles: string[];
|
|
12
|
+
source_type?: string;
|
|
13
|
+
user: {
|
|
14
|
+
avatar: string;
|
|
15
|
+
bot: number;
|
|
16
|
+
id: string;
|
|
17
|
+
username: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export type { GUILD_MEMBER_UPDATE_TYPE };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 信息更新
|
|
3
|
+
* @param event
|
|
4
|
+
* @returns
|
|
5
|
+
*/
|
|
6
|
+
type GUILD_UPDATE_TYPE = {
|
|
7
|
+
description: string;
|
|
8
|
+
icon: string;
|
|
9
|
+
id: string;
|
|
10
|
+
joined_at: string;
|
|
11
|
+
max_members: number;
|
|
12
|
+
member_count: number;
|
|
13
|
+
name: string;
|
|
14
|
+
op_user_id: string;
|
|
15
|
+
owner: boolean;
|
|
16
|
+
owner_id: string;
|
|
17
|
+
union_appid: string;
|
|
18
|
+
union_org_id: string;
|
|
19
|
+
union_world_id: string;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type { GUILD_UPDATE_TYPE };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
type MESSAGE_REACTION_REMOVE_TYPE = {
|
|
2
|
+
channel_id: string;
|
|
3
|
+
emoji: {
|
|
4
|
+
id: string;
|
|
5
|
+
type: number;
|
|
6
|
+
};
|
|
7
|
+
guild_id: string;
|
|
8
|
+
target: {
|
|
9
|
+
id: string;
|
|
10
|
+
type: string;
|
|
11
|
+
};
|
|
12
|
+
user_id: string;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export type { MESSAGE_REACTION_REMOVE_TYPE };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 公域
|
|
3
|
+
* @param event
|
|
4
|
+
*/
|
|
5
|
+
type PUBLIC_MESSAGE_DELETE_TYPE = {
|
|
6
|
+
message: {
|
|
7
|
+
author: {
|
|
8
|
+
bot: false;
|
|
9
|
+
id: string;
|
|
10
|
+
username: string;
|
|
11
|
+
};
|
|
12
|
+
channel_id: string;
|
|
13
|
+
guild_id: string;
|
|
14
|
+
id: string;
|
|
15
|
+
};
|
|
16
|
+
op_user: {
|
|
17
|
+
id: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export type { PUBLIC_MESSAGE_DELETE_TYPE };
|
package/lib/message.d.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { C2C_MESSAGE_CREATE_TYPE } from './message/C2C_MESSAGE_CREATE.js';
|
|
2
|
+
import { GROUP_AT_MESSAGE_CREATE_TYPE } from './message/GROUP_AT_MESSAGE_CREATE.js';
|
|
3
|
+
import { AT_MESSAGE_CREATE_TYPE } from './message/AT_MESSAGE_CREATE.js';
|
|
4
|
+
import { CHANNEL_CREATE_TYPE } from './message/CHANNEL_CREATE.js';
|
|
5
|
+
import { CHANNEL_DELETE_TYPE } from './message/CHANNEL_DELETE.js';
|
|
6
|
+
import { CHANNEL_UPDATE_TYPE } from './message/CHANNEL_UPDATE.js';
|
|
7
|
+
import { DIRECT_MESSAGE_CREATE_TYPE } from './message/DIRECT_MESSAGE_CREATE.js';
|
|
8
|
+
import { DIRECT_MESSAGE_DELETE_TYPE } from './message/DIRECT_MESSAGE_DELETE.js';
|
|
9
|
+
import { GUILD_CREATE_TYPE } from './message/GUILD_CREATE.js';
|
|
10
|
+
import { GUILD_DELETE_TYPE } from './message/GUILD_DELETE.js';
|
|
11
|
+
import { GUILD_MEMBER_ADD_TYPE } from './message/GUILD_MEMBER_ADD.js';
|
|
12
|
+
import { GUILD_MEMBER_REMOVE_TYPE } from './message/GUILD_MEMBER_REMOVE.js';
|
|
13
|
+
import { GUILD_MEMBER_UPDATE_TYPE } from './message/GUILD_MEMBER_UPDATE.js';
|
|
14
|
+
import { GUILD_UPDATE_TYPE } from './message/GUILD_UPDATE.js';
|
|
15
|
+
import { INTERACTION_CREATE_TYPE } from './message/INTERACTION_CREATE.js';
|
|
16
|
+
import { MESSAGE_CREATE_TYPE } from './message/MESSAGE_CREATE.js';
|
|
17
|
+
import { MESSAGE_DELETE_TYPE } from './message/MESSAGE_DELETE.js';
|
|
18
|
+
import { MESSAGE_REACTION_ADD_TYPE } from './message/MESSAGE_REACTION_ADD.js';
|
|
19
|
+
import { MESSAGE_REACTION_REMOVE_TYPE } from './message/MESSAGE_REACTION_REMOVE.js';
|
|
20
|
+
import { PUBLIC_MESSAGE_DELETE_TYPE } from './message/PUBLIC_MESSAGE_DELETE.js';
|
|
21
|
+
import { READY_TYPE } from './message/READY.js';
|
|
22
|
+
import { ERROR_TYPE } from './message/ERROR.js';
|
|
23
|
+
|
|
24
|
+
type QQBotEventMap = {
|
|
25
|
+
AT_MESSAGE_CREATE: AT_MESSAGE_CREATE_TYPE;
|
|
26
|
+
CHANNEL_CREATE: CHANNEL_CREATE_TYPE;
|
|
27
|
+
CHANNEL_DELETE: CHANNEL_DELETE_TYPE;
|
|
28
|
+
CHANNEL_UPDATE: CHANNEL_UPDATE_TYPE;
|
|
29
|
+
DIRECT_MESSAGE_CREATE: DIRECT_MESSAGE_CREATE_TYPE;
|
|
30
|
+
DIRECT_MESSAGE_DELETE: DIRECT_MESSAGE_DELETE_TYPE;
|
|
31
|
+
GUILD_CREATE: GUILD_CREATE_TYPE;
|
|
32
|
+
GUILD_DELETE: GUILD_DELETE_TYPE;
|
|
33
|
+
GUILD_MEMBER_ADD: GUILD_MEMBER_ADD_TYPE;
|
|
34
|
+
GUILD_MEMBER_REMOVE: GUILD_MEMBER_REMOVE_TYPE;
|
|
35
|
+
GUILD_MEMBER_UPDATE: GUILD_MEMBER_UPDATE_TYPE;
|
|
36
|
+
GUILD_UPDATE: GUILD_UPDATE_TYPE;
|
|
37
|
+
INTERACTION_CREATE: INTERACTION_CREATE_TYPE;
|
|
38
|
+
MESSAGE_CREATE: MESSAGE_CREATE_TYPE;
|
|
39
|
+
MESSAGE_DELETE: MESSAGE_DELETE_TYPE;
|
|
40
|
+
MESSAGE_REACTION_ADD: MESSAGE_REACTION_ADD_TYPE;
|
|
41
|
+
MESSAGE_REACTION_REMOVE: MESSAGE_REACTION_REMOVE_TYPE;
|
|
42
|
+
PUBLIC_MESSAGE_DELETE: PUBLIC_MESSAGE_DELETE_TYPE;
|
|
43
|
+
READY: READY_TYPE;
|
|
44
|
+
C2C_MESSAGE_CREATE: C2C_MESSAGE_CREATE_TYPE;
|
|
45
|
+
GROUP_AT_MESSAGE_CREATE: GROUP_AT_MESSAGE_CREATE_TYPE;
|
|
46
|
+
ERROR: ERROR_TYPE;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export type { QQBotEventMap };
|
package/lib/typing.d.ts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
type MessageType = 0 | 1 | 2 | 3 | 4 | 7;
|
|
2
|
+
type FileType = 1 | 2 | 3 | 4;
|
|
3
|
+
interface ButtonType {
|
|
4
|
+
id: string;
|
|
5
|
+
render_data: {
|
|
6
|
+
label: string;
|
|
7
|
+
visited_label: string;
|
|
8
|
+
style: number;
|
|
9
|
+
};
|
|
10
|
+
action: {
|
|
11
|
+
type: number;
|
|
12
|
+
permission: {
|
|
13
|
+
type: number;
|
|
14
|
+
};
|
|
15
|
+
reply?: boolean;
|
|
16
|
+
enter?: boolean;
|
|
17
|
+
unsupport_tips: string;
|
|
18
|
+
data: string;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
interface KeyboardType {
|
|
22
|
+
id?: string;
|
|
23
|
+
content?: {
|
|
24
|
+
rows: {
|
|
25
|
+
buttons: ButtonType[];
|
|
26
|
+
}[];
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
interface MarkdownType {
|
|
30
|
+
/** markdown 模版id,申请模版后获得 */
|
|
31
|
+
custom_template_id: string;
|
|
32
|
+
/** 原生 markdown 文本内容(内邀使用) */
|
|
33
|
+
content?: string;
|
|
34
|
+
/** 模版内变量与填充值的kv映射 */
|
|
35
|
+
params?: Array<{
|
|
36
|
+
key: string;
|
|
37
|
+
values: string[];
|
|
38
|
+
}>;
|
|
39
|
+
}
|
|
40
|
+
interface ApiRequestData {
|
|
41
|
+
content?: string;
|
|
42
|
+
msg_type: MessageType;
|
|
43
|
+
markdown?: MarkdownType;
|
|
44
|
+
keyboard?: KeyboardType;
|
|
45
|
+
media?: {
|
|
46
|
+
file_info: string;
|
|
47
|
+
};
|
|
48
|
+
ark?: any;
|
|
49
|
+
image?: any;
|
|
50
|
+
message_reference?: any;
|
|
51
|
+
event_id?: any;
|
|
52
|
+
msg_id?: string;
|
|
53
|
+
msg_seq?: number;
|
|
54
|
+
}
|
|
55
|
+
interface Options {
|
|
56
|
+
secret: string;
|
|
57
|
+
app_id: string;
|
|
58
|
+
token: string;
|
|
59
|
+
sandbox?: boolean;
|
|
60
|
+
route?: string;
|
|
61
|
+
port?: string;
|
|
62
|
+
ws?: string;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export type { ApiRequestData, ButtonType, FileType, KeyboardType, MarkdownType, MessageType, Options };
|