Александр
Александр

Reputation: 23

How to forward messages with media using a Telegram bot?

Due to a lack of knowledge, I encountered an issue on the TelebotCreator website. I created a simple bot, but I can’t forward messages if they contain one or more photos or videos. Messages without media are forwarded without any problems, but when media is attached, the message fails to send.

I know there are experienced people here; could you help me solve this problem?

    GROUP_ID = "*******"
if msg:
bot.forwardMessage(GROUP_ID, message.chat.id, message.message_id)

P.S. Guys, please, no insults...

Upvotes: 0

Views: 150

Answers (2)

plzbugmenot
plzbugmenot

Reputation: 1

If you want to send photo, you can use this codebase.

api.sendPhoto({
    chat_id : message.chat.id,
    caption: 'This is my test image',
    photo: 'image.jpeg'//replace your image url here
})
.then(function(data)
{
    console.log(data);
});

Also here.

   _img = url of Image;
    // console.log("photo", _img);

    await bot.sendPhoto(channel, _img, {
      caption: Content,
      parse_mode: "HTML",
    });

Upvotes: 0

plzbugmenot
plzbugmenot

Reputation: 1

You can send message with media like .gif file.

          await bot.sendAnimation(chatId, defaultIMG.file_id, {
            duration: defaultIMG.duration || 2,
            width: defaultIMG.width || 640,
            height: defaultIMG.height || 640,
            thumb: defaultIMG.thumb.file_id,
            caption: strBotDM, // Add the caption here
            parse_mode: "HTML",
          });

Please check this github repo. https://github.com/Any-bot/D2T-msg-forward

Also https://dev.to/plzbugmenot/building-a-discord-to-telegram-token-address-forwarder-8m

I wanna hear from you.

Thank you.

Upvotes: 0

Related Questions