Skip to content
Advertisement

Reply to a Python Telegram bot message

Please tell me how you can call the bot’s response to any message in the feedback bot. By example:

User: /start

Bot: Welcome message (Hello)

User: any message

Bot: Feedback message (Expect an answer)

I tried to do it through the echo function, but most likely I made a mistake somewhere.

I am attaching the code:

main.py:

JavaScript

settings.py:

JavaScript

handlers.py:

JavaScript

I will be very grateful for your help

Advertisement

Answer

Thanks to Aditya Yadav for the advice :)

Additionally, I researched the documentation, regarding the dialog handler part of the library I use. The following solution was found: Rewrite the def echo and def forward_to_chat functions, combining them.

JavaScript

The necessary dispatcher was also formed at the end:

JavaScript

Thus, the task that was set in the condition was solved.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement