MCPcopy Create free account
hub / github.com/TeleBoxOrg/TeleBox_Plugins / sendTargetFeedback

Function sendTargetFeedback

bs/bs.ts:646–709  ·  view source on GitHub ↗
(options: {
  client: any;
  replyMessage: Api.Message;
  successes: ForwardSuccess[];
  sourceEntity: any;
  originalMessageIds: number[];
})

Source from the content-addressed store, hash-verified

644}
645
646async function sendTargetFeedback(options: {
647 client: any;
648 replyMessage: Api.Message;
649 successes: ForwardSuccess[];
650 sourceEntity: any;
651 originalMessageIds: number[];
652}) {
653 const { client, replyMessage, successes, sourceEntity, originalMessageIds } =
654 options;
655 if (!successes.length) return;
656
657 const originEntity = sourceEntity ?? replyMessage.peerId;
658 const sourceNameRaw = getEntityDisplayName(originEntity) ?? "来源对话";
659 const sourceLink = buildEntityLink(originEntity);
660 const sourceName = escapeHtml(sourceNameRaw);
661 const sourceText = sourceLink
662 ? `<a href="${escapeAttribute(sourceLink)}">${sourceName}</a>`
663 : sourceName;
664
665 for (const success of successes) {
666 const forwardedMessages = success.forwarded;
667 if (!forwardedMessages || forwardedMessages.length === 0) continue;
668 const firstForwarded = forwardedMessages[0];
669 if (!firstForwarded || typeof firstForwarded.id !== "number") continue;
670
671 const forwardedLinks = buildForwardedLinkTags(
672 success.entity,
673 forwardedMessages
674 );
675 const originalLinks = buildMessageLinkTagsByIds(
676 originEntity,
677 (originalMessageIds || []).slice(0, forwardedMessages.length)
678 );
679
680 const textParts: string[] = [];
681 textParts.push(`来源:${sourceText}`);
682 if (originalLinks.length) {
683 textParts.push(`\n原消息:${originalLinks.join(" ")}`);
684 }
685 if (forwardedLinks.length) {
686 textParts.push(`\n消息:${forwardedLinks.join(" ")}`);
687 }
688
689 const replyToMsgId = firstForwarded.id;
690 const topMsgId = success.target.topicId
691 ? toInt(success.target.topicId) ?? undefined
692 : undefined;
693
694 try {
695 await client.sendMessage(success.entity, {
696 message: textParts.filter(Boolean).join("<br>"),
697 parseMode: "html",
698 linkPreview: false,
699 replyTo: replyToMsgId,
700 topMsgId,
701 });
702 } catch (error) {
703 console.warn(

Callers 1

BsPluginClass · 0.85

Calls 8

getEntityDisplayNameFunction · 0.85
buildEntityLinkFunction · 0.85
escapeAttributeFunction · 0.85
buildForwardedLinkTagsFunction · 0.85
warnMethod · 0.80
escapeHtmlFunction · 0.70
toIntFunction · 0.70

Tested by

no test coverage detected