Reputation: 2029
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.
Upvotes: 6
Views: 16790
Reputation: 607
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:
Upvotes: 2
Reputation: 52892
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.
Upvotes: 17