onebots 0.4.14 → 0.4.15
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/onebot.js +2 -2
- package/lib/service/V11/index.js +22 -1
- package/package.json +1 -1
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
|
}
|
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)
|
|
@@ -448,6 +463,12 @@ class V11 extends events_1.EventEmitter {
|
|
|
448
463
|
}
|
|
449
464
|
if (result.data instanceof Map)
|
|
450
465
|
result.data = [...result.data.values()];
|
|
466
|
+
if (result.data?.message)
|
|
467
|
+
result.data.message = (0, icqq_cq_enable_1.toSegment)(result.data.message);
|
|
468
|
+
if (result.data?.message_id && result.data?.seq) {
|
|
469
|
+
this.db.set(`KVMap.${result.data.seq}`, result.data.message_id);
|
|
470
|
+
result.data.message_id = result.data.seq;
|
|
471
|
+
}
|
|
451
472
|
if (echo) {
|
|
452
473
|
result.echo = echo;
|
|
453
474
|
}
|