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.
- package/dist/assets/index-2tNhvoZy.css +1 -0
- package/dist/assets/index-_Kz1yWe8.js +19 -0
- package/dist/index.html +2 -2
- package/lib/adapter.js +6 -8
- package/lib/adapters/dingtalk/index.d.ts +4 -4
- package/lib/adapters/dingtalk/index.js +59 -48
- package/lib/adapters/dingtalk/utils.js +5 -20
- package/lib/adapters/icqq/index.d.ts +4 -3
- package/lib/adapters/icqq/index.js +130 -101
- package/lib/adapters/icqq/utils.js +2 -2
- package/lib/adapters/qq/index.d.ts +4 -4
- package/lib/adapters/qq/index.js +66 -51
- package/lib/adapters/qq/utils.js +5 -20
- package/lib/adapters/wechat/index.d.ts +3 -3
- package/lib/adapters/wechat/index.js +66 -51
- package/lib/adapters/wechat/utils.js +5 -20
- package/lib/bin.js +6 -6
- package/lib/db.js +10 -10
- package/lib/onebot.d.ts +12 -12
- package/lib/onebot.js +25 -16
- package/lib/server/app.d.ts +2 -2
- package/lib/server/app.js +71 -70
- package/lib/server/router.d.ts +1 -1
- package/lib/server/router.js +5 -5
- package/lib/service/V11/action/common.d.ts +1 -0
- package/lib/service/V11/action/common.js +24 -24
- package/lib/service/V11/action/friend.js +16 -8
- package/lib/service/V11/action/group.js +52 -22
- package/lib/service/V11/index.js +86 -50
- package/lib/service/V12/action/common.d.ts +3 -3
- package/lib/service/V12/action/common.js +33 -31
- package/lib/service/V12/action/friend.js +8 -4
- package/lib/service/V12/action/group.js +50 -20
- package/lib/service/V12/action/guild.js +110 -35
- package/lib/service/V12/index.d.ts +18 -18
- package/lib/service/V12/index.js +189 -147
- package/lib/service/shareMusicCustom.js +14 -9
- package/lib/service.js +29 -27
- package/lib/utils.d.ts +1 -1
- package/lib/utils.js +44 -32
- package/package.json +3 -3
- package/dist/assets/index-VSQZ6fYD.js +0 -3
- 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,
|
|
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(
|
|
22
|
-
const msg_id = this.getStrByInt(
|
|
23
|
-
return this.adapter.call(this.oneBot.uin,
|
|
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
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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,
|
|
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[
|
|
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,
|
|
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,
|
|
70
|
-
csrf_token: this.adapter.call(this.oneBot.uin,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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(
|
|
13
|
-
const uid = this.getStrByInt(
|
|
14
|
-
return this.adapter.call(this.oneBot.uin,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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(
|
|
13
|
-
const gid = this.getStrByInt(
|
|
14
|
-
return this.adapter.call(this.oneBot.uin,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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 =
|
|
131
|
-
return this.adapter.call(this.oneBot.uin,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
189
|
+
return this.adapter.call(this.oneBot.uin, "V11", "getGroupMemberInfo", [group_id, user_id]);
|
|
160
190
|
}
|
|
161
191
|
}
|
|
162
192
|
exports.GroupAction = GroupAction;
|