koishi-plugin-forward-hime 1.4.2-alpha.2 → 1.4.3
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 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -631,9 +631,15 @@ async function relayForwardContent(content, traceId, session, node) {
|
|
|
631
631
|
}
|
|
632
632
|
|
|
633
633
|
// src/message.ts
|
|
634
|
+
var DeliveryUncertainError = class extends Error {
|
|
635
|
+
constructor(cause) {
|
|
636
|
+
super("message delivery status unknown", { cause });
|
|
637
|
+
}
|
|
638
|
+
};
|
|
634
639
|
async function MessageSendWithDecorator(ctx2, node, session, Deco, traceId, attempt) {
|
|
635
640
|
const startedAt = Date.now();
|
|
636
641
|
const uuid = session.channelId + ":" + session.messageId;
|
|
642
|
+
let submitted = false;
|
|
637
643
|
writeDiagnostic({
|
|
638
644
|
traceId,
|
|
639
645
|
phase: "send-attempt",
|
|
@@ -644,6 +650,7 @@ async function MessageSendWithDecorator(ctx2, node, session, Deco, traceId, atte
|
|
|
644
650
|
});
|
|
645
651
|
try {
|
|
646
652
|
const content = await Deco(session, node, traceId);
|
|
653
|
+
submitted = true;
|
|
647
654
|
const res = await ctx2.bots[`${node.Platform}:${node.BotID}`].sendMessage(
|
|
648
655
|
node.Guild,
|
|
649
656
|
content
|
|
@@ -686,7 +693,7 @@ async function MessageSendWithDecorator(ctx2, node, session, Deco, traceId, atte
|
|
|
686
693
|
logger.error(
|
|
687
694
|
`ERROR:<MessageSendWithDecorator ${node.Platform}> ctx=${ctx2} ${error}`
|
|
688
695
|
);
|
|
689
|
-
throw error;
|
|
696
|
+
throw submitted ? new DeliveryUncertainError(error) : error;
|
|
690
697
|
}
|
|
691
698
|
}
|
|
692
699
|
function sessionTypeArray(session) {
|
|
@@ -771,6 +778,10 @@ async function MessageForward(ctx2, node, session, timeoutSec, relayEnabled) {
|
|
|
771
778
|
logger.error(
|
|
772
779
|
`ERROR:<MessageSend ${node.Platform}> ctx=${ctx2} ${sessionTypeArray(session)} ${firstError}`
|
|
773
780
|
);
|
|
781
|
+
if (firstError instanceof DeliveryUncertainError) {
|
|
782
|
+
writeDiagnostic({ traceId, phase: "forward-uncertain", source, target });
|
|
783
|
+
return;
|
|
784
|
+
}
|
|
774
785
|
if (relayEnabled !== false && firstError instanceof MediaRelayError) {
|
|
775
786
|
logger.info(
|
|
776
787
|
`[MessageForward] relay failed, retrying without relay: ${node.Platform}`
|
|
@@ -788,6 +799,15 @@ async function MessageForward(ctx2, node, session, timeoutSec, relayEnabled) {
|
|
|
788
799
|
logger.error(
|
|
789
800
|
`ERROR:<MessageSendDirect ${node.Platform}> ctx=${ctx2} ${sessionTypeArray(session)} ${secondError}`
|
|
790
801
|
);
|
|
802
|
+
if (secondError instanceof DeliveryUncertainError) {
|
|
803
|
+
writeDiagnostic({
|
|
804
|
+
traceId,
|
|
805
|
+
phase: "forward-uncertain",
|
|
806
|
+
source,
|
|
807
|
+
target
|
|
808
|
+
});
|
|
809
|
+
return;
|
|
810
|
+
}
|
|
791
811
|
sendDegraded(reasonFromError(secondError));
|
|
792
812
|
});
|
|
793
813
|
} else {
|