@alemonjs/qq-bot 2.1.0-alpha.31 → 2.1.0-alpha.32

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 CHANGED
@@ -24,33 +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
- # 使用 user_key
51
- master_key:
52
- - 'xxx'
53
- # 使用 user_id
54
- master_id:
55
- - 'yyy'
44
+ # 4) 域名代理模式
45
+ # base_url_gateway: https://[your addr]
46
+ # base_url_app_access_token: https://[your addr]
56
47
  ```
package/lib/hook.d.ts CHANGED
@@ -28,7 +28,7 @@ export declare const useValue: <T extends EventKeys>(event: Events[T]) => readon
28
28
  export declare const useClient: <T extends EventKeys>(event: Events[T]) => readonly [{
29
29
  getAuthentication: () => Promise<import("alemonjs").Result<any>>;
30
30
  groupService: (options: import("axios").AxiosRequestConfig<any>) => Promise<import("alemonjs").Result<any>>;
31
- guildServer: (opstion: import("axios").AxiosRequestConfig<any>) => Promise<import("alemonjs").Result<any>>;
31
+ guildServer: (options: import("axios").AxiosRequestConfig<any>) => Promise<import("alemonjs").Result<any>>;
32
32
  gateway: () => Promise<import("alemonjs").Result<any>>;
33
33
  usersOpenMessages: (openid: string, data: import("./sdk/typing").ApiRequestData) => Promise<import("alemonjs").Result<{
34
34
  id: string;
@@ -215,7 +215,7 @@ export declare const useClient: <T extends EventKeys>(event: Events[T]) => reado
215
215
  }) => Promise<import("alemonjs").Result<any>>;
216
216
  channelsThreadsDelete: (channel_id: string, thread_id: string) => Promise<import("alemonjs").Result<any>>;
217
217
  guildApiPermission: (guild_id: string) => Promise<import("alemonjs").Result<any>>;
218
- interactionResponse: (mode: "guild" | "group", interaction_id: string, code?: number) => Promise<import("alemonjs").Result<any>>;
218
+ interactionResponse: (_mode: "group" | "guild", interaction_id: string, code?: number) => Promise<import("alemonjs").Result<any>>;
219
219
  }, MAP[T]];
220
220
  export declare const useMode: <T extends EventKeys>(event: Events[T]) => (mode: "guild" | "group" | "c2c") => boolean;
221
221
  export {};
@@ -22,24 +22,11 @@ const start = () => {
22
22
  const isGroupIntents = ['GROUP_AND_C2C_EVENT'];
23
23
  const pubIntents = ['INTERACTION'];
24
24
  const intents = [];
25
- if (config?.mode === 'guild') {
26
- if (config?.is_private) {
27
- intents.push(...isPrivateIntents, ...pubIntents);
28
- }
29
- else {
30
- intents.push(...notPrivateIntents, ...pubIntents);
31
- }
32
- }
33
- else if (config?.mode === 'group') {
34
- intents.push(...isGroupIntents, ...pubIntents);
25
+ if (config?.is_private) {
26
+ intents.push(...isPrivateIntents, ...pubIntents);
35
27
  }
36
28
  else {
37
- if (config?.is_private) {
38
- intents.push(...isPrivateIntents, ...pubIntents);
39
- }
40
- else {
41
- intents.push(...notPrivateIntents, ...isGroupIntents, ...pubIntents);
42
- }
29
+ intents.push(...notPrivateIntents, ...isGroupIntents, ...pubIntents);
43
30
  }
44
31
  const client = new QQBotClients({
45
32
  ...config,
@@ -47,7 +34,6 @@ const start = () => {
47
34
  is_private: config?.is_private ?? false,
48
35
  sandbox: config?.sandbox ?? false,
49
36
  shard: config?.shard ?? [0, 1],
50
- mode: config?.mode ?? 'group',
51
37
  gatewayURL: config?.gatewayURL,
52
38
  base_url_gateway: config?.base_url_gateway,
53
39
  base_url_app_access_token: config?.base_url_app_access_token
package/lib/sdk/api.d.ts CHANGED
@@ -6,7 +6,7 @@ export declare const API_URL = "https://api.sgroup.qq.com";
6
6
  export declare class QQBotAPI {
7
7
  getAuthentication(): Promise<any>;
8
8
  groupService(options: AxiosRequestConfig): Promise<any>;
9
- guildServer(opstion: AxiosRequestConfig): Promise<any>;
9
+ guildServer(options: AxiosRequestConfig): Promise<any>;
10
10
  gateway(): Promise<any>;
11
11
  usersOpenMessages(openid: string, data: ApiRequestData): Promise<{
12
12
  id: string;
@@ -193,5 +193,5 @@ export declare class QQBotAPI {
193
193
  }): Promise<any>;
194
194
  channelsThreadsDelete(channel_id: string, thread_id: string): Promise<any>;
195
195
  guildApiPermission(guild_id: string): Promise<any>;
196
- interactionResponse(mode: 'group' | 'guild', interaction_id: string, code?: number): Promise<any>;
196
+ interactionResponse(_mode: 'group' | 'guild', interaction_id: string, code?: number): Promise<any>;
197
197
  }
package/lib/sdk/api.js CHANGED
@@ -35,8 +35,9 @@ class QQBotAPI {
35
35
  groupService(options) {
36
36
  const app_id = config.get('app_id');
37
37
  const token = config.get('access_token');
38
+ const sandbox = config.get('sandbox');
38
39
  const service = axios.create({
39
- baseURL: API_URL,
40
+ baseURL: sandbox ? API_URL_SANDBOX : API_URL,
40
41
  timeout: 20000,
41
42
  headers: {
42
43
  'X-Union-Appid': app_id,
@@ -45,21 +46,10 @@ class QQBotAPI {
45
46
  });
46
47
  return createAxiosInstance(service, options);
47
48
  }
48
- guildServer(opstion) {
49
- const app_id = config.get('app_id');
50
- const token = config.get('token');
51
- const sandbox = config.get('sandbox');
52
- const service = axios.create({
53
- baseURL: sandbox ? API_URL_SANDBOX : API_URL,
54
- timeout: 20000,
55
- headers: {
56
- Authorization: `Bot ${app_id}.${token}`
57
- }
58
- });
59
- return createAxiosInstance(service, opstion);
49
+ guildServer(options) {
50
+ return this.groupService(options);
60
51
  }
61
52
  gateway() {
62
- const mode = config.get('mode');
63
53
  const baseUrlGateway = config.get('base_url_gateway');
64
54
  const params = {
65
55
  url: '/gateway'
@@ -67,15 +57,7 @@ class QQBotAPI {
67
57
  if (baseUrlGateway) {
68
58
  params.baseURL = baseUrlGateway;
69
59
  }
70
- if (mode === 'group') {
71
- return this.groupService(params);
72
- }
73
- else if (mode === 'guild') {
74
- return this.guildServer(params);
75
- }
76
- else {
77
- return this.groupService(params);
78
- }
60
+ return this.groupService(params);
79
61
  }
80
62
  usersOpenMessages(openid, data) {
81
63
  const db = {
@@ -526,25 +508,14 @@ class QQBotAPI {
526
508
  url: `/guilds/${guild_id}/api_permission`
527
509
  });
528
510
  }
529
- interactionResponse(mode, interaction_id, code) {
530
- if (mode === 'group') {
531
- return this.groupService({
532
- method: 'PUT',
533
- url: `/interactions/${interaction_id}`,
534
- data: {
535
- code: code || 0
536
- }
537
- });
538
- }
539
- else {
540
- return this.guildServer({
541
- method: 'PUT',
542
- url: `/interactions/${interaction_id}`,
543
- data: {
544
- code: code || 0
545
- }
546
- });
547
- }
511
+ interactionResponse(_mode, interaction_id, code) {
512
+ return this.groupService({
513
+ method: 'PUT',
514
+ url: `/interactions/${interaction_id}`,
515
+ data: {
516
+ code: code || 0
517
+ }
518
+ });
548
519
  }
549
520
  }
550
521
 
@@ -63,7 +63,6 @@ export interface Options {
63
63
  intents?: IntentsEnum[];
64
64
  is_private?: boolean;
65
65
  sandbox?: boolean;
66
- mode?: 'guild' | 'group' | '';
67
66
  route?: string;
68
67
  port?: string;
69
68
  ws?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alemonjs/qq-bot",
3
- "version": "2.1.0-alpha.31",
3
+ "version": "2.1.0-alpha.32",
4
4
  "description": "阿柠檬qq-bot平台连接",
5
5
  "author": "lemonade",
6
6
  "license": "MIT",