pyTelegramBotCAPTCHA 中 custom_language 的问题

Problem with custom_language in pyTelegramBotCAPTCHA

我曾多次尝试为我的验证码机器人设置自定义语言,但是当我将 .text 或任何其他函数设置为等于字符串时,我收到错误消息: AttributeError: 'NoneType' 对象没有属性 'text'

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

文档:https://github.com/SwissCorePy/pyTelegramBotCAPTCHA#customlanguage

CustomLanguage 与 CaptchaOptions 类似 class。您必须从 CustomLanguage class.

实例化自定义语言对象
my_lang = CustomLanguage()
my_lang.text = "example"

您的其他属性依此类推。不要忘记设置 custom_language:

options.custom_language = my_lang

更改底部的代码并尝试 运行:

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