onebots 0.4.22 → 0.4.25

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 (84) hide show
  1. package/README.md +129 -72
  2. package/lib/adapter.d.ts +55 -0
  3. package/lib/adapter.js +60 -0
  4. package/lib/adapters/icqq/index.d.ts +36 -0
  5. package/lib/adapters/icqq/index.js +300 -0
  6. package/lib/adapters/icqq/utils.d.ts +6 -0
  7. package/lib/adapters/icqq/utils.js +26 -0
  8. package/lib/adapters/qq/bot.d.ts +24 -0
  9. package/lib/adapters/qq/bot.js +20 -0
  10. package/lib/adapters/qq/constans.d.ts +69 -0
  11. package/lib/adapters/qq/constans.js +128 -0
  12. package/lib/adapters/qq/elements.d.ts +125 -0
  13. package/lib/adapters/qq/elements.js +8 -0
  14. package/lib/adapters/qq/entries/channel.d.ts +17 -0
  15. package/lib/adapters/qq/entries/channel.js +2 -0
  16. package/lib/adapters/qq/entries/friend.d.ts +8 -0
  17. package/lib/adapters/qq/entries/friend.js +2 -0
  18. package/lib/adapters/qq/entries/group.d.ts +6 -0
  19. package/lib/adapters/qq/entries/group.js +2 -0
  20. package/lib/adapters/qq/entries/groupMember.d.ts +7 -0
  21. package/lib/adapters/qq/entries/groupMember.js +2 -0
  22. package/lib/adapters/qq/entries/guild.d.ts +21 -0
  23. package/lib/adapters/qq/entries/guild.js +2 -0
  24. package/lib/adapters/qq/entries/guildMember.d.ts +9 -0
  25. package/lib/adapters/qq/entries/guildMember.js +2 -0
  26. package/lib/adapters/qq/entries/user.d.ts +9 -0
  27. package/lib/adapters/qq/entries/user.js +2 -0
  28. package/lib/adapters/qq/event.d.ts +28 -0
  29. package/lib/adapters/qq/event.js +24 -0
  30. package/lib/adapters/qq/index.d.ts +35 -0
  31. package/lib/adapters/qq/index.js +170 -0
  32. package/lib/adapters/qq/message.d.ts +83 -0
  33. package/lib/adapters/qq/message.js +272 -0
  34. package/lib/adapters/qq/qqBot.d.ts +122 -0
  35. package/lib/adapters/qq/qqBot.js +438 -0
  36. package/lib/adapters/qq/sessionManager.d.ts +33 -0
  37. package/lib/adapters/qq/sessionManager.js +257 -0
  38. package/lib/adapters/qq/types.d.ts +45 -0
  39. package/lib/adapters/qq/types.js +2 -0
  40. package/lib/adapters/qq/utils.d.ts +12 -0
  41. package/lib/adapters/qq/utils.js +86 -0
  42. package/lib/bin.js +17 -2
  43. package/lib/config.sample.yaml +11 -5
  44. package/lib/db.js +6 -6
  45. package/lib/index.d.ts +5 -5
  46. package/lib/onebot.d.ts +30 -22
  47. package/lib/onebot.js +42 -165
  48. package/lib/server/app.d.ts +22 -12
  49. package/lib/server/app.js +97 -71
  50. package/lib/service/V11/action/common.d.ts +11 -12
  51. package/lib/service/V11/action/common.js +19 -65
  52. package/lib/service/V11/action/friend.d.ts +6 -14
  53. package/lib/service/V11/action/friend.js +6 -16
  54. package/lib/service/V11/action/group.d.ts +20 -23
  55. package/lib/service/V11/action/group.js +20 -30
  56. package/lib/service/V11/action/index.d.ts +1 -1
  57. package/lib/service/V11/db_entities.d.ts +1 -1
  58. package/lib/service/V11/db_entities.js +1 -1
  59. package/lib/service/V11/db_sqlite.d.ts +1 -1
  60. package/lib/service/V11/db_sqlite.js +5 -7
  61. package/lib/service/V11/index.d.ts +46 -14
  62. package/lib/service/V11/index.js +163 -134
  63. package/lib/service/V12/action/common.d.ts +3 -67
  64. package/lib/service/V12/action/common.js +9 -63
  65. package/lib/service/V12/action/friend.d.ts +4 -10
  66. package/lib/service/V12/action/friend.js +4 -12
  67. package/lib/service/V12/action/group.d.ts +19 -21
  68. package/lib/service/V12/action/group.js +19 -27
  69. package/lib/service/V12/action/guild.d.ts +40 -13
  70. package/lib/service/V12/action/guild.js +99 -11
  71. package/lib/service/V12/action/index.d.ts +1 -1
  72. package/lib/service/V12/index.d.ts +37 -13
  73. package/lib/service/V12/index.js +63 -94
  74. package/lib/service.d.ts +7 -2
  75. package/lib/service.js +5 -1
  76. package/lib/types.d.ts +2 -2
  77. package/lib/types.js +3 -3
  78. package/lib/utils.d.ts +7 -4
  79. package/lib/utils.js +18 -1
  80. package/package.json +74 -70
  81. package/lib/service/V11/utils.d.ts +0 -9
  82. package/lib/service/V11/utils.js +0 -31
  83. package/lib/service/V12/utils.d.ts +0 -8
  84. package/lib/service/V12/utils.js +0 -47
@@ -6,72 +6,11 @@ export declare class CommonAction {
6
6
  * 撤回消息
7
7
  * @param message_id {string} 消息id
8
8
  */
9
- deleteMsg(this: V12, message_id: string): Promise<boolean>;
9
+ deleteMsg(this: V12, message_id: string): Promise<any>;
10
10
  /**
11
11
  * 获取消息详情
12
12
  */ F: any;
13
- getMsg(this: V12, message_id: string): Promise<{
14
- message: V12.SegmentElem<keyof V12.SegmentMap>[];
15
- message_type: "group";
16
- sub_type: "normal" | "anonymous";
17
- group_id: number;
18
- group_name: string;
19
- anonymous: import("icqq").Anonymous;
20
- block: boolean;
21
- atme: boolean;
22
- atall: boolean;
23
- sender: {
24
- user_id: number;
25
- nickname: string;
26
- sub_id: string;
27
- card: string;
28
- sex: import("icqq").Gender;
29
- age: number;
30
- area: string;
31
- level: number;
32
- role: import("icqq").GroupRole;
33
- title: string;
34
- };
35
- user_id: number;
36
- post_type: "message";
37
- time: number;
38
- raw_message: string;
39
- font: string;
40
- message_id: string;
41
- seq: number;
42
- rand: number;
43
- source?: import("icqq").Quotable;
44
- pktnum: number;
45
- index: number;
46
- div: number;
47
- cqCode: string;
48
- } | {
49
- message: V12.SegmentElem<keyof V12.SegmentMap>[];
50
- message_type: "private";
51
- sub_type: "self" | "other" | "group" | "friend";
52
- from_id: number;
53
- to_id: number;
54
- auto_reply: boolean;
55
- sender: {
56
- user_id: number;
57
- nickname: string;
58
- group_id: number;
59
- discuss_id: number;
60
- };
61
- user_id: number;
62
- post_type: "message";
63
- time: number;
64
- raw_message: string;
65
- font: string;
66
- message_id: string;
67
- seq: number;
68
- rand: number;
69
- source?: import("icqq").Quotable;
70
- pktnum: number;
71
- index: number;
72
- div: number;
73
- cqCode: string;
74
- }>;
13
+ getMsg(this: V12, message_id: string): Promise<any>;
75
14
  getSelfInfo(this: V12): {
76
15
  user_id: string;
77
16
  platform: string;
@@ -82,7 +21,7 @@ export declare class CommonAction {
82
21
  * 获取 Cookies
83
22
  * @param domain {string} 域名
84
23
  */
85
- getCookies(this: V12, domain: string): string;
24
+ getCookies(this: V12, domain: string): Promise<string>;
86
25
  getStatus(this: V12): {
87
26
  good: boolean;
88
27
  bots: {
@@ -97,12 +36,9 @@ export declare class CommonAction {
97
36
  version: any;
98
37
  onebot_version: string;
99
38
  };
100
- callLogin(this: V12, func: string, ...args: any[]): Promise<unknown>;
101
39
  submitSlider(this: V12, ticket: string): Promise<any>;
102
40
  submitSmsCode(this: V12, code: string): Promise<any>;
103
- sendSmsCode(this: V12): Promise<any>;
104
41
  login(this: V12, password?: string): Promise<unknown>;
105
- logout(this: V12, keepalive?: boolean): Promise<unknown>;
106
42
  getSupportedActions(this: V12): string[];
107
43
  uploadFile(this: V12, type: 'url' | 'path' | 'data', name: string, url?: string, path?: string, data?: string, sha256?: string, headers?: Record<string, any>): string;
108
44
  uploadFileFragmented(this: V12, stage: 'prepare' | 'transfer' | 'finish', name?: string, total_size?: number, file_id?: string, offset?: number, data?: string, sha256?: string): string | true;
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CommonAction = void 0;
4
- const V12_1 = require("../../../service/V12");
5
- const icqq_1 = require("icqq");
6
4
  const utils_1 = require("../../../utils");
7
5
  const onebot_1 = require("../../../onebot");
8
6
  const utils_2 = require("../../../utils");
@@ -15,22 +13,19 @@ class CommonAction {
15
13
  * @param message_id {string} 消息id
16
14
  */
17
15
  deleteMsg(message_id) {
18
- return this.client.deleteMsg(message_id);
16
+ return this.adapter.call(this.oneBot.uin, 'V12', 'deleteMsg', [message_id]);
19
17
  }
20
18
  async getMsg(message_id) {
21
- const message = await this.client.getMsg(message_id);
19
+ const message = await this.adapter.call(this.oneBot.uin, 'V12', 'getMsg', [message_id]);
22
20
  if (!message)
23
21
  throw new Error('消息不存在');
24
- return {
25
- ...message,
26
- message: V12_1.V12.toSegment(message.message)
27
- };
22
+ return message;
28
23
  }
29
24
  getSelfInfo() {
30
25
  return {
31
26
  user_id: this.oneBot.uin + '',
32
27
  platform: 'qq',
33
- nickname: this.client.nickname,
28
+ nickname: this.adapter.getSelfInfo(this.oneBot.uin, 'V12').nickname,
34
29
  user_displayname: ''
35
30
  };
36
31
  }
@@ -38,8 +33,8 @@ class CommonAction {
38
33
  * 获取 Cookies
39
34
  * @param domain {string} 域名
40
35
  */
41
- getCookies(domain) {
42
- return this.client.cookies[domain];
36
+ async getCookies(domain) {
37
+ return await this.adapter.call(this.oneBot.uin, 'V12', 'getCookies', [domain]);
43
38
  }
44
39
  getStatus() {
45
40
  return {
@@ -47,7 +42,7 @@ class CommonAction {
47
42
  bots: [
48
43
  {
49
44
  self: this.action.getSelfInfo.apply(this),
50
- online: this.client.status === icqq_1.OnlineStatus.Online,
45
+ online: this.oneBot.status === onebot_1.OneBotStatus.Online,
51
46
  }
52
47
  ]
53
48
  };
@@ -68,63 +63,14 @@ class CommonAction {
68
63
  onebot_version: '12'
69
64
  };
70
65
  }
71
- callLogin(func, ...args) {
72
- return new Promise(async (resolve) => {
73
- const receiveResult = (event) => {
74
- this.client.offTrap('system.login.qrcode');
75
- this.client.offTrap('system.login.device');
76
- this.client.offTrap('system.login.slider');
77
- this.client.offTrap('system.login.error');
78
- resolve(event);
79
- };
80
- this.client.trap('system.login.qrcode', receiveResult);
81
- this.client.trap('system.login.device', receiveResult);
82
- this.client.trap('system.login.slider', receiveResult);
83
- this.client.trap('system.login.error', receiveResult);
84
- this.client.trapOnce('system.online', receiveResult);
85
- try {
86
- await this.client[func](...args);
87
- }
88
- catch (reason) {
89
- receiveResult(reason);
90
- }
91
- });
92
- }
93
66
  async submitSlider(ticket) {
94
- return this.action.callLogin.apply(this, ['submitSlider', ticket]);
67
+ return this.adapter.call(this.oneBot.uin, 'V12', 'callLogin', ['submitSlider', ticket]);
95
68
  }
96
69
  async submitSmsCode(code) {
97
70
  return this.action.callLogin.apply(this, ['submitSmsCode', code]);
98
71
  }
99
- sendSmsCode() {
100
- return new Promise(resolve => {
101
- const receiveResult = (e) => {
102
- const callback = (data) => {
103
- this.client.offTrap('internal.verbose');
104
- this.client.offTrap('system.login.error');
105
- resolve(data);
106
- };
107
- if ((typeof e === 'string' && e.includes('已发送')) || typeof e !== 'string') {
108
- callback(e);
109
- }
110
- };
111
- this.client.trap('internal.verbose', receiveResult);
112
- this.client.trap('system.login.error', receiveResult);
113
- this.client.sendSmsCode();
114
- });
115
- }
116
72
  login(password) {
117
- return this.action.callLogin.apply(this, ['login', password]);
118
- }
119
- logout(keepalive) {
120
- return new Promise(async (resolve) => {
121
- const receiveResult = (e) => {
122
- this.client.offTrap('system.offline');
123
- resolve(e);
124
- };
125
- this.client.on('system.offline', receiveResult);
126
- await this.client.logout(keepalive);
127
- });
73
+ return this.adapter.call(this.oneBot.uin, 'V12', 'callLogin', ['login', password]);
128
74
  }
129
75
  getSupportedActions() {
130
76
  return [...new Set((0, utils_2.getProperties)(this.action))].filter(key => {
@@ -1,24 +1,18 @@
1
1
  import { V12 } from "../index";
2
2
  export declare class FriendAction {
3
- getUserInfo(this: V12, user_id: number): Promise<{
4
- user_id: number;
5
- nickname: string;
6
- sex: import("icqq").Gender;
7
- age: number;
8
- area: string;
9
- }>;
10
- getFriendList(this: V12): Map<number, import("icqq").FriendInfo>;
3
+ getUserInfo(this: V12, user_id: number): Promise<any>;
4
+ getFriendList(this: V12): Promise<any>;
11
5
  /**
12
6
  * 发送私聊消息
13
7
  * @param user_id {number} 用户id
14
8
  * @param message {import('onebots/lib/service/v12').Sendable} 消息
15
9
  * @param source {import('onebots/lib/service/v12').SegmentElem<'reply'>} 引用内容
16
10
  */
17
- sendPrivateMsg(this: V12, user_id: number, message: V12.Sendable, source?: V12.SegmentElem<'reply'>): Promise<import("icqq").MessageRet>;
11
+ sendPrivateMsg(this: V12, user_id: number, message: V12.Sendable, source?: V12.SegmentElem<'reply'>): Promise<any>;
18
12
  /**
19
13
  * 为指定用户点赞
20
14
  * @param user_id {number} 用户id
21
15
  * @param times 点赞次数
22
16
  */
23
- sendUserLike(this: V12, user_id: number, times?: number): Promise<boolean>;
17
+ sendUserLike(this: V12, user_id: number, times?: number): Promise<void>;
24
18
  }
@@ -1,13 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FriendAction = void 0;
4
- const utils_1 = require("../../../service/V12/utils");
5
4
  class FriendAction {
6
5
  getUserInfo(user_id) {
7
- return this.client.getStrangerInfo(user_id);
6
+ return this.adapter.call(this.oneBot.uin, 'V12', 'getUserInfo', [user_id]);
8
7
  }
9
8
  getFriendList() {
10
- return this.client.getFriendList();
9
+ return this.adapter.call(this.oneBot.uin, 'V12', 'getFriendList');
11
10
  }
12
11
  /**
13
12
  * 发送私聊消息
@@ -16,14 +15,7 @@ class FriendAction {
16
15
  * @param source {import('onebots/lib/service/v12').SegmentElem<'reply'>} 引用内容
17
16
  */
18
17
  async sendPrivateMsg(user_id, message, source) {
19
- let { element, quote, music, share } = await utils_1.processMessage.apply(this, [message, source]);
20
- if (music)
21
- await this.client.pickFriend(user_id).shareMusic(music.data.platform, music.data.id);
22
- if (share)
23
- await this.client.pickFriend(user_id).shareUrl(music.data);
24
- if (element.length) {
25
- return await this.client.sendPrivateMsg(user_id, element, quote ? await this.client.getMsg(quote.data.message_id) : undefined);
26
- }
18
+ return this.adapter.call(this.oneBot.uin, 'V12', 'sendPrivateMessage', [user_id, message, source]);
27
19
  }
28
20
  /**
29
21
  * 为指定用户点赞
@@ -31,7 +23,7 @@ class FriendAction {
31
23
  * @param times 点赞次数
32
24
  */
33
25
  async sendUserLike(user_id, times) {
34
- return this.client.sendLike(user_id, times);
26
+ throw new Error('不支持的API');
35
27
  }
36
28
  }
37
29
  exports.FriendAction = FriendAction;
@@ -6,82 +6,80 @@ export declare class GroupAction {
6
6
  * @param message {import('icqq/lib/service').Sendable} 消息
7
7
  * @param source {import('onebots/lib/service/v12').SegmentElem<'reply'>} 引用内容
8
8
  */
9
- sendGroupMsg(this: V12, group_id: number, message: V12.Sendable, source?: V12.SegmentElem<'reply'>): Promise<import("icqq").MessageRet>;
9
+ sendGroupMsg(this: V12, group_id: number, message: V12.Sendable, source?: V12.SegmentElem<'reply'>): Promise<any>;
10
10
  /**
11
11
  * 群组踢人
12
12
  * @param group_id {number} 群id
13
13
  * @param user_id {number} 成员id
14
14
  * @param reject_add_request {boolean} 是否禁止此人加群请求
15
15
  */
16
- setGroupKick(this: V12, group_id: number, user_id: number, reject_add_request?: boolean): Promise<boolean>;
16
+ setGroupKick(this: V12, group_id: number, user_id: number, reject_add_request?: boolean): Promise<any>;
17
17
  /**
18
18
  * 设置群精华
19
19
  * @param message_id
20
20
  */
21
- setEssenceMessage(this: V12, message_id: string): Promise<string>;
21
+ setEssenceMessage(this: V12, message_id: string): Promise<any>;
22
22
  /**
23
23
  * 移除群精华
24
24
  * @param message_id
25
25
  */
26
- deleteEssenceMessage(this: V12, message_id: string): Promise<string>;
26
+ deleteEssenceMessage(this: V12, message_id: string): Promise<any>;
27
27
  /**
28
28
  * 群打卡
29
29
  * @param group_id 群id
30
30
  */
31
- sendGroupSign(this: V12, group_id: number): Promise<{
32
- result: number;
33
- }>;
31
+ sendGroupSign(this: V12, group_id: number): Promise<any>;
34
32
  /**
35
33
  * 群禁言指定人
36
34
  * @param group_id {number} 群id
37
35
  * @param user_id {number} 成员id
38
36
  * @param duration {number} 禁言时长(单位:秒)
39
37
  */
40
- setGroupBan(this: V12, group_id: number, user_id: number, duration?: number): Promise<void>;
38
+ setGroupBan(this: V12, group_id: number, user_id: number, duration?: number): Promise<any>;
41
39
  /**
42
40
  * 群禁言匿名者
43
41
  * @param group_id {number} 群id
44
42
  * @param flag {string} 匿名者flag
45
43
  * @param duration {number} 禁言时长(单位:秒)
46
44
  */
47
- setGroupAnonymousBan(this: V12, group_id: number, flag: string, duration?: number): Promise<void>;
45
+ setGroupAnonymousBan(this: V12, group_id: number, flag: string, duration?: number): Promise<any>;
48
46
  /**
49
47
  * 群全体禁言
50
48
  * @param group_id {number} 群id
51
49
  * @param enable {boolean} 是否禁言
52
50
  */
53
- setGroupWholeBan(this: V12, group_id: number, enable?: boolean): Promise<boolean>;
51
+ setGroupWholeBan(this: V12, group_id: number, enable?: boolean): Promise<any>;
54
52
  /**
55
53
  * 群匿名聊天
56
54
  * @param group_id {number} 群id
57
55
  * @param enable {boolean} 是否开启
58
56
  */
59
- setGroupAnonymous(this: V12, group_id: number, enable?: boolean): Promise<boolean>;
57
+ setGroupAnonymous(this: V12, group_id: number, enable?: boolean): Promise<any>;
60
58
  /**
61
59
  * 设置群管
62
60
  * @param group_id {number} 群id
63
61
  * @param user_id {number} 成员id
64
62
  * @param enable {boolean} true 设为管理,false 取消管理
65
63
  */
66
- setGroupAdmin(this: V12, group_id: number, user_id: number, enable?: boolean): Promise<boolean>;
64
+ setGroupAdmin(this: V12, group_id: number, user_id: number, enable?: boolean): Promise<any>;
67
65
  /**
68
66
  * 设置群成员名片(成员备注)
69
67
  * @param group_id {number} 群id
70
68
  * @param user_id {number} 成员id
71
69
  * @param card {string} 名片信息,不传或传空串则为 删除名片
72
70
  */
73
- setGroupCard(this: V12, group_id: number, user_id: number, card?: string): Promise<boolean>;
71
+ setGroupCard(this: V12, group_id: number, user_id: number, card?: string): Promise<any>;
74
72
  /**
75
73
  * 设置群名
76
74
  * @param group_id {number} 群id
77
75
  * @param name {string} 新群名
78
76
  */
79
- setGroupName(this: V12, group_id: number, name: string): Promise<boolean>;
77
+ setGroupName(this: V12, group_id: number, name: string): Promise<any>;
80
78
  /**
81
79
  * 退出指定群聊
82
80
  * @param group_id {number} 群id
83
81
  */
84
- leaveGroup(this: V12, group_id: number): Promise<boolean>;
82
+ leaveGroup(this: V12, group_id: number): Promise<any>;
85
83
  /**
86
84
  * 设置群成员头衔
87
85
  * @param group_id {number} 群id
@@ -89,7 +87,7 @@ export declare class GroupAction {
89
87
  * @param special_title {string} 头衔
90
88
  * @param duration {number} 持有时长 不传则永久
91
89
  */
92
- setGroupSpecialTitle(this: V12, group_id: number, user_id: number, special_title: string, duration?: number): Promise<boolean>;
90
+ setGroupSpecialTitle(this: V12, group_id: number, user_id: number, special_title: string, duration?: number): Promise<any>;
93
91
  /**
94
92
  * 处理加群请求
95
93
  * @param flag {string} 加群flag
@@ -97,25 +95,25 @@ export declare class GroupAction {
97
95
  * @param reason {string} 拒绝理由,approve为false时有效(默认为空)
98
96
  * @param block {boolean} 拒绝时是否加入黑名单,(默认:false)
99
97
  */
100
- setGroupAddRequest(this: V12, flag: string, approve?: boolean, reason?: string, block?: boolean): Promise<boolean>;
98
+ setGroupAddRequest(this: V12, flag: string, approve?: boolean, reason?: string, block?: boolean): Promise<any>;
101
99
  /**
102
100
  * 获取群列表
103
101
  */
104
- getGroupList(this: V12): Promise<Map<number, import("icqq").GroupInfo>>;
102
+ getGroupList(this: V12): Promise<any>;
105
103
  /**
106
104
  * 获取指定群信息
107
105
  * @param group_id
108
106
  */
109
- getGroupInfo(this: V12, group_id: number): Promise<import("icqq").GroupInfo>;
107
+ getGroupInfo(this: V12, group_id: number): Promise<any>;
110
108
  /**
111
109
  * 获取群成员列表
112
110
  * @param group_id
113
111
  */
114
- getGroupMemberList(this: V12, group_id: number): Promise<Map<number, import("icqq").MemberInfo>>;
112
+ getGroupMemberList(this: V12, group_id: number): Promise<any>;
115
113
  /**
116
114
  * 获取指定群成员信息
117
115
  * @param group_id
118
116
  * @param user_id
119
117
  */
120
- getGroupMemberInfo(this: V12, group_id: number, user_id: number): Promise<import("icqq").MemberInfo>;
118
+ getGroupMemberInfo(this: V12, group_id: number, user_id: number): Promise<any>;
121
119
  }
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GroupAction = void 0;
4
- const utils_1 = require("../../../service/V12/utils");
5
4
  class GroupAction {
6
5
  /**
7
6
  * 发送群聊消息
@@ -10,14 +9,7 @@ class GroupAction {
10
9
  * @param source {import('onebots/lib/service/v12').SegmentElem<'reply'>} 引用内容
11
10
  */
12
11
  async sendGroupMsg(group_id, message, source) {
13
- let { element, quote, music, share } = await utils_1.processMessage.apply(this, [message, source]);
14
- if (music)
15
- await this.client.pickGroup(group_id).shareMusic(music.data.platform, music.data.id);
16
- if (share)
17
- await this.client.pickGroup(group_id).shareUrl(music.data);
18
- if (element.length) {
19
- return await this.client.sendGroupMsg(group_id, element, quote ? await this.client.getMsg(quote.data.message_id) : undefined);
20
- }
12
+ return this.adapter.call(this.oneBot.uin, 'V12', 'sendGroupMessage', [group_id, message, source]);
21
13
  }
22
14
  /**
23
15
  * 群组踢人
@@ -26,28 +18,28 @@ class GroupAction {
26
18
  * @param reject_add_request {boolean} 是否禁止此人加群请求
27
19
  */
28
20
  setGroupKick(group_id, user_id, reject_add_request) {
29
- return this.client.setGroupKick(group_id, user_id, reject_add_request);
21
+ return this.adapter.call(this.oneBot.uin, 'V12', 'setGroupKick', [group_id, user_id, reject_add_request]);
30
22
  }
31
23
  /**
32
24
  * 设置群精华
33
25
  * @param message_id
34
26
  */
35
27
  setEssenceMessage(message_id) {
36
- return this.client.setEssenceMessage(message_id);
28
+ return this.adapter.call(this.oneBot.uin, 'V12', 'setEssenceMessage', [message_id]);
37
29
  }
38
30
  /**
39
31
  * 移除群精华
40
32
  * @param message_id
41
33
  */
42
34
  deleteEssenceMessage(message_id) {
43
- return this.client.removeEssenceMessage(message_id);
35
+ return this.adapter.call(this.oneBot.uin, 'V12', 'deleteEssenceMessage', [message_id]);
44
36
  }
45
37
  /**
46
38
  * 群打卡
47
39
  * @param group_id 群id
48
40
  */
49
41
  sendGroupSign(group_id) {
50
- return this.client.pickGroup(group_id).sign();
42
+ return this.adapter.call(this.oneBot.uin, 'V12', 'sendGroupSign', [group_id]);
51
43
  }
52
44
  /**
53
45
  * 群禁言指定人
@@ -56,7 +48,7 @@ class GroupAction {
56
48
  * @param duration {number} 禁言时长(单位:秒)
57
49
  */
58
50
  setGroupBan(group_id, user_id, duration = 1800) {
59
- return this.client.setGroupBan(group_id, user_id, duration);
51
+ return this.adapter.call(this.oneBot.uin, 'V12', 'setGroupBan', [group_id, user_id, duration]);
60
52
  }
61
53
  /**
62
54
  * 群禁言匿名者
@@ -65,7 +57,7 @@ class GroupAction {
65
57
  * @param duration {number} 禁言时长(单位:秒)
66
58
  */
67
59
  setGroupAnonymousBan(group_id, flag, duration = 1800) {
68
- return this.client.setGroupAnonymousBan(group_id, flag, duration);
60
+ return this.adapter.call(this.oneBot.uin, 'V12', 'setGroupAnonymousBan', [group_id, flag, duration]);
69
61
  }
70
62
  /**
71
63
  * 群全体禁言
@@ -73,7 +65,7 @@ class GroupAction {
73
65
  * @param enable {boolean} 是否禁言
74
66
  */
75
67
  setGroupWholeBan(group_id, enable) {
76
- return this.client.setGroupWholeBan(group_id, enable);
68
+ return this.adapter.call(this.oneBot.uin, 'V12', 'setGroupWholeBan', [group_id, enable]);
77
69
  }
78
70
  /**
79
71
  * 群匿名聊天
@@ -81,7 +73,7 @@ class GroupAction {
81
73
  * @param enable {boolean} 是否开启
82
74
  */
83
75
  setGroupAnonymous(group_id, enable) {
84
- return this.client.setGroupAnonymous(group_id, enable);
76
+ return this.adapter.call(this.oneBot.uin, 'V12', 'setGroupAnonymous', [group_id, enable]);
85
77
  }
86
78
  /**
87
79
  * 设置群管
@@ -90,7 +82,7 @@ class GroupAction {
90
82
  * @param enable {boolean} true 设为管理,false 取消管理
91
83
  */
92
84
  setGroupAdmin(group_id, user_id, enable) {
93
- return this.client.setGroupAdmin(group_id, user_id, enable);
85
+ return this.adapter.call(this.oneBot.uin, 'V12', 'setGroupAdmin', [group_id, user_id, enable]);
94
86
  }
95
87
  /**
96
88
  * 设置群成员名片(成员备注)
@@ -99,7 +91,7 @@ class GroupAction {
99
91
  * @param card {string} 名片信息,不传或传空串则为 删除名片
100
92
  */
101
93
  setGroupCard(group_id, user_id, card) {
102
- return this.client.setGroupCard(group_id, user_id, card);
94
+ return this.adapter.call(this.oneBot.uin, 'V12', 'setGroupCard', [group_id, user_id, card]);
103
95
  }
104
96
  /**
105
97
  * 设置群名
@@ -107,14 +99,14 @@ class GroupAction {
107
99
  * @param name {string} 新群名
108
100
  */
109
101
  setGroupName(group_id, name) {
110
- return this.client.setGroupName(group_id, name);
102
+ return this.adapter.call(this.oneBot.uin, 'V12', 'setGroupName', [group_id, name]);
111
103
  }
112
104
  /**
113
105
  * 退出指定群聊
114
106
  * @param group_id {number} 群id
115
107
  */
116
108
  leaveGroup(group_id) {
117
- return this.client.setGroupLeave(group_id);
109
+ return this.adapter.call(this.oneBot.uin, 'V12', 'leaveGroup', [group_id]);
118
110
  }
119
111
  /**
120
112
  * 设置群成员头衔
@@ -124,7 +116,7 @@ class GroupAction {
124
116
  * @param duration {number} 持有时长 不传则永久
125
117
  */
126
118
  setGroupSpecialTitle(group_id, user_id, special_title, duration = -1) {
127
- return this.client.setGroupSpecialTitle(group_id, user_id, special_title, duration);
119
+ return this.adapter.call(this.oneBot.uin, 'V12', 'setGroupSpecialTitle', [group_id, user_id, special_title, duration]);
128
120
  }
129
121
  /**
130
122
  * 处理加群请求
@@ -134,27 +126,27 @@ class GroupAction {
134
126
  * @param block {boolean} 拒绝时是否加入黑名单,(默认:false)
135
127
  */
136
128
  setGroupAddRequest(flag, approve = true, reason = '', block = false) {
137
- return this.client.setGroupAddRequest(flag, approve, reason, block);
129
+ return this.adapter.call(this.oneBot.uin, 'V12', 'setGroupAddRequest', [flag, approve, reason, block]);
138
130
  }
139
131
  /**
140
132
  * 获取群列表
141
133
  */
142
134
  async getGroupList() {
143
- return this.client.getGroupList();
135
+ return this.adapter.call(this.oneBot.uin, 'V12', 'getGroupList');
144
136
  }
145
137
  /**
146
138
  * 获取指定群信息
147
139
  * @param group_id
148
140
  */
149
141
  getGroupInfo(group_id) {
150
- return this.client.getGroupInfo(group_id);
142
+ return this.adapter.call(this.oneBot.uin, 'V12', 'getGroupInfo', [group_id]);
151
143
  }
152
144
  /**
153
145
  * 获取群成员列表
154
146
  * @param group_id
155
147
  */
156
148
  async getGroupMemberList(group_id) {
157
- return this.client.getGroupMemberList(group_id);
149
+ return this.adapter.call(this.oneBot.uin, 'V12', 'getGroupMemberList', [group_id]);
158
150
  }
159
151
  /**
160
152
  * 获取指定群成员信息
@@ -162,7 +154,7 @@ class GroupAction {
162
154
  * @param user_id
163
155
  */
164
156
  getGroupMemberInfo(group_id, user_id) {
165
- return this.client.getGroupMemberInfo(group_id, user_id);
157
+ return this.adapter.call(this.oneBot.uin, 'V12', 'getGroupMemberInfo', [group_id, user_id]);
166
158
  }
167
159
  }
168
160
  exports.GroupAction = GroupAction;
@@ -1,21 +1,48 @@
1
1
  import { V12 } from "../../../service/V12";
2
+ import { ApiBaseInfo, UpdatePermissionParams } from "../../../adapters/qq/types";
3
+ import { Channel } from "../../../adapters/qq/entries/channel";
4
+ import { Guild } from "../../../adapters/qq/entries/guild";
2
5
  export declare class GuildAction {
3
- getGuildList(this: V12): {
4
- guild_id: string;
5
- guild_name: string;
6
- }[];
7
- getChannelList(this: V12, guild_id: string): {
8
- guild_id: string;
6
+ getGuildSelfInfo(this: V12): Promise<any>;
7
+ getChannelPermissionOfRole(this: V12, channel_id: string, role_id: string): Promise<any>;
8
+ setChannelAnnounce(this: V12, guild_id: string, channel_id: string, message_id: string): Promise<any>;
9
+ updateChannelPermissionOfRole(this: V12, channel_id: string, role_id: string, permission: UpdatePermissionParams): Promise<any>;
10
+ getChannelMemberPermission(this: V12, channel_id: string, member_id: string): Promise<any>;
11
+ updateChannelMemberPermission(this: V12, channel_id: string, member_id: string, permission: UpdatePermissionParams): Promise<any>;
12
+ getChannelPins(this: V12, channel_id: string): Promise<string[]>;
13
+ pinChannelMessage(this: V12, channel_id: string, message_id: string): Promise<any>;
14
+ unPinChannelMessage(this: V12, channel_id: string, message_id: string): Promise<any>;
15
+ createChannel(this: V12, guild_id: string, channelInfo: Omit<Channel.Info, 'id'>): Promise<Channel.Info>;
16
+ updateChannel(this: V12, { channel_id, ...updateInfo }: {
9
17
  channel_id: string;
10
- channel_name: string;
11
- channel_type: import("icqq").ChannelType;
12
- }[];
13
- getGuildMemberList(this: V12, guild_id: string): never[] | Promise<import("icqq").GuildMember[]>;
18
+ } & Partial<Pick<Channel.Info, 'name' | 'position' | 'parent_id' | 'private_type' | 'speak_permission'>>): Promise<Channel.Info>;
19
+ deleteChannel(this: V12, channel_id: string): Promise<any>;
20
+ getGuildRoles(this: V12, guild_id: string): Promise<any>;
21
+ creatGuildRole(this: V12, guild_id: string, role: Pick<Guild.Role, 'name' | 'color' | 'hoist'>): Promise<Guild.Role>;
22
+ updateGuildRole(this: V12, guild_id: string, { id, ...role }: Pick<Guild.Role, 'id' | 'name' | 'color' | 'hoist'>): Promise<any>;
23
+ deleteGuildRole(this: V12, role_id: string): Promise<any>;
24
+ getGuildAccessApis(this: V12, guild_id: string): Promise<any>;
25
+ applyGuildAccess(this: V12, guild_id: string, channel_id: string, apiInfo: ApiBaseInfo, desc?: string): Promise<any>;
26
+ unMuteGuild(this: V12, guild_id: string): Promise<any>;
27
+ muteGuild(this: V12, guild_id: string, seconds: number, end_time?: number): Promise<any>;
28
+ unMuteGuildMembers(this: V12, guild_id: string, member_ids: string[]): Promise<any>;
29
+ muteGuildMembers(this: V12, guild_id: string, member_ids: string[], seconds: number, end_time?: number): Promise<any>;
30
+ addGuildMemberRoles(this: V12, guild_id: string, channel_id: string, member_id: string, role_id: string): Promise<any>;
31
+ removeGuildMemberRoles(this: V12, guild_id: string, channel_id: string, member_id: string, role_id: string): Promise<any>;
32
+ kickGuildMember(this: V12, guild_id: string, member_id: string, clean?: -1 | 0 | 3 | 7 | 15 | 30, blacklist?: boolean): Promise<any>;
33
+ unMuteGuildMember(this: V12, guild_id: string, member_id: string): Promise<any>;
34
+ muteGuildMember(this: V12, guild_id: string, member_id: string, seconds: number, end_time?: number): Promise<any>;
35
+ getGuildList(this: V12): Promise<any>;
36
+ getGuildInfo(this: V12, guild_id: string): Promise<any>;
37
+ getChannelList(this: V12, guild_id: string): Promise<any>;
38
+ getChannelInfo(this: V12, channel_id: string): Promise<any>;
39
+ getGuildMemberList(this: V12, guild_id: string): Promise<any>;
14
40
  /**
15
- * 发送群聊消息
16
- * @param guild_id {number} 频道id
41
+ * 发送频道消息
17
42
  * @param channel_id {string} 子频道id
18
43
  * @param message {import('icqq/lib/service').Sendable} 消息
19
44
  */
20
- sendGuildMsg(this: V12, guild_id: string, channel_id: string, message: V12.Sendable): Promise<import("icqq/lib/internal").GuildMessageRet>;
45
+ sendGuildMsg(this: V12, channel_id: string, message: V12.Sendable): Promise<any>;
46
+ createDirectSession(this: V12, guild_id: string, user_id: string): Promise<any>;
47
+ sendDirectMsg(this: V12, guild_id: string, message: V12.Sendable): Promise<any>;
21
48
  }