Search code examples
pythonpy-telegram-bot-api

Problem with custom_language in pyTelegramBotCAPTCHA


I have tried many time to set a custom language for my captcha bot but when i put the .text or any else function equal a string I got an error: AttributeError: 'NoneType' object has no attribute 'text'

options = CaptchaOptions()
options.generator = "keyzend"
options.custom_language.text = "example"
options.timeout = 120
captcha_manager = CaptchaManager(bot.get_me().id, default_options=options)

Doc: https://github.com/SwissCorePy/pyTelegramBotCAPTCHA#customlanguage


Solution

  • CustomLanguage is a class like CaptchaOptions. You would have to instantiate a custom language object from the CustomLanguage class.

    my_lang = CustomLanguage()
    my_lang.text = "example"
    

    and so on for your other attributes. Don't forget to set your custom_language:

    options.custom_language = my_lang