@alemonjs/qq-bot 2.1.0-alpha.9 → 2.1.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 (109) hide show
  1. package/README.md +13 -45
  2. package/lib/config.d.ts +8 -0
  3. package/lib/config.js +20 -0
  4. package/lib/desktop.d.ts +1 -3
  5. package/lib/desktop.js +3 -12
  6. package/lib/hook.d.ts +36 -9
  7. package/lib/hook.js +21 -19
  8. package/lib/index.d.ts +5 -7
  9. package/lib/index.js +11 -21
  10. package/lib/index.webhook.d.ts +1 -0
  11. package/lib/index.webhook.js +5 -4
  12. package/lib/index.websoket.d.ts +1 -0
  13. package/lib/index.websoket.js +31 -23
  14. package/lib/message/AT_MESSAGE_CREATE.d.ts +35 -0
  15. package/lib/message/AT_MESSAGE_CREATE.js +1 -0
  16. package/lib/message/CHANNEL_CREATE.d.ts +15 -0
  17. package/lib/message/CHANNEL_CREATE.js +1 -0
  18. package/lib/message/CHANNEL_DELETE.d.ts +15 -0
  19. package/lib/message/CHANNEL_DELETE.js +1 -0
  20. package/lib/message/CHANNEL_UPDATE.d.ts +15 -0
  21. package/lib/message/CHANNEL_UPDATE.js +1 -0
  22. package/lib/message/DIRECT_MESSAGE_CREATE.d.ts +29 -0
  23. package/lib/message/DIRECT_MESSAGE_CREATE.js +1 -0
  24. package/lib/message/DIRECT_MESSAGE_DELETE.d.ts +17 -0
  25. package/lib/message/DIRECT_MESSAGE_DELETE.js +1 -0
  26. package/lib/message/ERROR.d.ts +1 -0
  27. package/lib/message/ERROR.js +1 -0
  28. package/lib/message/GUILD_CREATE.d.ts +15 -0
  29. package/lib/message/GUILD_CREATE.js +1 -0
  30. package/lib/message/GUILD_DELETE.d.ts +15 -0
  31. package/lib/message/GUILD_DELETE.js +1 -0
  32. package/lib/message/GUILD_MEMBER_ADD.d.ts +14 -0
  33. package/lib/message/GUILD_MEMBER_ADD.js +1 -0
  34. package/lib/message/GUILD_MEMBER_REMOVE.d.ts +14 -0
  35. package/lib/message/GUILD_MEMBER_REMOVE.js +1 -0
  36. package/lib/message/GUILD_MEMBER_UPDATE.d.ts +14 -0
  37. package/lib/message/GUILD_MEMBER_UPDATE.js +1 -0
  38. package/lib/message/GUILD_UPDATE.d.ts +15 -0
  39. package/lib/message/GUILD_UPDATE.js +1 -0
  40. package/lib/message/INTERACTION_CREATE.d.ts +53 -0
  41. package/lib/message/INTERACTION_CREATE.js +1 -0
  42. package/lib/message/MESSAGE_CREATE.d.ts +1 -0
  43. package/lib/message/MESSAGE_CREATE.js +1 -0
  44. package/lib/message/MESSAGE_DELETE.d.ts +1 -0
  45. package/lib/message/MESSAGE_DELETE.js +1 -0
  46. package/lib/message/MESSAGE_REACTION_ADD.d.ts +13 -0
  47. package/lib/message/MESSAGE_REACTION_ADD.js +1 -0
  48. package/lib/message/MESSAGE_REACTION_REMOVE.d.ts +13 -0
  49. package/lib/message/MESSAGE_REACTION_REMOVE.js +1 -0
  50. package/lib/message/PUBLIC_MESSAGE_DELETE.d.ts +15 -0
  51. package/lib/message/PUBLIC_MESSAGE_DELETE.js +1 -0
  52. package/lib/message/READY.d.ts +6 -0
  53. package/lib/message/READY.js +1 -0
  54. package/lib/message/group/C2C_MESSAGE_CREATE.d.ts +9 -0
  55. package/lib/message/group/C2C_MESSAGE_CREATE.js +1 -0
  56. package/lib/message/group/C2C_MSG_RECEIVE.d.ts +4 -0
  57. package/lib/message/group/C2C_MSG_RECEIVE.js +1 -0
  58. package/lib/message/group/C2C_MSG_REJECT.d.ts +4 -0
  59. package/lib/message/group/C2C_MSG_REJECT.js +1 -0
  60. package/lib/message/group/FRIEND_ADD.d.ts +4 -0
  61. package/lib/message/group/FRIEND_ADD.js +1 -0
  62. package/lib/message/group/FRIEND_DEL.d.ts +4 -0
  63. package/lib/message/group/FRIEND_DEL.js +1 -0
  64. package/lib/message/group/GROUP_ADD_ROBOT.d.ts +5 -0
  65. package/lib/message/group/GROUP_ADD_ROBOT.js +1 -0
  66. package/lib/message/group/GROUP_AT_MESSAGE_CREATE.d.ts +11 -0
  67. package/lib/message/group/GROUP_AT_MESSAGE_CREATE.js +1 -0
  68. package/lib/message/group/GROUP_DEL_ROBOT.d.ts +5 -0
  69. package/lib/message/group/GROUP_DEL_ROBOT.js +1 -0
  70. package/lib/message/group/GROUP_MSG_RECEIVE.d.ts +5 -0
  71. package/lib/message/group/GROUP_MSG_RECEIVE.js +1 -0
  72. package/lib/message/group/GROUP_MSG_REJECT.d.ts +5 -0
  73. package/lib/message/group/GROUP_MSG_REJECT.js +1 -0
  74. package/lib/register.d.ts +2 -3
  75. package/lib/register.js +426 -252
  76. package/lib/sdk/api.d.ts +10 -567
  77. package/lib/sdk/api.js +224 -790
  78. package/lib/sdk/client.webhook.d.ts +9 -0
  79. package/lib/sdk/{client.js → client.webhook.js} +18 -55
  80. package/lib/sdk/client.websoket.d.ts +9 -0
  81. package/lib/sdk/client.websoket.js +52 -97
  82. package/lib/sdk/config.d.ts +1 -0
  83. package/lib/sdk/instance.d.ts +3 -0
  84. package/lib/sdk/instance.js +93 -0
  85. package/lib/sdk/intents.d.ts +3 -0
  86. package/lib/sdk/intents.js +25 -90
  87. package/lib/sdk/message.d.ts +4 -0
  88. package/lib/sdk/message.group.d.ts +24 -0
  89. package/lib/sdk/message.group.js +1 -0
  90. package/lib/sdk/message.guild.d.ts +38 -0
  91. package/lib/sdk/message.guild.js +1 -0
  92. package/lib/sdk/message.js +1 -0
  93. package/lib/sdk/message.public.d.ts +6 -0
  94. package/lib/sdk/message.public.js +1 -0
  95. package/lib/sdk/typing.d.ts +22 -11
  96. package/lib/sdk/typing.js +1 -0
  97. package/lib/sdk/webhook.secret.d.ts +14 -0
  98. package/lib/sdk/webhook.secret.js +6 -21
  99. package/lib/sends.d.ts +29 -0
  100. package/lib/sends.js +326 -745
  101. package/lib/utils.d.ts +1 -0
  102. package/lib/utils.js +7 -12
  103. package/package.json +9 -5
  104. package/lib/index.group.js +0 -19
  105. package/lib/index.guild.js +0 -36
  106. package/lib/sdk/client.websoket.group.js +0 -221
  107. package/lib/sdk/client.websoket.guild.js +0 -205
  108. package/lib/sdk/counter.js +0 -19
  109. package/lib/sdk/from.js +0 -44
package/README.md CHANGED
@@ -24,56 +24,24 @@ qq-bot:
24
24
  secret: ''
25
25
  ```
26
26
 
27
- > 默认使用 1)websocket 模式,配置 route 可选择 webhook 模式
27
+ > 1、默认 websocket 模式,配置 route/port 可选择 webhook 模式
28
28
 
29
- > 配置 webhook ip/域名,一旦生效官方将禁用 websocket 模式
29
+ > 2、webhook 模式,需 ip/域名,一旦生效官方将禁用 websocket 模式
30
+
31
+ > 3、gatewayURL 直连模式,
32
+
33
+ > 4、域名代理模式
30
34
 
31
35
  ```sh
32
36
  qq-bot:
33
37
  # 频道沙盒,默认false
34
- sandbox: false
35
- # 1)websocket 模式
36
- # mode: 'guild'
37
- # mode: 'group'
38
- # 2)webhook 模式
39
- # 推荐nginx进行代理 http://localhost:17157/webhook
40
- # 填写将启动 webhook模式
41
- port: 17157
42
- route: '/webhook'
43
- # 当配置ws的时候,会连接另一台webhook机器人的消息。不会再启动本地端口。
44
- # 假设代理后的地址为 https://qqbotjs.com
45
- # ws: 'wss://qqbotjs.com/websocket'
46
- # ws: 'ws://[your ip]:17157/websocket'
38
+ # sandbox: false
39
+ # 2)填写将启动 webhook模式
40
+ # port: 17157
41
+ # route: '/webhook'
47
42
  # 3) 自定义模式 (用于连接类官网连接方式的指定服务端)
48
43
  # gatewayURL: 'ws://[your ip]:8080'
49
- ```
50
-
51
- ```conf
52
- server {
53
- listen 443 ssl http2;
54
- server_name bundle.com;
55
- ssl_certificate /usr/local/nginx/bundle.crt;
56
- ssl_certificate_key /usr/local/nginx/bundle.key;
57
- # 对应 route: ''
58
- location /webhook {
59
- # 指向 webhook 服务的端口 17157
60
- proxy_pass http://localhost:17157;
61
- proxy_set_header Host $host;
62
- proxy_set_header X-Real-IP $remote_addr;
63
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
64
- proxy_set_header X-Forwarded-Proto $scheme;
65
- }
66
- # 对应 ws: ''
67
- location /websocket {
68
- # 指向 WebSocket 服务的端口 17157
69
- proxy_pass http://localhost:17157;
70
- proxy_http_version 1.1;
71
- proxy_set_header Upgrade $http_upgrade;
72
- proxy_set_header Connection "upgrade";
73
- proxy_set_header Host $host;
74
- proxy_set_header X-Real-IP $remote_addr;
75
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
76
- proxy_set_header X-Forwarded-Proto $scheme;
77
- }
78
- }
44
+ # 4) 域名代理模式
45
+ # base_url_gateway: https://[your addr]
46
+ # base_url_app_access_token: https://[your addr]
79
47
  ```
@@ -0,0 +1,8 @@
1
+ import { Options as sdkOptions } from './sdk/typing';
2
+ export declare const platform = "qq-bot";
3
+ export type Options = {
4
+ master_key?: string[];
5
+ master_id?: string[];
6
+ } & sdkOptions;
7
+ export declare const getQQBotConfig: () => Options;
8
+ export declare const getMaster: (UserId: string) => readonly [boolean, string];
package/lib/config.js ADDED
@@ -0,0 +1,20 @@
1
+ import { getConfigValue, useUserHashKey } from 'alemonjs';
2
+
3
+ const platform = 'qq-bot';
4
+ const getQQBotConfig = () => {
5
+ const value = getConfigValue() || {};
6
+ return value[platform] || {};
7
+ };
8
+ const getMaster = (UserId) => {
9
+ const config = getQQBotConfig();
10
+ const master_key = config.master_key || [];
11
+ const master_id = config.master_id || [];
12
+ const UserKey = useUserHashKey({
13
+ Platform: platform,
14
+ UserId: UserId
15
+ });
16
+ const is = master_key.includes(UserKey) || master_id.includes(UserId);
17
+ return [is, UserKey];
18
+ };
19
+
20
+ export { getMaster, getQQBotConfig, platform };
package/lib/desktop.d.ts CHANGED
@@ -1,3 +1 @@
1
- declare const activate: (context: any) => void;
2
-
3
- export { activate };
1
+ export declare const activate: (context: any) => void;
package/lib/desktop.js CHANGED
@@ -3,30 +3,22 @@ import { dirname, join } from 'path';
3
3
  import { fileURLToPath } from 'url';
4
4
  import { getConfig, getConfigValue } from 'alemonjs';
5
5
 
6
- // 当前目录
7
6
  const __dirname = dirname(fileURLToPath(import.meta.url));
8
- // 被激活的时候。
9
7
  const activate = context => {
10
- // 创建一个 webview。
11
8
  const webView = context.createSidebarWebView(context);
12
- // 当命令被触发的时候。
13
9
  context.onCommand('open.qq-bot', () => {
14
10
  const dir = join(__dirname, '../', 'dist', 'index.html');
15
11
  const scriptReg = /<script.*?src="(.+?)".*?>/;
16
12
  const styleReg = /<link.*?rel="stylesheet".*?href="(.+?)".*?>/;
17
13
  const iconReg = /<link.*?rel="icon".*?href="(.+?)".*?>/g;
18
- // 创建 webview 路径
19
14
  const styleUri = context.createExtensionDir(join(__dirname, '../', 'dist', 'assets', 'index.css'));
20
15
  const scriptUri = context.createExtensionDir(join(__dirname, '../', 'dist', 'assets', 'index.js'));
21
- // 确保路径存在
22
16
  const html = readFileSync(dir, 'utf-8')
23
- .replace(iconReg, ``)
17
+ .replace(iconReg, '')
24
18
  .replace(scriptReg, `<script type="module" crossorigin src="${scriptUri}"></script>`)
25
19
  .replace(styleReg, `<link rel="stylesheet" crossorigin href="${styleUri}">`);
26
- // 立即渲染 webview
27
20
  webView.loadWebView(html);
28
21
  });
29
- // 监听 webview 的消息。
30
22
  webView.onMessage(data => {
31
23
  try {
32
24
  if (data.type === 'qq-bot.form.save') {
@@ -35,7 +27,6 @@ const activate = context => {
35
27
  const value = config.value ?? {};
36
28
  value['qq-bot'] = {
37
29
  ...qqBot,
38
- // master_key 12121,1313,1313,13 转为数组
39
30
  master_key: qqBot.master_key.split(',')
40
31
  };
41
32
  config.saveValue(value);
@@ -43,9 +34,9 @@ const activate = context => {
43
34
  }
44
35
  else if (data.type === 'qq-bot.init') {
45
36
  let config = getConfigValue();
46
- if (!config)
37
+ if (!config) {
47
38
  config = {};
48
- // 发送消息
39
+ }
49
40
  webView.postMessage({
50
41
  type: 'qq-bot.init',
51
42
  data: config['qq-bot'] ?? {}
package/lib/hook.d.ts CHANGED
@@ -1,10 +1,37 @@
1
1
  import { EventKeys, Events } from 'alemonjs';
2
-
3
- /**
4
- * 判断当前模式
5
- * @param event
6
- * @returns
7
- */
8
- declare const useMode: <T extends EventKeys>(event: Events[T]) => (mode: "guild" | "group") => boolean;
9
-
10
- export { useMode };
2
+ import { GROUP_AT_MESSAGE_CREATE_TYPE } from './message/group/GROUP_AT_MESSAGE_CREATE';
3
+ import { QQBotAPI as API } from './sdk/api';
4
+ import { AT_MESSAGE_CREATE_TYPE } from './message/AT_MESSAGE_CREATE';
5
+ import { INTERACTION_CREATE_TYPE } from './message/INTERACTION_CREATE';
6
+ import { DIRECT_MESSAGE_CREATE_TYPE } from './message/DIRECT_MESSAGE_CREATE';
7
+ import { C2C_MESSAGE_CREATE_TYPE } from './message/group/C2C_MESSAGE_CREATE';
8
+ type MAP = {
9
+ 'message.create': GROUP_AT_MESSAGE_CREATE_TYPE | AT_MESSAGE_CREATE_TYPE;
10
+ 'private.message.create': DIRECT_MESSAGE_CREATE_TYPE | C2C_MESSAGE_CREATE_TYPE;
11
+ 'interaction.create': INTERACTION_CREATE_TYPE;
12
+ 'private.interaction.create': undefined;
13
+ 'message.update': undefined;
14
+ 'message.delete': undefined;
15
+ 'message.reaction.add': undefined;
16
+ 'message.reaction.remove': undefined;
17
+ 'message.pin': undefined;
18
+ 'channel.create': undefined;
19
+ 'channel.delete': undefined;
20
+ 'channel.update': undefined;
21
+ 'guild.join': undefined;
22
+ 'guild.exit': undefined;
23
+ 'guild.update': undefined;
24
+ 'member.add': undefined;
25
+ 'member.remove': undefined;
26
+ 'member.ban': undefined;
27
+ 'member.unban': undefined;
28
+ 'private.message.update': undefined;
29
+ 'private.message.delete': undefined;
30
+ 'private.friend.add': undefined;
31
+ 'private.friend.remove': undefined;
32
+ 'private.guild.add': undefined;
33
+ };
34
+ export declare const useValue: <T extends EventKeys>(event: Events[T]) => readonly [MAP[T]];
35
+ export declare const useClient: <T extends EventKeys>(event: Events[T]) => readonly [API, MAP[T]];
36
+ export declare const useMode: <T extends EventKeys>(event: Events[T]) => (mode: "guild" | "group" | "c2c") => boolean;
37
+ export {};
package/lib/hook.js CHANGED
@@ -1,35 +1,37 @@
1
- /**
2
- * 判断当前模式
3
- * @param event
4
- * @returns
5
- */
1
+ import { createEventValue, useClient as useClient$1 } from 'alemonjs';
2
+ import { QQBotAPI } from './sdk/api.js';
3
+
4
+ const useValue = (event) => {
5
+ const value = createEventValue(event);
6
+ return [value];
7
+ };
8
+ const useClient = (event) => {
9
+ const [client] = useClient$1(event, QQBotAPI);
10
+ const value = createEventValue(event);
11
+ return [client, value];
12
+ };
6
13
  const useMode = (event) => {
7
- const tag = event.tag;
14
+ const tag = event._tag;
8
15
  let currentMode = 'group';
9
- // 群at
10
- if (tag == 'GROUP_AT_MESSAGE_CREATE') {
16
+ if (tag === 'GROUP_AT_MESSAGE_CREATE') {
11
17
  currentMode = 'group';
12
18
  }
13
- // 私聊
14
- if (tag == 'C2C_MESSAGE_CREATE') {
15
- currentMode = 'group';
19
+ if (tag === 'C2C_MESSAGE_CREATE') {
20
+ currentMode = 'c2c';
16
21
  }
17
- // 频道私聊
18
- if (tag == 'DIRECT_MESSAGE_CREATE') {
22
+ if (tag === 'DIRECT_MESSAGE_CREATE') {
19
23
  currentMode = 'guild';
20
24
  }
21
- // 频道at
22
- if (tag == 'AT_MESSAGE_CREATE') {
25
+ if (tag === 'AT_MESSAGE_CREATE') {
23
26
  currentMode = 'guild';
24
27
  }
25
- // 频道消息
26
- if (tag == 'MESSAGE_CREATE') {
28
+ if (tag === 'MESSAGE_CREATE') {
27
29
  currentMode = 'guild';
28
30
  }
29
31
  const isMode = (mode) => {
30
- return currentMode == mode;
32
+ return currentMode === mode;
31
33
  };
32
34
  return isMode;
33
35
  };
34
36
 
35
- export { useMode };
37
+ export { useClient, useMode, useValue };
package/lib/index.d.ts CHANGED
@@ -1,7 +1,5 @@
1
- export { platform } from './register.js';
2
- export { useMode } from './hook.js';
3
- export { QQBotAPI as API } from './sdk/api.js';
4
-
5
- declare const _default: () => void;
6
-
7
- export { _default as default };
1
+ export { platform } from './config';
2
+ export * from './hook';
3
+ export { QQBotAPI as API } from './sdk/api';
4
+ declare const _default: () => any;
5
+ export default _default;
package/lib/index.js CHANGED
@@ -1,33 +1,23 @@
1
- import { getConfigValue } from 'alemonjs';
2
- import { start } from './index.group.js';
3
- import { start as start$1 } from './index.guild.js';
4
- import { start as start$2 } from './index.webhook.js';
5
- import { start as start$3 } from './index.websoket.js';
6
- import { platform } from './register.js';
7
- export { useMode } from './hook.js';
1
+ import { definePlatform, getConfigValue } from 'alemonjs';
2
+ import { start } from './index.webhook.js';
3
+ import { start as start$1 } from './index.websoket.js';
4
+ import { platform } from './config.js';
5
+ export { useClient, useMode, useValue } from './hook.js';
8
6
  export { QQBotAPI as API } from './sdk/api.js';
9
7
 
10
- // main
11
- var index = () => {
8
+ const main = () => {
12
9
  let value = getConfigValue();
13
- if (!value)
10
+ if (!value) {
14
11
  value = {};
12
+ }
15
13
  const config = value[platform];
16
- if (config?.mode == 'guild') {
14
+ if (config?.route || config?.port || config?.ws) {
17
15
  start();
18
- return;
19
- }
20
- else if (config?.mode == 'group') {
21
- start$1();
22
- return;
23
- }
24
- else if (config?.route || config?.port || config?.ws) {
25
- start$2();
26
- return;
27
16
  }
28
17
  else {
29
- start$3();
18
+ start$1();
30
19
  }
31
20
  };
21
+ var index = definePlatform({ main });
32
22
 
33
23
  export { index as default, platform };
@@ -0,0 +1 @@
1
+ export declare const start: () => void;
@@ -1,12 +1,13 @@
1
- import { QQBotClient } from './sdk/client.js';
2
- import { getQQBotConfig, register } from './register.js';
1
+ import { QQBotClient } from './sdk/client.webhook.js';
2
+ import { register } from './register.js';
3
+ import { getQQBotConfig } from './config.js';
3
4
 
4
5
  const start = () => {
5
6
  const config = getQQBotConfig();
7
+ const { master_id: _, master_key: __, ...cfgConfig } = config;
6
8
  const client = new QQBotClient({
7
- ...config
9
+ ...cfgConfig
8
10
  });
9
- // 连接
10
11
  client.connect();
11
12
  register(client);
12
13
  };
@@ -0,0 +1 @@
1
+ export declare const start: () => void;
@@ -1,36 +1,44 @@
1
1
  import { QQBotClients } from './sdk/client.websoket.js';
2
- import { getQQBotConfig, register } from './register.js';
2
+ import { register } from './register.js';
3
+ import { getQQBotConfig } from './config.js';
3
4
 
4
5
  const start = () => {
5
6
  const config = getQQBotConfig();
7
+ const notPrivateIntents = [
8
+ 'GUILDS',
9
+ 'GUILD_MEMBERS',
10
+ 'GUILD_MESSAGE_REACTIONS',
11
+ 'DIRECT_MESSAGE',
12
+ 'PUBLIC_GUILD_MESSAGES'
13
+ ];
14
+ const isPrivateIntents = [
15
+ 'GUILDS',
16
+ 'GUILD_MEMBERS',
17
+ 'GUILD_MESSAGES',
18
+ 'GUILD_MESSAGE_REACTIONS',
19
+ 'DIRECT_MESSAGE',
20
+ 'FORUMS_EVENT'
21
+ ];
22
+ const isGroupIntents = ['GROUP_AND_C2C_EVENT'];
23
+ const pubIntents = ['INTERACTION'];
24
+ const intents = [];
25
+ if (config?.is_private) {
26
+ intents.push(...isPrivateIntents, ...pubIntents);
27
+ }
28
+ else {
29
+ intents.push(...notPrivateIntents, ...isGroupIntents, ...pubIntents);
30
+ }
6
31
  const client = new QQBotClients({
7
32
  ...config,
8
- intents: config?.intents ?? config?.is_private
9
- ? [
10
- 'GUILDS', // base
11
- 'GUILD_MEMBERS', // base
12
- 'GUILD_MESSAGES',
13
- 'GUILD_MESSAGE_REACTIONS',
14
- 'DIRECT_MESSAGE',
15
- 'INTERACTION',
16
- 'FORUMS_EVENT'
17
- ]
18
- : [
19
- 'GUILDS', // base
20
- 'GUILD_MEMBERS', // base
21
- 'GUILD_MESSAGE_REACTIONS',
22
- 'DIRECT_MESSAGE',
23
- 'INTERACTION',
24
- 'PUBLIC_GUILD_MESSAGES',
25
- 'GROUP_AND_C2C_EVENT'
26
- ],
33
+ intents: config?.intents || intents,
27
34
  is_private: config?.is_private ?? false,
28
35
  sandbox: config?.sandbox ?? false,
29
36
  shard: config?.shard ?? [0, 1],
30
- mode: config?.mode ?? 'group'
37
+ gatewayURL: config?.gatewayURL,
38
+ base_url_gateway: config?.base_url_gateway,
39
+ base_url_app_access_token: config?.base_url_app_access_token
31
40
  });
32
- // 连接
33
- client.connect(config?.gatewayURL);
41
+ void client.connect(config?.gatewayURL);
34
42
  register(client);
35
43
  };
36
44
 
@@ -0,0 +1,35 @@
1
+ export 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
+ };
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,15 @@
1
+ export 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
+ };
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,15 @@
1
+ export type CHANNEL_DELETE_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
+ };
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,15 @@
1
+ export type CHANNEL_UPDATE_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
+ };
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,29 @@
1
+ export type DIRECT_MESSAGE_CREATE_TYPE = {
2
+ attachments?: {
3
+ content_type: string;
4
+ filename: string;
5
+ height: number;
6
+ id: string;
7
+ size: number;
8
+ url: string;
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
+ direct_message: boolean;
20
+ guild_id: string;
21
+ id: string;
22
+ member: {
23
+ joined_at: string;
24
+ };
25
+ seq: number;
26
+ seq_in_channel: string;
27
+ src_guild_id: string;
28
+ timestamp: string;
29
+ };
@@ -0,0 +1,17 @@
1
+ export type DIRECT_MESSAGE_DELETE_TYPE = {
2
+ message: {
3
+ author: {
4
+ bot: boolean;
5
+ id: string;
6
+ username: string;
7
+ };
8
+ channel_id: string;
9
+ direct_message: boolean;
10
+ guild_id: string;
11
+ id: string;
12
+ src_guild_id: string;
13
+ };
14
+ op_user: {
15
+ id: string;
16
+ };
17
+ };
@@ -0,0 +1 @@
1
+ export type ERROR_TYPE = any;
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,15 @@
1
+ export type GUILD_CREATE_TYPE = {
2
+ description: string;
3
+ icon: string;
4
+ id: string;
5
+ joined_at: string;
6
+ max_members: number;
7
+ member_count: number;
8
+ name: string;
9
+ op_user_id: string;
10
+ owner: boolean;
11
+ owner_id: string;
12
+ union_appid: string;
13
+ union_org_id: string;
14
+ union_world_id: string;
15
+ };
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,15 @@
1
+ export type GUILD_DELETE_TYPE = {
2
+ description: string;
3
+ icon: string;
4
+ id: string;
5
+ joined_at: string;
6
+ max_members: number;
7
+ member_count: number;
8
+ name: string;
9
+ op_user_id: string;
10
+ owner: boolean;
11
+ owner_id: string;
12
+ union_appid: string;
13
+ union_org_id: string;
14
+ union_world_id: string;
15
+ };
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,14 @@
1
+ export type GUILD_MEMBER_ADD_TYPE = {
2
+ guild_id: string;
3
+ joined_at: string;
4
+ nick: string;
5
+ op_user_id: string;
6
+ roles: string[];
7
+ source_type?: string;
8
+ user: {
9
+ avatar: string;
10
+ bot: number;
11
+ id: string;
12
+ username: string;
13
+ };
14
+ };
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,14 @@
1
+ export type GUILD_MEMBER_REMOVE_TYPE = {
2
+ guild_id: string;
3
+ joined_at: string;
4
+ nick: string;
5
+ op_user_id: string;
6
+ roles: string[];
7
+ source_type?: string;
8
+ user: {
9
+ avatar: string;
10
+ bot: number;
11
+ id: string;
12
+ username: string;
13
+ };
14
+ };
@@ -0,0 +1 @@
1
+