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

Method sendSingleMedia

save/save.ts:771–803  ·  view source on GitHub ↗
(
    client: any,
    targetPeer: any,
    mediaInfo: { 
      path: string; 
      type: string; 
      caption?: string;
      fileName?: string;
    },
    replyMsg?: Api.Message
  )

Source from the content-addressed store, hash-verified

769 try {
770 // 直接转发,获取转发的消息
771 const result = await client.forwardMessagesById({
772 toChatId: targetPeer,
773 fromChatId: sourceMsg.chat.id,
774 messages: [sourceMsg.id]
775 });
776 forwardedMessage = result[0] as MtcuteMessageContext;
777
778 await this.safeEditMessage(replyMsg, `${progress}✅ 转发成功`, true);
779
780 // 如果开启了来源显示,发送来源消息
781 return {
782 success: true,
783 forwardedMsg: forwardedMessage,
784 source: { chatId: sourceChatId, messageId: sourceMessageId }
785 };
786 } catch (forwardError: unknown) {
787 const errorMsg = getErrorMessage(forwardError);
788 const isRestricted = errorMsg.includes('SAVE') ||
789 errorMsg.includes('FORWARD') ||
790 errorMsg.includes('CHAT_FORWARDS_RESTRICTED');
791
792 if (!isRestricted) throw forwardError;
793
794 if (!sourceMsg.media) {
795 const text = sourceMsg.text || '';
796 if (text) {
797 // 发送文本消息,获取发送的消息
798 forwardedMessage = await client.sendText(targetPeer, text) as MtcuteMessageContext;
799
800 await this.safeEditMessage(replyMsg, `${progress}✅ 文本内容已发送`, true);
801
802 // 如果开启了来源显示,发送来源消息
803 return {
804 success: true,
805 forwardedMsg: forwardedMessage,
806 source: { chatId: sourceChatId, messageId: sourceMessageId }

Callers 1

processMessageMethod · 0.95

Calls 1

safeEditMessageMethod · 0.95

Tested by

no test coverage detected