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

Function sendSourceFeedback

bs/bs.ts:592–644  ·  view source on GitHub ↗
(options: {
  msg: Api.Message;
  client: any;
  fromPeer: any;
  replyMessage: Api.Message;
  successes: ForwardSuccess[];
  messageCount: number;
})

Source from the content-addressed store, hash-verified

590}
591
592async function sendSourceFeedback(options: {
593 msg: Api.Message;
594 client: any;
595 fromPeer: any;
596 replyMessage: Api.Message;
597 successes: ForwardSuccess[];
598 messageCount: number;
599}) {
600 const { msg, client, fromPeer, replyMessage, successes, messageCount } =
601 options;
602 if (!successes.length) return;
603
604 const responses: string[] = [];
605
606 for (const success of successes) {
607 const forwardedCount = success.forwarded?.filter(
608 (item) => item && typeof item.id === "number"
609 ).length;
610 const countText =
611 forwardedCount && forwardedCount > 0 ? forwardedCount : messageCount;
612
613 const targetNameRaw =
614 getEntityDisplayName(success.entity) ??
615 (typeof success.target.target === "string"
616 ? success.target.target
617 : "目标");
618 const targetName = escapeHtml(targetNameRaw);
619 const targetLink = buildEntityLink(success.entity);
620 const targetHtml = targetLink
621 ? `<a href="${escapeAttribute(targetLink)}">${targetName}</a>`
622 : targetName;
623
624 responses.push(`${countText} 条消息已被保送到 ${targetHtml}`);
625 }
626
627 if (!responses.length) return;
628
629 try {
630 // await client.sendMessage(fromPeer, {
631 // message: `亲爱的被观察者 您的 ${responses.join("\n")}`,
632 // parseMode: "html",
633 // linkPreview: false,
634 // replyTo: buildReplyToForMessage(replyMessage),
635 // });
636 await msg.edit({
637 text: `亲爱的被观察者 您的 ${responses.join("\n")}`,
638 parseMode: "html",
639 linkPreview: false,
640 });
641 } catch (error) {
642 console.warn("[bs] 回复原消息失败", error);
643 }
644}
645
646async function sendTargetFeedback(options: {
647 client: any;

Callers 1

BsPluginClass · 0.85

Calls 6

getEntityDisplayNameFunction · 0.85
buildEntityLinkFunction · 0.85
escapeAttributeFunction · 0.85
warnMethod · 0.80
escapeHtmlFunction · 0.70
editMethod · 0.45

Tested by

no test coverage detected