Search code examples
pythontelegrampyrogram

How to answer in users language using Pyrogram?


I am working on the Telegram auto-replies bot, it's expected to answer in different languages. But I can't find a way how to get users' language code to activate the required scenario. At least there is no language_code in get_users(), so I am disappointed about it.


Solution

  • Telegram usually sends a language_code in the Message.from_user you receive. You could use that to handle the languages.

    Alternatively, you could use a library like plate and just ask your users for their language.
    I actually made an example on how that could work: https://github.com/ColinShark/pyrogram-language-chooser