onebots 0.4.14 → 0.4.16
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 +2 -0
- package/lib/onebot.js +2 -2
- package/lib/service/V11/action/common.d.ts +1 -1
- package/lib/service/V11/action/common.js +1 -2
- package/lib/service/V11/action/friend.d.ts +1 -1
- package/lib/service/V11/action/friend.js +2 -2
- package/lib/service/V11/action/group.d.ts +1 -1
- package/lib/service/V11/action/group.js +2 -2
- package/lib/service/V11/index.js +31 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
<h1>基于icqq的oneBot实现</h1>
|
|
3
3
|
<p>
|
|
4
4
|
|
|
5
|
+

|
|
6
|
+
[](https://github.com/icqqjs/onebots/actions/workflows/release.yml)
|
|
5
7
|
[](https://www.npmjs.com/package/onebots)
|
|
6
8
|
[](https://onebot.dev/)
|
|
7
9
|
[](https://12.onebot.dev/)
|
package/lib/onebot.js
CHANGED
|
@@ -182,13 +182,13 @@ class OneBot extends events_1.EventEmitter {
|
|
|
182
182
|
case 'group':
|
|
183
183
|
data.message.unshift({
|
|
184
184
|
type: 'reply',
|
|
185
|
-
|
|
185
|
+
id: (0, icqq_2.genGroupMessageId)(data.group_id, data.source.user_id, data.source.seq, data.source.rand, data.source.time)
|
|
186
186
|
});
|
|
187
187
|
break;
|
|
188
188
|
case 'private':
|
|
189
189
|
data.message.unshift({
|
|
190
190
|
type: 'reply',
|
|
191
|
-
|
|
191
|
+
id: (0, icqq_2.genDmMessageId)(data.source.user_id, data.source.seq, data.source.rand, data.source.time)
|
|
192
192
|
});
|
|
193
193
|
break;
|
|
194
194
|
}
|
|
@@ -16,7 +16,7 @@ export declare class CommonAction {
|
|
|
16
16
|
* 获取消息
|
|
17
17
|
* @param message_id {string} 消息id
|
|
18
18
|
*/
|
|
19
|
-
getMsg(this: V11, message_id:
|
|
19
|
+
getMsg(this: V11, message_id: string): Promise<import("icqq").GroupMessage | import("icqq").PrivateMessage>;
|
|
20
20
|
/**
|
|
21
21
|
* 获取合并消息
|
|
22
22
|
* @param id {string} 合并id
|
|
@@ -8,7 +8,7 @@ export declare class FriendAction {
|
|
|
8
8
|
* @param message {import('icqq').Sendable} 发送的消息
|
|
9
9
|
* @param message_id {string} 引用的消息ID
|
|
10
10
|
*/
|
|
11
|
-
sendPrivateMsg(this: V11, user_id: number, message: string | SegmentElem | SegmentElem[], message_id?: string): Promise<import("icqq").MessageRet>;
|
|
11
|
+
sendPrivateMsg(this: V11, user_id: number, message: string | SegmentElem | SegmentElem[], message_id?: string): Promise<void | import("icqq").MessageRet>;
|
|
12
12
|
/**
|
|
13
13
|
* 获取好友列表
|
|
14
14
|
*/
|
|
@@ -13,9 +13,9 @@ class FriendAction {
|
|
|
13
13
|
const msg = message_id ? await this.client.getMsg(message_id) : undefined;
|
|
14
14
|
const { element, quote, music, share } = await utils_1.processMessage.apply(this.client, [message, msg]);
|
|
15
15
|
if (music)
|
|
16
|
-
await this.client.pickFriend(user_id).shareMusic(music.
|
|
16
|
+
return await this.client.pickFriend(user_id).shareMusic(music.platform, music.id);
|
|
17
17
|
if (share)
|
|
18
|
-
await this.client.pickFriend(user_id).shareUrl(music.data);
|
|
18
|
+
return await this.client.pickFriend(user_id).shareUrl(music.data);
|
|
19
19
|
if (element.length) {
|
|
20
20
|
return await this.client.sendPrivateMsg(user_id, element, quote ? await this.client.getMsg(quote.data.message_id) : undefined);
|
|
21
21
|
}
|
|
@@ -7,7 +7,7 @@ export declare class GroupAction {
|
|
|
7
7
|
* @param message {import('icqq').Sendable} 消息
|
|
8
8
|
* @param message_id {string} 引用的消息ID
|
|
9
9
|
*/
|
|
10
|
-
sendGroupMsg(this: V11, group_id: number, message: string | SegmentElem | SegmentElem[], message_id?: string): Promise<import("icqq").MessageRet>;
|
|
10
|
+
sendGroupMsg(this: V11, group_id: number, message: string | SegmentElem | SegmentElem[], message_id?: string): Promise<void | import("icqq").MessageRet>;
|
|
11
11
|
/**
|
|
12
12
|
* 群组踢人
|
|
13
13
|
* @param group_id {number} 群id
|
|
@@ -13,9 +13,9 @@ class GroupAction {
|
|
|
13
13
|
const msg = message_id ? await this.client.getMsg(message_id) : undefined;
|
|
14
14
|
const { element, quote, music, share } = await utils_1.processMessage.apply(this.client, [message, msg]);
|
|
15
15
|
if (music)
|
|
16
|
-
await this.client.pickGroup(group_id).shareMusic(music.
|
|
16
|
+
return await this.client.pickGroup(group_id).shareMusic(music.platform, music.id);
|
|
17
17
|
if (share)
|
|
18
|
-
await this.client.pickGroup(group_id).shareUrl(music.data);
|
|
18
|
+
return await this.client.pickGroup(group_id).shareUrl(music.data);
|
|
19
19
|
if (element.length) {
|
|
20
20
|
return await this.client.sendGroupMsg(group_id, element, quote ? await this.client.getMsg(quote.data.message_id) : undefined);
|
|
21
21
|
}
|
package/lib/service/V11/index.js
CHANGED
|
@@ -196,7 +196,19 @@ class V11 extends events_1.EventEmitter {
|
|
|
196
196
|
if (data.post_type === 'system') {
|
|
197
197
|
}
|
|
198
198
|
if (data.message && data.post_type === 'message') {
|
|
199
|
-
|
|
199
|
+
if (this.config.post_message_format === 'array') {
|
|
200
|
+
data.message = (0, icqq_cq_enable_1.toSegment)(data.message);
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
if (data.source) {
|
|
204
|
+
this.db.set(`KVMap.${data.source.seq}`, data.message[0].id);
|
|
205
|
+
data.message.shift();
|
|
206
|
+
data.message = (0, icqq_cq_enable_1.toCqcode)(data).replace(/^(\[CQ:reply,id=)(.+?)\]/, `$1${data.source.seq}]`);
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
data.message = (0, icqq_cq_enable_1.toCqcode)(data);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
200
212
|
}
|
|
201
213
|
if (data.message_id) {
|
|
202
214
|
this.db.set(`KVMap.${data.seq}`, data.message_id);
|
|
@@ -377,6 +389,9 @@ class V11 extends events_1.EventEmitter {
|
|
|
377
389
|
*/
|
|
378
390
|
async apply(req) {
|
|
379
391
|
let { action, params, echo } = req;
|
|
392
|
+
if (typeof params.message_id == 'number' || /^\d+$/.test(params.message_id)) {
|
|
393
|
+
params.message_id = this.db.get(`KVMap.${params.message_id}`);
|
|
394
|
+
}
|
|
380
395
|
action = (0, utils_1.toLine)(action);
|
|
381
396
|
let is_async = action.includes("_async");
|
|
382
397
|
if (is_async)
|
|
@@ -397,6 +412,8 @@ class V11 extends events_1.EventEmitter {
|
|
|
397
412
|
else
|
|
398
413
|
throw new Error('required message_type or input (user_id/group_id)');
|
|
399
414
|
}
|
|
415
|
+
if (action === 'send_like')
|
|
416
|
+
action = 'send_user_like';
|
|
400
417
|
const method = (0, utils_1.toHump)(action);
|
|
401
418
|
if (Reflect.has(this.action, method)) {
|
|
402
419
|
const ARGS = String(Reflect.get(this.action, method)).match(/\(.*\)/)?.[0]
|
|
@@ -411,9 +428,16 @@ class V11 extends events_1.EventEmitter {
|
|
|
411
428
|
params[k] = (0, utils_1.toBool)(params[k]);
|
|
412
429
|
if (k === 'message') {
|
|
413
430
|
if (typeof params[k] === 'string') {
|
|
431
|
+
if (/[CQ:music,type=.+,id=.+]/.test(params[k])) {
|
|
432
|
+
params[k] = params[k].replace(',type=', ',platform=');
|
|
433
|
+
}
|
|
414
434
|
params[k] = (0, icqq_cq_enable_1.fromCqcode)(params[k]);
|
|
415
435
|
}
|
|
416
436
|
else {
|
|
437
|
+
if (params[k][0].type == 'music' && params[k][0]?.data?.type) {
|
|
438
|
+
params[k][0].data.platform = params[k][0].data.type;
|
|
439
|
+
delete params[k][0].data.type;
|
|
440
|
+
}
|
|
417
441
|
params[k] = (0, icqq_cq_enable_1.fromSegment)(params[k]);
|
|
418
442
|
}
|
|
419
443
|
params['message_id'] = params[k].find(e => e.type === 'reply')?.message_id;
|
|
@@ -448,6 +472,12 @@ class V11 extends events_1.EventEmitter {
|
|
|
448
472
|
}
|
|
449
473
|
if (result.data instanceof Map)
|
|
450
474
|
result.data = [...result.data.values()];
|
|
475
|
+
if (result.data?.message)
|
|
476
|
+
result.data.message = (0, icqq_cq_enable_1.toSegment)(result.data.message);
|
|
477
|
+
if (result.data?.message_id && result.data?.seq) {
|
|
478
|
+
this.db.set(`KVMap.${result.data.seq}`, result.data.message_id);
|
|
479
|
+
result.data.message_id = result.data.seq;
|
|
480
|
+
}
|
|
451
481
|
if (echo) {
|
|
452
482
|
result.echo = echo;
|
|
453
483
|
}
|