2
votes

I'm using node-telegram-bot-api package
and I have two telegram bots like this:

  const TelegramBot = require('node-telegram-bot-api');
  let bot1 = new TelegramBot(token1, { polling: true });
  let bot2 = new TelegramBot(token2, { polling: true });

I'm kind of making a connection between these two bots, In a way that messages that are recieved from bot1 should be sent to user by bot2 and vice versa
something like:

bot1.on('message', (msg) => {
    if (msg.video) { // video in this case
         bot2.sendVideo(user2_chatid, msg.video.file_id);
    }
});

In the above code I am trying to send the video to user2 using bot2, once bot1 receives a video
using file_id to reference sticker is all right, but for photos, videos, voices etc I get this error

wrong file identifier/HTTP URL specified

Looks like telegram is kind of private about the bots and the data they can share, means that file_id is something private and only accessible by the bot it self
How can I share these data between telegram bots?
and I strongly prefer a way other than saving photos and videos somewhere on the server then sending them

1

1 Answers

0
votes

https://core.telegram.org/bots/api#sending-files

file_id is unique for each individual bot and can't be transferred from one bot to another.

so I guess the answer Is no, unless I would save the file somewhere, upload it again using bot2 and then send it
for me a better solution was to use the same bot (bot1) for both users, so I can easily send the received file to any user who has started a chat with the bot