I am using the python-telegram-bot package to develop a Telegram bot.
I was wondering if it's possible to access the details of a message that has been replied to from another chat?
Broader explanation:
When a user in a group click on a someone else's message and choose reply in another chat, and goes to a bot and writes some text and sends it to the bot, is it possible to track the original message and know details like id of group/supergroup, id of original user, message id of original message and so on?
I tried: update.effective_message.reply_to_message and update.effective_message.forward_origin. Both seem to return None.
1 Answer 1
Yes, if the bot is an admin in the group, he will receive a regular message update that looks like the one below.
The external_reply hold the information you're looking for, the original replied message.
Where as the quote fields hold the part the users actually replies to, this can be part of the original message.
Regarding the Python Telegram Bot Library, there seems to be an ExternalReplyInfo available in telegram.Message.external_reply:
Information about the message that is being replied to, which may come from another chat or forum topic.
Raw getUpdates json to show the actual fields:
{
"ok": true,
"result": [
{
"update_id": 000000,
"message": {
"message_id": 81,
"from": {
"id": 000000,
"is_bot": false,
"first_name": "x",
"username": "xx",
"language_code": "en"
},
"chat": {
"id": 000000,
"title": "Test Group",
"type": "supergroup"
},
"date": 1752579014,
"external_reply": {
"origin": {
"type": "user",
"sender_user": {
"id": 000000,
"is_bot": false,
"first_name": "xxxx",
"username": "xxxxxxxx",
"language_code": "en"
},
"date": 1752490674
}
},
"quote": {
"text": "HERE ORIGINAL MESSAGE",
"position": 0
},
"text": "HERE REPLIED MESSAGE"
}
}
]
}
Comments
Explore related questions
See similar questions with these tags.