onebots 0.4.46 → 0.4.48

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 (43) hide show
  1. package/dist/assets/index-2tNhvoZy.css +1 -0
  2. package/dist/assets/index-_Kz1yWe8.js +19 -0
  3. package/dist/index.html +2 -2
  4. package/lib/adapter.js +6 -8
  5. package/lib/adapters/dingtalk/index.d.ts +4 -4
  6. package/lib/adapters/dingtalk/index.js +59 -48
  7. package/lib/adapters/dingtalk/utils.js +5 -20
  8. package/lib/adapters/icqq/index.d.ts +4 -3
  9. package/lib/adapters/icqq/index.js +130 -101
  10. package/lib/adapters/icqq/utils.js +2 -2
  11. package/lib/adapters/qq/index.d.ts +4 -4
  12. package/lib/adapters/qq/index.js +66 -51
  13. package/lib/adapters/qq/utils.js +5 -20
  14. package/lib/adapters/wechat/index.d.ts +3 -3
  15. package/lib/adapters/wechat/index.js +66 -51
  16. package/lib/adapters/wechat/utils.js +5 -20
  17. package/lib/bin.js +6 -6
  18. package/lib/db.js +10 -10
  19. package/lib/onebot.d.ts +12 -12
  20. package/lib/onebot.js +25 -16
  21. package/lib/server/app.d.ts +2 -2
  22. package/lib/server/app.js +71 -70
  23. package/lib/server/router.d.ts +1 -1
  24. package/lib/server/router.js +5 -5
  25. package/lib/service/V11/action/common.d.ts +1 -0
  26. package/lib/service/V11/action/common.js +24 -24
  27. package/lib/service/V11/action/friend.js +16 -8
  28. package/lib/service/V11/action/group.js +52 -22
  29. package/lib/service/V11/index.js +86 -50
  30. package/lib/service/V12/action/common.d.ts +3 -3
  31. package/lib/service/V12/action/common.js +33 -31
  32. package/lib/service/V12/action/friend.js +8 -4
  33. package/lib/service/V12/action/group.js +50 -20
  34. package/lib/service/V12/action/guild.js +110 -35
  35. package/lib/service/V12/index.d.ts +18 -18
  36. package/lib/service/V12/index.js +189 -147
  37. package/lib/service/shareMusicCustom.js +14 -9
  38. package/lib/service.js +29 -27
  39. package/lib/utils.d.ts +1 -1
  40. package/lib/utils.js +44 -32
  41. package/package.json +3 -3
  42. package/dist/assets/index-VSQZ6fYD.js +0 -3
  43. package/dist/assets/index-m-TylXnm.css +0 -1
@@ -9,7 +9,7 @@ class CommonAction {
9
9
  getLoginInfo() {
10
10
  return {
11
11
  user_id: this.oneBot.uin,
12
- nickname: this.adapter.getSelfInfo(this.oneBot.uin, 'V11').nickname
12
+ nickname: this.adapter.getSelfInfo(this.oneBot.uin, "V11").nickname,
13
13
  };
14
14
  }
15
15
  /**
@@ -18,9 +18,12 @@ class CommonAction {
18
18
  */
19
19
  async deleteMsg(message_id) {
20
20
  if (message_id == 0)
21
- throw new Error('getMsg: message_id[0] is invalid');
22
- const msg_id = this.getStrByInt('message_id', message_id);
23
- return this.adapter.call(this.oneBot.uin, 'V11', 'deleteMessage', [this.oneBot.uin, msg_id]);
21
+ throw new Error("getMsg: message_id[0] is invalid");
22
+ const msg_id = this.getStrByInt("message_id", message_id);
23
+ return this.adapter.call(this.oneBot.uin, "V11", "deleteMessage", [
24
+ this.oneBot.uin,
25
+ msg_id,
26
+ ]);
24
27
  }
25
28
  /**
26
29
  * 获取消息
@@ -28,15 +31,9 @@ class CommonAction {
28
31
  * @param onebot_id {number}
29
32
  */
30
33
  async getMsg(message_id) {
31
- if (message_id == 0)
32
- throw new Error('getMsg: message_id[0] is invalid');
33
- let msg_entry = this.db.find('messages', (message) => {
34
- return message.id === message_id;
35
- });
36
- if (!msg_entry)
37
- throw new Error(`getMsg: can not find msg[${message_id}] in db`);
38
- let msg = await this.adapter.call(this.oneBot.uin, 'V11', 'getMsg', [msg_entry.base64_id]);
39
- msg.message_id = String(message_id); // nonebot v11 要求 message_id 是 number 类型
34
+ const msg_id = this.getStrByInt("message_id", message_id);
35
+ let msg = await this.adapter.call(this.oneBot.uin, "V11", "getMessage", [msg_id]);
36
+ msg.message_id = message_id; // nonebot v11 要求 message_id 是 number 类型
40
37
  msg["real_id"] = msg.message_id; // nonebot 的reply类型会检测real_id是否存在,虽然它从未使用
41
38
  return msg;
42
39
  }
@@ -45,20 +42,20 @@ class CommonAction {
45
42
  * @param id {string} 合并id
46
43
  */
47
44
  getForwardMsg(id) {
48
- return this.adapter.call(this.oneBot.uin, 'V11', 'getForwardMsg', [id]);
45
+ return this.adapter.call(this.oneBot.uin, "V11", "getForwardMsg", [id]);
49
46
  }
50
47
  /**
51
48
  * 获取 Cookies
52
49
  * @param domain {string} 域名
53
50
  */
54
51
  getCookies(domain) {
55
- return this.adapter.call['getCookies']([domain]);
52
+ return this.adapter.call["getCookies"]([domain]);
56
53
  }
57
54
  /**
58
55
  * 获取 CSRF Token
59
56
  */
60
57
  getCsrfToken() {
61
- return this.adapter.call(this.oneBot.uin, 'V11', 'getCsrfToken');
58
+ return this.adapter.call(this.oneBot.uin, "V11", "getCsrfToken");
62
59
  }
63
60
  /**
64
61
  * 获取 QQ 相关接口凭证
@@ -66,8 +63,8 @@ class CommonAction {
66
63
  */
67
64
  getCredentials(domain) {
68
65
  return {
69
- cookies: this.adapter.call(this.oneBot.uin, 'V11', 'getCookies', [domain]),
70
- csrf_token: this.adapter.call(this.oneBot.uin, 'V11', 'getCsrfToken')
66
+ cookies: this.adapter.call(this.oneBot.uin, "V11", "getCookies", [domain]),
67
+ csrf_token: this.adapter.call(this.oneBot.uin, "V11", "getCsrfToken"),
71
68
  };
72
69
  }
73
70
  /**
@@ -89,21 +86,24 @@ class CommonAction {
89
86
  }
90
87
  getStatus() {
91
88
  return {
92
- online: this.adapter.getSelfInfo(this.oneBot.uin, 'V11').status === onebot_1.OneBotStatus.Online,
93
- good: this.oneBot.status === onebot_1.OneBotStatus.Good
89
+ online: this.adapter.getSelfInfo(this.oneBot.uin, "V11").status === onebot_1.OneBotStatus.Online,
90
+ good: this.oneBot.status === onebot_1.OneBotStatus.Good,
94
91
  };
95
92
  }
96
93
  async submitSlider(ticket) {
97
- return this.adapter.call(this.oneBot.uin, 'V11', 'callLogin', ['submitSlider', ticket]);
94
+ return this.adapter.call(this.oneBot.uin, "V11", "callLogin", ["submitSlider", ticket]);
98
95
  }
99
96
  async submitSmsCode(code) {
100
- return this.adapter.call(this.oneBot.uin, 'V11', 'callLogin', ['submitSmsCode', code]);
97
+ return this.adapter.call(this.oneBot.uin, "V11", "callLogin", ["submitSmsCode", code]);
98
+ }
99
+ callApi(name, args) {
100
+ return this.adapter.call(this.oneBot.uin, "V11", "callApi", [name, args]);
101
101
  }
102
102
  login(password) {
103
- return this.adapter.call(this.oneBot.uin, 'V11', 'callLogin', ['login', password]);
103
+ return this.adapter.call(this.oneBot.uin, "V11", "callLogin", ["login", password]);
104
104
  }
105
105
  logout(keepalive) {
106
- return this.adapter.call(this.oneBot.uin, 'V11', 'logout', [keepalive]);
106
+ return this.adapter.call(this.oneBot.uin, "V11", "logout", [keepalive]);
107
107
  }
108
108
  }
109
109
  exports.CommonAction = CommonAction;
@@ -9,15 +9,19 @@ class FriendAction {
9
9
  * @param message_id {number} 引用的消息ID
10
10
  */
11
11
  async sendPrivateMsg(user_id, message, message_id) {
12
- const msg_id = message_id ? this.getStrByInt('message_id', message_id) : undefined;
13
- const uid = this.getStrByInt('user_id', user_id);
14
- return this.adapter.call(this.oneBot.uin, 'V11', 'sendPrivateMessage', [uid, message, msg_id]);
12
+ const msg_id = message_id ? this.getStrByInt("message_id", message_id) : undefined;
13
+ const uid = this.getStrByInt("user_id", user_id);
14
+ return this.adapter.call(this.oneBot.uin, "V11", "sendPrivateMessage", [
15
+ uid,
16
+ message,
17
+ msg_id,
18
+ ]);
15
19
  }
16
20
  /**
17
21
  * 获取好友列表
18
22
  */
19
23
  async getFriendList() {
20
- return this.adapter.call(this.oneBot.uin, 'V11', 'getFriendList');
24
+ return this.adapter.call(this.oneBot.uin, "V11", "getFriendList");
21
25
  }
22
26
  /**
23
27
  * 处理好友添加请求
@@ -25,15 +29,19 @@ class FriendAction {
25
29
  * @param approve {boolean} 是否同意
26
30
  * @param remark {string} 添加后的备注
27
31
  */
28
- async setFriendAddRequest(flag, approve = true, remark = '') {
29
- return this.adapter.call(this.oneBot.uin, 'V11', 'setFriendAddRequest', [flag, approve, remark]);
32
+ async setFriendAddRequest(flag, approve = true, remark = "") {
33
+ return this.adapter.call(this.oneBot.uin, "V11", "setFriendAddRequest", [
34
+ flag,
35
+ approve,
36
+ remark,
37
+ ]);
30
38
  }
31
39
  /**
32
40
  * 获取陌生人信息
33
41
  * @param user_id {number} 用户id
34
42
  */
35
43
  async getStrangerInfo(user_id) {
36
- return this.adapter.call(this.oneBot.uin, 'V11', 'getStrangerInfo', [user_id]);
44
+ return this.adapter.call(this.oneBot.uin, "V11", "getStrangerInfo", [user_id]);
37
45
  }
38
46
  /**
39
47
  * 为指定用户点赞
@@ -41,7 +49,7 @@ class FriendAction {
41
49
  * @param times 点赞次数
42
50
  */
43
51
  async sendLike(user_id, times) {
44
- return this.adapter.call(this.oneBot.uin, 'V11', 'sendLike', [user_id, times]);
52
+ return this.adapter.call(this.oneBot.uin, "V11", "sendLike", [user_id, times]);
45
53
  }
46
54
  }
47
55
  exports.FriendAction = FriendAction;
@@ -9,9 +9,13 @@ class GroupAction {
9
9
  * @param message_id {number} 引用的消息ID
10
10
  */
11
11
  async sendGroupMsg(group_id, message, message_id) {
12
- const msg_id = message_id ? this.getStrByInt('message_id', message_id) : undefined;
13
- const gid = this.getStrByInt('group_id', group_id);
14
- return this.adapter.call(this.oneBot.uin, 'V11', 'sendGroupMessage', [gid, message, msg_id]);
12
+ const msg_id = message_id ? this.getStrByInt("message_id", message_id) : undefined;
13
+ const gid = this.getStrByInt("group_id", group_id);
14
+ return this.adapter.call(this.oneBot.uin, "V11", "sendGroupMessage", [
15
+ gid,
16
+ message,
17
+ msg_id,
18
+ ]);
15
19
  }
16
20
  /**
17
21
  * 群组踢人
@@ -20,7 +24,11 @@ class GroupAction {
20
24
  * @param reject_add_request {boolean} 是否禁止此人加群请求
21
25
  */
22
26
  setGroupKick(group_id, user_id, reject_add_request) {
23
- return this.adapter.call(this.oneBot.uin, 'V11', 'setGroupKick', [group_id, user_id, reject_add_request]);
27
+ return this.adapter.call(this.oneBot.uin, "V11", "setGroupKick", [
28
+ group_id,
29
+ user_id,
30
+ reject_add_request,
31
+ ]);
24
32
  }
25
33
  /**
26
34
  * 群禁言指定人
@@ -29,7 +37,11 @@ class GroupAction {
29
37
  * @param duration {number} 禁言时长(单位:秒)
30
38
  */
31
39
  setGroupBan(group_id, user_id, duration = 1800) {
32
- return this.adapter.call(this.oneBot.uin, 'V11', 'setGroupBan', [group_id, user_id, duration]);
40
+ return this.adapter.call(this.oneBot.uin, "V11", "setGroupBan", [
41
+ group_id,
42
+ user_id,
43
+ duration,
44
+ ]);
33
45
  }
34
46
  /**
35
47
  * 群禁言匿名者
@@ -38,7 +50,11 @@ class GroupAction {
38
50
  * @param duration {number} 禁言时长(单位:秒)
39
51
  */
40
52
  setGroupAnonymousBan(group_id, flag, duration = 1800) {
41
- return this.adapter.call(this.oneBot.uin, 'V11', 'setGroupAnonymousBan', [group_id, flag, duration]);
53
+ return this.adapter.call(this.oneBot.uin, "V11", "setGroupAnonymousBan", [
54
+ group_id,
55
+ flag,
56
+ duration,
57
+ ]);
42
58
  }
43
59
  /**
44
60
  * 群全体禁言
@@ -46,7 +62,7 @@ class GroupAction {
46
62
  * @param enable {boolean} 是否禁言
47
63
  */
48
64
  setGroupWholeBan(group_id, enable) {
49
- return this.adapter.call(this.oneBot.uin, 'V11', 'setGroupWholeBan', [group_id, enable]);
65
+ return this.adapter.call(this.oneBot.uin, "V11", "setGroupWholeBan", [group_id, enable]);
50
66
  }
51
67
  /**
52
68
  * 群匿名聊天
@@ -54,7 +70,7 @@ class GroupAction {
54
70
  * @param enable {boolean} 是否开启
55
71
  */
56
72
  setGroupAnonymous(group_id, enable) {
57
- return this.adapter.call(this.oneBot.uin, 'V11', 'setGroupAnonymous', [group_id, enable]);
73
+ return this.adapter.call(this.oneBot.uin, "V11", "setGroupAnonymous", [group_id, enable]);
58
74
  }
59
75
  /**
60
76
  * 设置群管
@@ -63,7 +79,11 @@ class GroupAction {
63
79
  * @param enable {boolean} true 设为管理,false 取消管理
64
80
  */
65
81
  setGroupAdmin(group_id, user_id, enable) {
66
- return this.adapter.call(this.oneBot.uin, 'V11', 'setGroupAdmin', [group_id, user_id, enable]);
82
+ return this.adapter.call(this.oneBot.uin, "V11", "setGroupAdmin", [
83
+ group_id,
84
+ user_id,
85
+ enable,
86
+ ]);
67
87
  }
68
88
  /**
69
89
  * 设置群成员名片(成员备注)
@@ -72,28 +92,28 @@ class GroupAction {
72
92
  * @param card {string} 名片信息,不传或传空串则为 删除名片
73
93
  */
74
94
  setGroupCard(group_id, user_id, card) {
75
- return this.adapter.call(this.oneBot.uin, 'V11', 'setGroupCard', [group_id, user_id, card]);
95
+ return this.adapter.call(this.oneBot.uin, "V11", "setGroupCard", [group_id, user_id, card]);
76
96
  }
77
97
  /**
78
98
  * 设置群精华
79
99
  * @param message_id 消息id
80
100
  */
81
101
  setEssenceMessage(message_id) {
82
- return this.adapter.call(this.oneBot.uin, 'V11', 'setEssenceMessage', [message_id]);
102
+ return this.adapter.call(this.oneBot.uin, "V11", "setEssenceMessage", [message_id]);
83
103
  }
84
104
  /**
85
105
  * 群打卡
86
106
  * @param group_id 群id
87
107
  */
88
108
  sendGroupSign(group_id) {
89
- return this.adapter.call(this.oneBot.uin, 'V11', 'sendGroupSign', [group_id]);
109
+ return this.adapter.call(this.oneBot.uin, "V11", "sendGroupSign", [group_id]);
90
110
  }
91
111
  /**
92
112
  * 移除群精华
93
113
  * @param message_id
94
114
  */
95
115
  deleteEssenceMessage(message_id) {
96
- return this.adapter.call(this.oneBot.uin, 'V11', 'removeEssenceMessage', [message_id]);
116
+ return this.adapter.call(this.oneBot.uin, "V11", "removeEssenceMessage", [message_id]);
97
117
  }
98
118
  /**
99
119
  * 设置群名
@@ -101,14 +121,14 @@ class GroupAction {
101
121
  * @param name {string} 新群名
102
122
  */
103
123
  setGroupName(group_id, name) {
104
- return this.adapter.call(this.oneBot.uin, 'V11', 'setGroupName', [group_id, name]);
124
+ return this.adapter.call(this.oneBot.uin, "V11", "setGroupName", [group_id, name]);
105
125
  }
106
126
  /**
107
127
  * 退出指定群聊
108
128
  * @param group_id {number} 群id
109
129
  */
110
130
  setGroupLeave(group_id) {
111
- return this.adapter.call(this.oneBot.uin, 'V11', 'setGroupLeave', [group_id]);
131
+ return this.adapter.call(this.oneBot.uin, "V11", "setGroupLeave", [group_id]);
112
132
  }
113
133
  /**
114
134
  * 设置群成员头衔
@@ -118,7 +138,12 @@ class GroupAction {
118
138
  * @param duration {number} 持有时长 不传则永久
119
139
  */
120
140
  setGroupSpecialTitle(group_id, user_id, special_title, duration = -1) {
121
- return this.adapter.call(this.oneBot.uin, 'V11', 'setGroupSpecialTitle', [group_id, user_id, special_title, duration]);
141
+ return this.adapter.call(this.oneBot.uin, "V11", "setGroupSpecialTitle", [
142
+ group_id,
143
+ user_id,
144
+ special_title,
145
+ duration,
146
+ ]);
122
147
  }
123
148
  /**
124
149
  * 处理加群请求
@@ -127,28 +152,33 @@ class GroupAction {
127
152
  * @param reason {string} 拒绝理由,approve为false时有效(默认为空)
128
153
  * @param block {boolean} 拒绝时是否加入黑名单,(默认:false)
129
154
  */
130
- setGroupAddRequest(flag, approve = true, reason = '', block = false) {
131
- return this.adapter.call(this.oneBot.uin, 'V11', 'setGroupAddRequest', [flag, approve, reason, block]);
155
+ setGroupAddRequest(flag, approve = true, reason = "", block = false) {
156
+ return this.adapter.call(this.oneBot.uin, "V11", "setGroupAddRequest", [
157
+ flag,
158
+ approve,
159
+ reason,
160
+ block,
161
+ ]);
132
162
  }
133
163
  /**
134
164
  * 获取群列表
135
165
  */
136
166
  async getGroupList() {
137
- return this.adapter.call(this.oneBot.uin, 'V11', 'getGroupList');
167
+ return this.adapter.call(this.oneBot.uin, "V11", "getGroupList");
138
168
  }
139
169
  /**
140
170
  * 获取指定群信息
141
171
  * @param group_id
142
172
  */
143
173
  getGroupInfo(group_id) {
144
- return this.adapter.call(this.oneBot.uin, 'V11', 'getGroupInfo', [group_id]);
174
+ return this.adapter.call(this.oneBot.uin, "V11", "getGroupInfo", [group_id]);
145
175
  }
146
176
  /**
147
177
  * 获取群成员列表
148
178
  * @param group_id
149
179
  */
150
180
  async getGroupMemberList(group_id) {
151
- return this.adapter.call(this.oneBot.uin, 'V11', 'getGroupMemberList', [group_id]);
181
+ return this.adapter.call(this.oneBot.uin, "V11", "getGroupMemberList", [group_id]);
152
182
  }
153
183
  /**
154
184
  * 获取指定群成员信息
@@ -156,7 +186,7 @@ class GroupAction {
156
186
  * @param user_id
157
187
  */
158
188
  getGroupMemberInfo(group_id, user_id) {
159
- return this.adapter.call(this.oneBot.uin, 'V11', 'getGroupMemberInfo', [group_id, user_id]);
189
+ return this.adapter.call(this.oneBot.uin, "V11", "getGroupMemberInfo", [group_id, user_id]);
160
190
  }
161
191
  }
162
192
  exports.GroupAction = GroupAction;