Is there any way to transfer Telegram file IDs between different bots? - telegram-bot

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?

Bot can't interact with each other. But there's a workaround,
we can use channels as a medium (with only BotAPI)
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 B

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:
Start both of your bots.
Forward messages you receive from bot 1 to bot 2.
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.

The 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.

Related

Telegram bot receiving commands from other bot

in the documentation of the telegram bot API I found:
Bots with privacy mode enabled will receive:
Commands explicitly meant for them (e.g., /command#this_bot).
General commands from users (e.g. /start) if the bot was the last bot
to send a message to the group.
So I created two bots - invited both in a group and had "firstbot" to fire /cmd#otherbot something commands. The "otherbot" echos everything it reads.
I (in the client) I can write - "otherbot" doesn't see it - which is correct due to privacy settings.
I i write /cmd#otherbot - "otherbot" receives and echos this - also correct.
BUT - when I let "firstbot" emit /cmd#otherbot in the group "otherbot" doesn't see it.
Am I doing something wrong - or am I miss-leaded by the documentation?
I use C# with Telegram.Bot by roundrobin.
Bots can't see messages meant for other bots, regardless of privacy modes.
Why doesn't my bot see messages from other bots?
Bots talking to each other could potentially get stuck in unwelcome loops. To avoid this, we decided that bots will not be able to see messages from other bots regardless of mode.
Recently I came across with this problem, that one bot can't read messages from another bot.
But I've found a solution: instead of using the Telegram Bot API, you can use TDLib (Telegram Database library) to read the messages.
I am using python, so with this short piece of code I am able to read messages from a bot:
from telegram.client import Telegram
tg = Telegram(
api_id=123456,
api_hash='api_hash',
phone='+555555555',
database_encryption_key='changehere' )
tg.login()
def new_message_handler(update):
message_content = update['message']['content']
message_text = message_content.get('text', {}).get('text', '').lower()
print(message_text)
# do what you want with the message
tg.add_message_handler(new_message_handler)
tg.idle()
I guess that the same can be extended for other languages.
With this approach combined with Bot Telegram API, you are able to:
read messages from a bot (with Telegram Database library)
send that message with another bot (with Telegram Bot API)

Get chat_id from bot to bot conversation

So What Im trying to accomplish is a bot that forwards messages from one specific user to one specific group chat. I started my testing by using my own chat_id and the bot perfectly forwards my messages to the right groupchat.
The problem is tho, that I want to forward messages that I receive from a bot. So I am trying to gather the chat_id between this bot and my bot but I can't get my head around how I should send and/or receive a message from this bot to gather said chat_id because I cant use it's #username in a /sendMessage? URL.
Why doesn't my bot see messages from other bots? Bots talking to each
other could potentially get stuck in unwelcome loops. To avoid this,
we decided that bots will not be able to see messages from other bots
regardless of mode.
Telegram Bots FAQ

Telegram bots - how can we detect that a user has started typing?

We can get Telegram messages when they are complete and sent via long polling or webhooks, but is there a way to understand when the user has started typing?
I guess this is not a normal case for bots and I dont think there is a straight away method but could we fall back on the Telegram API for messaging apps for that?
Well, actually I found a solution in the current Bot API; inline queries. While they are not intended for this, inline queries send what the user types in to the bot in real-time, so you are alerted as soon as the first characters are typed in.
There is a way in Telegram Core API, named: updateUserTyping.
But there is not any way in Telegram Bot API yet (until today: 2016-10-17).
If you type or send a file to the bot during these processes you do not get any message from Telegram in your webhook, but it's possible they'll add a new feature to detect user typing in future Bot API updates.

Is it possible to build a telegram bot that aggregates posts of multi telegram channel?

Requirments:
1- Have a feed of posts that aggregate all posts of multi channels
2- have actions (bot command) on each post
3- When post of channel edited, correspondent post in the telegram bot edited too.
(If it is not possible, I want to know is it possible to edit a message that was sent to multiple recipients in one action or i have to change each of them by message id, chat id)
You can assume you are owner of all these channels and you set your bot as admin of all of them
Only creator/admins can add bots to channels and only as admins.
Bots (for now) can't read messages in channels.
Bots (for now) can't view any counters in channels.
So no such bot for now :(

How to have a telegram bot join a channel via link?

I would like to program a crawler bot which would surf channels and find the message with high view counts.
Is it possible to have a bot added to a channel via link?
Is it possible for a bot to read messages broadcast in a channel?
Is it possible for a bot to read view count value of a message in a channel?
If any of the above questions are possible, what is/are the solution(s)?
Only creator/admins can add bots to channels and only as admins.
Bots (for now) can't read messages in channels.
Bots (for now) can't view any counters in channels.
Finally, for now, bots can only post messages to channels and only if added to channel by creator or admin.