Many different media types on Telegram have a file_id
and file_unique_id
property, such as Stickers, Audio, and Document.
The file_id
property is unique to each Telegram bot, so one Telegram bot will not report the same file_id
as another Telegram bot will, even if it’s the same piece of media.
I want to have two Telegram bots communicate with each other, but they are currently unable to do so because the file_id
property is meaningless when one bot tries to talk to the other.
The file_unique_id
property is consistent between the bots, but it does not seem like you can do much of anything with that identifier.
Is there any way to pass a reference to a file stored on Telegram’s servers from one bot to another, without having to re-upload the file on both bots?
3
Answers
There aren’t any official methods to share fileIds between bots. In fact, you can’t even get 2 bots talk to each other, also you won’t get bot updates in groups. So bot to bot communication is not possible at all at this moment.
But what you can do is to use Mtproto api and sign-in to telegram as a normal user (with phone number). And follow these steps using the logged in account:
This way you’ll be able to access any files in bot 1 in bot 2.
You can use Telethon to write a script that does the job for you, listening to updates coming from bot 1 & forwarding them to bot 2.
Also using normal bot api you should forward received messages to your logged-in account.
Bot can’t interact with each other. But there’s a workaround,
we can use
channels
as a medium (with onlyBotAPI
)Steps,
Add two bots as admin in channel
Broadcast the messages from Bot A to channel
Now, the Bot B will get these as channel posts and your new
fileid
for the same file which will be unique for Bot B (obviously)
You have officially transferred all
fileid
to Bot BThe only way is to use a shared channel. Both bots have admin access. However, you may encounter error 429 while transferring the file.
The solution is to send the files to the channel at longer intervals.