koishi-plugin-forward-hime 1.3.8 → 1.3.9
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/index.js +21 -5
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -141,8 +141,10 @@ function getNameFromQQat(elem) {
|
|
|
141
141
|
__name(getNameFromQQat, "getNameFromQQat");
|
|
142
142
|
function Middleware(session) {
|
|
143
143
|
const platform = guessPlatform(session);
|
|
144
|
+
let sessionTemp = session;
|
|
145
|
+
sessionTemp.platform = platform;
|
|
146
|
+
let head = defaultMiddleware(sessionTemp).head;
|
|
144
147
|
let newContent = [];
|
|
145
|
-
let head = defaultMiddleware(session).head;
|
|
146
148
|
if (platform === "QQ") {
|
|
147
149
|
IdNameCache.set(session.userId, session.username);
|
|
148
150
|
for (const key in session.elements) {
|
|
@@ -347,7 +349,7 @@ function defaultDecoratorFallback({ head, content }) {
|
|
|
347
349
|
newContent.push(content[key]);
|
|
348
350
|
}
|
|
349
351
|
}
|
|
350
|
-
msg = msg.concat(head,
|
|
352
|
+
msg = msg.concat(head, newContent);
|
|
351
353
|
return msg;
|
|
352
354
|
}
|
|
353
355
|
__name(defaultDecoratorFallback, "defaultDecoratorFallback");
|
|
@@ -418,20 +420,34 @@ async function MessageSendWithDecorator(ctx2, node, session, Deco) {
|
|
|
418
420
|
logger.debug(`[MessageForward] to ${mc.platform} ${mc.uuid}`);
|
|
419
421
|
}
|
|
420
422
|
}).catch((error) => {
|
|
421
|
-
logger.error(
|
|
423
|
+
logger.error(
|
|
424
|
+
`ERROR:<MessageSendWithDecorator ${node.Platform}> ctx=${ctx2} ${error}`
|
|
425
|
+
);
|
|
422
426
|
throw error;
|
|
423
427
|
});
|
|
424
428
|
}
|
|
425
429
|
__name(MessageSendWithDecorator, "MessageSendWithDecorator");
|
|
430
|
+
function sessionTypeArray(session) {
|
|
431
|
+
let contentTypes = "|";
|
|
432
|
+
session.elements.forEach((element) => {
|
|
433
|
+
contentTypes = contentTypes + element.type + "|";
|
|
434
|
+
});
|
|
435
|
+
return contentTypes;
|
|
436
|
+
}
|
|
437
|
+
__name(sessionTypeArray, "sessionTypeArray");
|
|
426
438
|
async function MessageForward(ctx2, node, session) {
|
|
427
439
|
if (!botExistsCheck(ctx2, node)) {
|
|
428
440
|
return;
|
|
429
441
|
}
|
|
430
442
|
MessageSendWithDecorator(ctx2, node, session, MsgDecorator).catch((error) => {
|
|
431
|
-
logger.error(
|
|
443
|
+
logger.error(
|
|
444
|
+
`ERROR:<MessageSend ${node.Platform}> ctx=${ctx2} ${sessionTypeArray(session)} ${error}`
|
|
445
|
+
);
|
|
432
446
|
MessageSendWithDecorator(ctx2, node, session, MsgDecoratorFallback).catch(
|
|
433
447
|
(error2) => {
|
|
434
|
-
logger.error(
|
|
448
|
+
logger.error(
|
|
449
|
+
`ERROR:<MessageSendFallback ${node.Platform}> ctx=${ctx2} ${sessionTypeArray(session)} ${error2}`
|
|
450
|
+
);
|
|
435
451
|
}
|
|
436
452
|
);
|
|
437
453
|
});
|