@kotori-bot/kotori-plugin-adapter-onebot 2.0.0 → 2.1.1

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/lib/api.d.ts CHANGED
@@ -1,77 +1,114 @@
1
- import { Api, MessageRaw } from 'kotori-bot';
1
+ import { Api, type Message } from 'kotori-bot';
2
+ import type OnebotAdapter from './adapter';
2
3
  export declare class OnebotApi extends Api {
3
- sendPrivateMsg(message: MessageRaw, userId: number): void;
4
+ private factory;
5
+ readonly adapter: OnebotAdapter;
6
+ constructor(adapter: OnebotAdapter);
7
+ getSupportedEvents(): ReturnType<Api['getSupportedEvents']>;
8
+ sendPrivateMsg(message: Message, userId: string): Promise<{
9
+ messageId: string;
10
+ time: number;
11
+ }>;
4
12
  /**
5
13
  * @description: 发送私聊消息
6
- * @param {Msg} message 要发送的内容
7
- * @param {groupId} groupId 群号
8
- * @return {void}
14
+ * @param message 要发送的内容
15
+ * @param groupId 群号
9
16
  */
10
- sendGroupMsg(message: MessageRaw, groupId: number): void;
17
+ sendGroupMsg(message: Message, groupId: string): Promise<{
18
+ messageId: string;
19
+ time: number;
20
+ }>;
11
21
  /**
12
22
  * @description: 撤回消息
13
- * @param {number} messageId 消息id
14
- * @return {void}
23
+ * @param messageId 消息id
15
24
  */
16
- deleteMsg(messageId: number): void;
25
+ deleteMsg(messageId: string): void;
26
+ getSelfInfo(): Promise<{
27
+ userId: string;
28
+ username: string;
29
+ userDisplayname: string;
30
+ }>;
31
+ getUserInfo(userId: string): Promise<{
32
+ userId: string;
33
+ username: string;
34
+ userDisplayname: string;
35
+ userRemark: string;
36
+ }>;
37
+ getFriendList(): Promise<{
38
+ userId: string;
39
+ username: string;
40
+ userDisplayname: string;
41
+ userRemark: string;
42
+ }[]>;
43
+ getGroupInfo(groupId: string): Promise<{
44
+ groupId: string;
45
+ groupName: string;
46
+ }>;
47
+ getGroupList(): Promise<{
48
+ groupId: string;
49
+ groupName: string;
50
+ }[]>;
51
+ getGroupMemberInfo(groupId: string, userId: string): Promise<{
52
+ userId: string;
53
+ username: string;
54
+ userDisplayname: string;
55
+ }>;
56
+ getGroupMemberList(groupId: string): Promise<{
57
+ userId: string;
58
+ username: string;
59
+ userDisplayname: string;
60
+ }[]>;
17
61
  /**
18
62
  * @description: 设置群名
19
- * @param {number} groupId 群号
20
- * @param {string} groupName 新群名
21
- * @return {void}
63
+ * @param groupId 群号
64
+ * @param groupName 新群名
22
65
  */
23
- setGroupName(groupId: number, groupName: string): void;
66
+ setGroupName(groupId: string, groupName: string): void;
67
+ /**
68
+ * @description: 退出群组
69
+ * @param groupId 群号
70
+ */
71
+ leaveGroup(groupId: string): void;
24
72
  /**
25
73
  * @description: 设置群头像
26
- * @param {number} groupId 群号
27
- * @param {string} image 图片路径
28
- * @return {void}
74
+ * @param groupId 群号
75
+ * @param image 图片路径
29
76
  */
30
- setGroupAvatar(groupId: number, image: string): void;
77
+ setGroupAvatar(groupId: string, image: string): void;
31
78
  /**
32
79
  * @description: 设置群管理员
33
- * @param {number} groupId 群号
34
- * @param {number} userId 要设置的管理员的QQ号
35
- * @param {boolean} enable true为设置,false取消,默认true
36
- * @return {void}
80
+ * @param groupId 群号
81
+ * @param userId 要设置的管理员的QQ号
82
+ * @param enable true为设置,false取消,默认true
37
83
  */
38
- setGroupAdmin(groupId: number, userId: number, enable?: boolean): void;
84
+ setGroupAdmin(groupId: string, userId: string, enable?: boolean): void;
39
85
  /**
40
86
  * @description: 设置群名片(群备注)
41
- * @param {number} groupId 群号
42
- * @param {number} userId 要设置的QQ号
43
- * @param {string} card 群名片内容,不填或空字符串表示删除群名片
44
- * @return {void}
87
+ * @param groupId 群号
88
+ * @param userId 要设置的QQ号
89
+ * @param card 群名片内容,不填或空字符串表示删除群名片
45
90
  */
46
- setGroupCard(groupId: number, userId: number, card: string): void;
91
+ setGroupCard(groupId: string, userId: string, card: string): void;
47
92
  /**
48
93
  * @description: 群禁言
49
- * @param {number} groupId 群号
50
- * @param {number} userId 要禁言的QQ号,不填则为群禁言
51
- * @param {number} time 禁言时长,单位秒,0表示取消禁言
52
- * @return {void}
94
+ * @param groupId 群号
95
+ * @param userId 要禁言的QQ号,不填则为群禁言
96
+ * @param time 禁言时长,单位秒,0表示取消禁言
53
97
  */
54
- setGroupBan(groupId: number, userId?: number, time?: number): void;
98
+ setGroupBan(groupId: string, userId?: string, time?: number): void;
99
+ setGroupWholeBan(groupId: string, enable?: boolean): void;
55
100
  /**
56
101
  * @description: 发送群公告
57
- * @param {number} groupId 群号
58
- * @param {string} content 公告内容
59
- * @param {string} image 图片路径(可选)
60
- * @return {void}
102
+ * @param groupId 群号
103
+ * @param content 公告内容
104
+ * @param image 图片路径(可选)
61
105
  */
62
- sendGroupNotice(groupId: number, content: string, image?: string): void;
106
+ sendGroupNotice(groupId: string, content: string, image?: string): void;
63
107
  /**
64
108
  * @description: 群组踢人
65
- * @param {number} groupId 群号
66
- * @param {number} userId 要踢的QQ号
67
- * @return {void}
68
- */
69
- setGroupKick(groupId: number, userId: number): void;
70
- /**
71
- * @description: 退出群组
72
- * @param {number} groupId 群号
73
- * @return {void}
109
+ * @param groupId 群号
110
+ * @param userId 要踢的QQ号
74
111
  */
75
- setGroupLeave(groupId: number): void;
112
+ setGroupKick(groupId: string, userId: string): void;
76
113
  }
77
114
  export default OnebotApi;
package/lib/api.js CHANGED
@@ -1,14 +1,12 @@
1
-
2
1
  /**
3
- * @Package @kotori-bot/kotori-plugin-adapter-onebot
4
- * @Version 2.0.0
5
- * @Author Hotaru <biyuehuya@gmail.com>
6
- * @Copyright 2024 Hotaru. All rights reserved.
7
- * @License GPL-3.0
8
- * @Link https://github.com/kotorijs/kotori
9
- * @Date 2024/6/7 21:36:06
10
- */
11
-
2
+ * @Package @kotori-bot/kotori-plugin-adapter-onebot
3
+ * @Version 2.1.1
4
+ * @Author Hotaru <me@hotaru.icu>
5
+ * @Copyright 2024-2025 Hotaru. All rights reserved.
6
+ * @License BAN-ZHINESE-USING
7
+ * @Link https://github.com/kotorijs/kotori
8
+ * @Date 16:14:08
9
+ */
12
10
  "use strict";
13
11
  var __defProp = Object.defineProperty;
14
12
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -35,110 +33,264 @@ __export(api_exports, {
35
33
  module.exports = __toCommonJS(api_exports);
36
34
  var import_kotori_bot = require("kotori-bot");
37
35
  class OnebotApi extends import_kotori_bot.Api {
36
+ factory(callback) {
37
+ return new Promise((resolve, reject) => {
38
+ const timer = setTimeout(() => {
39
+ reject(new import_kotori_bot.KotoriError("data response timeout"));
40
+ this.adapter.ctx.off("literal_onebot_raw_data", handler);
41
+ }, 10 * 1e3);
42
+ const handler = (data) => {
43
+ const result = callback(data);
44
+ if (!result) return;
45
+ this.adapter.ctx.off("literal_onebot_raw_data", handler);
46
+ clearTimeout(timer);
47
+ resolve(result);
48
+ };
49
+ this.adapter.ctx.on("literal_onebot_raw_data", handler);
50
+ });
51
+ }
52
+ adapter;
53
+ constructor(adapter) {
54
+ super(adapter);
55
+ this.adapter = adapter;
56
+ }
57
+ getSupportedEvents() {
58
+ return [
59
+ "on_message",
60
+ "on_message_delete",
61
+ "on_request",
62
+ "on_group_increase",
63
+ "on_group_decrease",
64
+ "on_group_ban",
65
+ "on_group_admin",
66
+ "onebot_poke"
67
+ ];
68
+ }
38
69
  sendPrivateMsg(message, userId) {
39
- this.adapter.status.lastMsgTime = /* @__PURE__ */ new Date();
40
- this.adapter.status.sentMsg += 1;
41
- this.adapter.send("send_private_msg", { user_id: userId, message, auto_escape: false });
70
+ this.adapter.send("send_private_msg", {
71
+ user_id: Number(userId),
72
+ message: this.adapter.elements.decode(message),
73
+ auto_escape: false
74
+ });
75
+ return this.factory((data) => {
76
+ if (Object.keys(data).length !== 1 || !("message_id" in data)) return null;
77
+ this.adapter.ctx.emit("send", { api: this, messageId: String(data.message_id) });
78
+ return { messageId: String(data.message_id), time: Date.now() };
79
+ });
42
80
  }
43
81
  /**
44
82
  * @description: 发送私聊消息
45
- * @param {Msg} message 要发送的内容
46
- * @param {groupId} groupId 群号
47
- * @return {void}
83
+ * @param message 要发送的内容
84
+ * @param groupId 群号
48
85
  */
49
86
  sendGroupMsg(message, groupId) {
50
- this.adapter.status.lastMsgTime = /* @__PURE__ */ new Date();
51
- this.adapter.status.sentMsg += 1;
52
- this.adapter.send("send_group_msg", { group_id: groupId, message, auto_escape: false });
87
+ this.adapter.send("send_group_msg", {
88
+ group_id: Number(groupId),
89
+ message: this.adapter.elements.decode(message),
90
+ auto_escape: false
91
+ });
92
+ return this.factory((data) => {
93
+ if (Object.keys(data).length !== 1 || !("message_id" in data)) return null;
94
+ this.adapter.ctx.emit("send", { api: this, messageId: String(data.message_id) });
95
+ return { messageId: String(data.message_id), time: Date.now() };
96
+ });
53
97
  }
54
98
  /**
55
99
  * @description: 撤回消息
56
- * @param {number} messageId 消息id
57
- * @return {void}
100
+ * @param messageId 消息id
58
101
  */
59
102
  deleteMsg(messageId) {
60
103
  this.adapter.send("delete_msg", { messageId });
61
104
  }
105
+ getSelfInfo() {
106
+ this.adapter.send("get_login_info");
107
+ return this.factory((data) => {
108
+ if (Object.keys(data).length !== 2 || !("user_id" in data) || !("nickname" in data)) return null;
109
+ return {
110
+ userId: String(data.user_id),
111
+ username: String(data.nickname),
112
+ userDisplayname: String(data.nickname)
113
+ };
114
+ });
115
+ }
116
+ getUserInfo(userId) {
117
+ this.adapter.send("get_stranger_info", { user_id: Number(userId) });
118
+ return this.factory((data) => {
119
+ const result = import_kotori_bot.Tsu.Object({
120
+ user_Id: import_kotori_bot.Tsu.Number(),
121
+ nickname: import_kotori_bot.Tsu.String(),
122
+ sex: import_kotori_bot.Tsu.String(),
123
+ qid: import_kotori_bot.Tsu.String()
124
+ }).parseSafe(data);
125
+ if (!result.value) return null;
126
+ return {
127
+ userId: result.data.user_Id.toString(),
128
+ username: result.data.nickname,
129
+ userDisplayname: result.data.nickname,
130
+ userRemark: ""
131
+ };
132
+ });
133
+ }
134
+ getFriendList() {
135
+ this.adapter.send("get_friend_list");
136
+ return this.factory((data) => {
137
+ const result = import_kotori_bot.Tsu.Array(
138
+ import_kotori_bot.Tsu.Object({
139
+ user_id: import_kotori_bot.Tsu.Number(),
140
+ nickname: import_kotori_bot.Tsu.String(),
141
+ remark: import_kotori_bot.Tsu.String()
142
+ })
143
+ ).parseSafe(data);
144
+ if (!result.value) return null;
145
+ return result.data.map((item) => ({
146
+ userId: item.user_id.toString(),
147
+ username: item.nickname,
148
+ userDisplayname: item.nickname,
149
+ userRemark: ""
150
+ }));
151
+ });
152
+ }
153
+ getGroupInfo(groupId) {
154
+ this.adapter.send("get_group_info", { group_id: Number(groupId) });
155
+ return this.factory((data) => {
156
+ const result = import_kotori_bot.Tsu.Object({
157
+ group_id: import_kotori_bot.Tsu.Number(),
158
+ group_name: import_kotori_bot.Tsu.String(),
159
+ group_memo: import_kotori_bot.Tsu.String()
160
+ }).parseSafe(data);
161
+ if (!result.value) return null;
162
+ return { groupId: result.data.group_id.toString(), groupName: result.data.group_name };
163
+ });
164
+ }
165
+ getGroupList() {
166
+ this.adapter.send("get_group_list");
167
+ return this.factory((data) => {
168
+ const result = import_kotori_bot.Tsu.Array(
169
+ import_kotori_bot.Tsu.Object({
170
+ group_id: import_kotori_bot.Tsu.Number(),
171
+ group_name: import_kotori_bot.Tsu.String(),
172
+ group_memo: import_kotori_bot.Tsu.String()
173
+ })
174
+ ).parseSafe(data);
175
+ if (!result.value) return null;
176
+ return result.data.map((item) => ({
177
+ groupId: item.group_id.toString(),
178
+ groupName: item.group_name
179
+ }));
180
+ });
181
+ }
182
+ getGroupMemberInfo(groupId, userId) {
183
+ this.adapter.send("get_group_member_info", { group_id: Number(groupId), user_id: Number(userId) });
184
+ return this.factory((data) => {
185
+ const result = import_kotori_bot.Tsu.Object({
186
+ group_id: import_kotori_bot.Tsu.Number(),
187
+ user_id: import_kotori_bot.Tsu.Number(),
188
+ nickname: import_kotori_bot.Tsu.String(),
189
+ card: import_kotori_bot.Tsu.String(),
190
+ join_time: import_kotori_bot.Tsu.Number(),
191
+ role: import_kotori_bot.Tsu.String()
192
+ }).parseSafe(data);
193
+ if (!result.value) return null;
194
+ return {
195
+ userId: result.data.user_id.toString(),
196
+ username: result.data.nickname,
197
+ userDisplayname: result.data.card
198
+ };
199
+ });
200
+ }
201
+ getGroupMemberList(groupId) {
202
+ this.adapter.send("get_group_member_list", { group_id: Number(groupId) });
203
+ return this.factory((data) => {
204
+ const result = import_kotori_bot.Tsu.Array(
205
+ import_kotori_bot.Tsu.Object({
206
+ group_id: import_kotori_bot.Tsu.Number(),
207
+ user_id: import_kotori_bot.Tsu.Number(),
208
+ nickname: import_kotori_bot.Tsu.String(),
209
+ card: import_kotori_bot.Tsu.String()
210
+ })
211
+ ).parseSafe(data);
212
+ if (!result.value) return null;
213
+ return result.data.map((item) => ({
214
+ userId: item.user_id.toString(),
215
+ username: item.nickname,
216
+ userDisplayname: item.card
217
+ }));
218
+ });
219
+ }
62
220
  /**
63
221
  * @description: 设置群名
64
- * @param {number} groupId 群号
65
- * @param {string} groupName 新群名
66
- * @return {void}
222
+ * @param groupId 群号
223
+ * @param groupName 新群名
67
224
  */
68
225
  setGroupName(groupId, groupName) {
69
- this.adapter.send("set_group_name", { group_id: groupId, group_name: groupName });
226
+ this.adapter.send("set_group_name", { group_id: Number(groupId), group_name: groupName });
227
+ }
228
+ /**
229
+ * @description: 退出群组
230
+ * @param groupId 群号
231
+ */
232
+ leaveGroup(groupId) {
233
+ this.adapter.send("set_group_leave", { group_id: Number(groupId), is_dismiss: false });
70
234
  }
71
235
  /**
72
236
  * @description: 设置群头像
73
- * @param {number} groupId 群号
74
- * @param {string} image 图片路径
75
- * @return {void}
237
+ * @param groupId 群号
238
+ * @param image 图片路径
76
239
  */
77
240
  setGroupAvatar(groupId, image) {
78
- this.adapter.send("set_group_portrait", { group_id: groupId, file: image, cache: false });
241
+ this.adapter.send("set_group_portrait", { group_id: Number(groupId), file: image, cache: false });
79
242
  }
80
243
  /**
81
244
  * @description: 设置群管理员
82
- * @param {number} groupId 群号
83
- * @param {number} userId 要设置的管理员的QQ号
84
- * @param {boolean} enable true为设置,false取消,默认true
85
- * @return {void}
245
+ * @param groupId 群号
246
+ * @param userId 要设置的管理员的QQ号
247
+ * @param enable true为设置,false取消,默认true
86
248
  */
87
249
  setGroupAdmin(groupId, userId, enable = true) {
88
- this.adapter.send("set_group_admin", { group_id: groupId, user_id: userId, enable });
250
+ this.adapter.send("set_group_admin", { group_id: Number(groupId), user_id: Number(userId), enable });
89
251
  }
90
252
  /**
91
253
  * @description: 设置群名片(群备注)
92
- * @param {number} groupId 群号
93
- * @param {number} userId 要设置的QQ号
94
- * @param {string} card 群名片内容,不填或空字符串表示删除群名片
95
- * @return {void}
254
+ * @param groupId 群号
255
+ * @param userId 要设置的QQ号
256
+ * @param card 群名片内容,不填或空字符串表示删除群名片
96
257
  */
97
258
  setGroupCard(groupId, userId, card) {
98
- this.adapter.send("set_group_card", { group_id: groupId, user_id: userId, card });
259
+ this.adapter.send("set_group_card", { group_id: Number(groupId), user_id: Number(userId), card });
99
260
  }
100
261
  /**
101
262
  * @description: 群禁言
102
- * @param {number} groupId 群号
103
- * @param {number} userId 要禁言的QQ号,不填则为群禁言
104
- * @param {number} time 禁言时长,单位秒,0表示取消禁言
105
- * @return {void}
263
+ * @param groupId 群号
264
+ * @param userId 要禁言的QQ号,不填则为群禁言
265
+ * @param time 禁言时长,单位秒,0表示取消禁言
106
266
  */
107
267
  setGroupBan(groupId, userId, time = 0) {
108
- if (userId) {
109
- this.adapter.send("setGroupBan", { group_id: groupId, user_id: userId, duration: time });
110
- } else {
111
- this.adapter.send("set_group_whole_ban", { group_id: groupId, enable: !!time });
112
- }
268
+ this.adapter.send("set_group_ban", { group_id: Number(groupId), user_id: Number(userId), duration: time });
269
+ }
270
+ setGroupWholeBan(groupId, enable = true) {
271
+ this.adapter.send("set_group_whole_ban", { group_id: Number(groupId), enable });
113
272
  }
114
273
  /**
115
274
  * @description: 发送群公告
116
- * @param {number} groupId 群号
117
- * @param {string} content 公告内容
118
- * @param {string} image 图片路径(可选)
119
- * @return {void}
275
+ * @param groupId 群号
276
+ * @param content 公告内容
277
+ * @param image 图片路径(可选)
120
278
  */
121
279
  sendGroupNotice(groupId, content, image) {
122
- this.adapter.send("_sendGroupNotice", { group_id: groupId, content, image });
280
+ this.adapter.send("_send_group_notice", { group_id: Number(groupId), content, image });
123
281
  }
124
282
  /**
125
283
  * @description: 群组踢人
126
- * @param {number} groupId 群号
127
- * @param {number} userId 要踢的QQ号
128
- * @return {void}
284
+ * @param groupId 群号
285
+ * @param userId 要踢的QQ号
129
286
  */
130
287
  setGroupKick(groupId, userId) {
131
- this.adapter.send("setGroupKick", { group_id: groupId, user_id: userId, reject_add_request: false });
132
- }
133
- /**
134
- * @description: 退出群组
135
- * @param {number} groupId 群号
136
- * @return {void}
137
- */
138
- setGroupLeave(groupId) {
139
- this.adapter.send("setGroupLeave", { group_id: groupId, is_dismiss: false });
288
+ this.adapter.send("set_group_kick", {
289
+ group_id: Number(groupId),
290
+ user_id: Number(userId),
291
+ reject_add_request: false
292
+ });
140
293
  }
141
- /* extra: ApiExtraValue = { type: 'onebot', image, at, poke }; */
142
294
  }
143
295
  var api_default = OnebotApi;
144
296
  // Annotate the CommonJS export names for ESM import in node:
package/lib/elements.d.ts CHANGED
@@ -1,11 +1,9 @@
1
- import { Elements, EventDataTargetId } from 'kotori-bot';
2
- import { MessageCqType } from './types';
1
+ import { Elements, type Message, type MessageMapping } from 'kotori-bot';
2
+ import type { MessageCqType } from './types';
3
3
  export declare class OnebotElements extends Elements {
4
+ getSupportsElements(): (keyof MessageMapping)[];
5
+ decode(message: Message): string;
6
+ encode(raw: string): Message;
4
7
  cq(type: MessageCqType, data: string): string;
5
- at(target: EventDataTargetId): string;
6
- image(url: string): string;
7
- voice(url: string): string;
8
- video(url: string): string;
9
- face(id: number): string;
10
8
  }
11
9
  export default OnebotElements;
package/lib/elements.js CHANGED
@@ -1,14 +1,12 @@
1
-
2
1
  /**
3
- * @Package @kotori-bot/kotori-plugin-adapter-onebot
4
- * @Version 2.0.0
5
- * @Author Hotaru <biyuehuya@gmail.com>
6
- * @Copyright 2024 Hotaru. All rights reserved.
7
- * @License GPL-3.0
8
- * @Link https://github.com/kotorijs/kotori
9
- * @Date 2024/6/7 21:36:06
10
- */
11
-
2
+ * @Package @kotori-bot/kotori-plugin-adapter-onebot
3
+ * @Version 2.1.1
4
+ * @Author Hotaru <me@hotaru.icu>
5
+ * @Copyright 2024-2025 Hotaru. All rights reserved.
6
+ * @License BAN-ZHINESE-USING
7
+ * @Link https://github.com/kotorijs/kotori
8
+ * @Date 16:14:08
9
+ */
12
10
  "use strict";
13
11
  var __defProp = Object.defineProperty;
14
12
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -35,24 +33,38 @@ __export(elements_exports, {
35
33
  module.exports = __toCommonJS(elements_exports);
36
34
  var import_kotori_bot = require("kotori-bot");
37
35
  class OnebotElements extends import_kotori_bot.Elements {
38
- cq(type, data) {
39
- (0, import_kotori_bot.none)(this);
40
- return `[CQ:${type},${data}]`;
41
- }
42
- at(target) {
43
- return this.cq("at", `qq=${target}`);
36
+ getSupportsElements() {
37
+ return ["mention", "mentionAll", "image", "voice", "video", "text", "reply"];
44
38
  }
45
- image(url) {
46
- return this.cq("image", `file=${url},cache=0`);
39
+ decode(message) {
40
+ if (typeof message === "string") return message;
41
+ if (!(message instanceof import_kotori_bot.MessageSingle)) {
42
+ return Array.from(message).map((el) => this.decode(el)).join("");
43
+ }
44
+ switch (message.data.type) {
45
+ case "text":
46
+ return message.toString();
47
+ case "image":
48
+ return this.cq("image", `file=${message.data.content},cache=0`);
49
+ case "voice":
50
+ return this.cq("record", `file=${message.data.content}`);
51
+ case "video":
52
+ return this.cq("video", `file=${message.data.content}`);
53
+ case "mention":
54
+ return this.cq("at", `qq=${message.data.userId}`);
55
+ case "mentionAll":
56
+ return this.cq("at", "qq=all");
57
+ case "reply":
58
+ return this.cq("reply", `id=${message.data.messageId}`);
59
+ default:
60
+ return "";
61
+ }
47
62
  }
48
- voice(url) {
49
- return this.cq("record", `file=${url}`);
63
+ encode(raw) {
64
+ return new import_kotori_bot.MessageSingle("text", { text: raw });
50
65
  }
51
- video(url) {
52
- return this.cq("video", `file=${url}`);
53
- }
54
- face(id) {
55
- return this.cq("face", `id=${id}`);
66
+ cq(type, data) {
67
+ return `[CQ:${type},${data}]`;
56
68
  }
57
69
  }
58
70
  var elements_default = OnebotElements;
package/lib/index.d.ts CHANGED
@@ -1,2 +1,6 @@
1
1
  import { OnebotAdapter } from './adapter';
2
+ export * from './adapter';
3
+ export * from './api';
4
+ export * from './elements';
5
+ export * from './types';
2
6
  export default OnebotAdapter;
package/lib/index.js CHANGED
@@ -1,14 +1,12 @@
1
-
2
1
  /**
3
- * @Package @kotori-bot/kotori-plugin-adapter-onebot
4
- * @Version 2.0.0
5
- * @Author Hotaru <biyuehuya@gmail.com>
6
- * @Copyright 2024 Hotaru. All rights reserved.
7
- * @License GPL-3.0
8
- * @Link https://github.com/kotorijs/kotori
9
- * @Date 2024/6/7 21:36:06
10
- */
11
-
2
+ * @Package @kotori-bot/kotori-plugin-adapter-onebot
3
+ * @Version 2.1.1
4
+ * @Author Hotaru <me@hotaru.icu>
5
+ * @Copyright 2024-2025 Hotaru. All rights reserved.
6
+ * @License BAN-ZHINESE-USING
7
+ * @Link https://github.com/kotorijs/kotori
8
+ * @Date 16:14:08
9
+ */
12
10
  "use strict";
13
11
  var __defProp = Object.defineProperty;
14
12
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -26,6 +24,7 @@ var __copyProps = (to, from, except, desc) => {
26
24
  }
27
25
  return to;
28
26
  };
27
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
29
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
29
  var src_exports = {};
31
30
  __export(src_exports, {
@@ -33,4 +32,15 @@ __export(src_exports, {
33
32
  });
34
33
  module.exports = __toCommonJS(src_exports);
35
34
  var import_adapter = require("./adapter");
35
+ __reExport(src_exports, require("./adapter"), module.exports);
36
+ __reExport(src_exports, require("./api"), module.exports);
37
+ __reExport(src_exports, require("./elements"), module.exports);
38
+ __reExport(src_exports, require("./types"), module.exports);
36
39
  var src_default = import_adapter.OnebotAdapter;
40
+ // Annotate the CommonJS export names for ESM import in node:
41
+ 0 && (module.exports = {
42
+ ...require("./adapter"),
43
+ ...require("./api"),
44
+ ...require("./elements"),
45
+ ...require("./types")
46
+ });