Search code examples
pythontelebot

How do I know if user's message is a reply?


I am using telebot for Python.

Is there any way I get to know if the message is a reply?


Solution

  • I assume you are using this library: https://pytba.readthedocs.io/en/latest/index.html

    If you have a Message object r, you can check its reply_to_message attribute:

    • If reply_to_message is another Message instance m, r is a reply to m.

    • If reply_to_message is None, r is not a reply.

    If you have a different library, it should work similarly, as it corresponds directly to the Telegram API.