python - 回溯,当我更改电报机器人上的令牌时,它可以工作,但在它给出错误之前
问题描述
这是一段代码
#token and set proxy
token = 'token'
bot = telebot.TeleBot(token, threaded= False)
apihelper.proxy = {'https':'socks5://'}
@bot.message_handler(commands=('start'))
def start_message(message):
markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
Showcase = types.KeyboardButton('---')
Vakancy = types.KeyboardButton('---')
City = types.KeyboardButton('---')
Account = types.KeyboardButton('---')
markup.add(Showcase,Vakancy)
markup.add(City)
markup.add(Account)
bot.send_message(message.chat.id,'Приветсвую тебя'),reply_markup=markup)
if __name__ == "__main__":
bot.polling()
如果我更改令牌一切正常,但对我来说,它不起作用,令牌不完全正确。我不知道发生了什么,因为我添加了最后一个按钮,它停止工作以免做
错误
Traceback (most recent call last):
File "c:\Users\admin\Desktop\My Projects\Python\Shop bot\main.py", line 31, in <module>
bot.polling()
File "C:\Users\admin\AppData\Local\Programs\Python\Python37-32\lib\site-packages\telebot\__init__.py", line 394, in polling
self.__non_threaded_polling(none_stop, interval, timeout)
File "C:\Users\admin\AppData\Local\Programs\Python\Python37-32\lib\site-packages\telebot\__init__.py", line 445, in __non_threaded_polling
self.__retrieve_updates(timeout)
File "C:\Users\admin\AppData\Local\Programs\Python\Python37-32\lib\site-packages\telebot\__init__.py", line 280, in __retrieve_updates
self.process_new_updates(updates)
File "C:\Users\admin\AppData\Local\Programs\Python\Python37-32\lib\site-packages\telebot\__init__.py", line 317, in process_new_updates
self.process_new_messages(new_messages)
File "C:\Users\admin\AppData\Local\Programs\Python\Python37-32\lib\site-packages\telebot\__init__.py", line 339, in process_new_messages
self._notify_command_handlers(self.message_handlers, new_messages)
File "C:\Users\admin\AppData\Local\Programs\Python\Python37-32\lib\site-packages\telebot\__init__.py", line 1801, in _notify_command_handlers
if self._test_message_handler(message_handler, message):
File "C:\Users\admin\AppData\Local\Programs\Python\Python37-32\lib\site-packages\telebot\__init__.py", line 1769, in _test_message_handler
if not self._test_filter(filter, filter_value, message):
File "C:\Users\admin\AppData\Local\Programs\Python\Python37-32\lib\site-packages\telebot\__init__.py", line 1790, in _test_filter
return test_cases.get(filter, lambda msg: False)(message)
File "C:\Users\admin\AppData\Local\Programs\Python\Python37-32\lib\site-packages\telebot\__init__.py", line 1801, in _notify_command_handlers
if self._test_message_handler(message_handler, message):
File "C:\Users\admin\AppData\Local\Programs\Python\Python37-32\lib\site-packages\telebot\__init__.py", line 1769, in _test_message_handler
if not self._test_filter(filter, filter_value, message):
File "C:\Users\admin\AppData\Local\Programs\Python\Python37-32\lib\site-packages\telebot\__init__.py", line 1790, in _test_filter
return test_cases.get(filter, lambda msg: False)(message)
File "C:\Users\admin\AppData\Local\Programs\Python\Python37-32\lib\site-packages\telebot\__init__.py", line 1786, in <lambda>
'commands': lambda msg: msg.content_type == 'text' and util.extract_command(msg.text) in filter_value,
TypeError: 'in <string>' requires string as left operand, not NoneType
解决方案
嗨兄弟这是阿卡什我发现了同样的错误现在得到了解决方案。
#token and set proxy
token = 'token'
bot = telebot.TeleBot(token, threaded= False)
apihelper.proxy = {'https':'socks5://'}
@bot.message_handler(commands=['start'])
def start_message(message):
markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
Showcase = types.KeyboardButton('---')
Vakancy = types.KeyboardButton('---')
City = types.KeyboardButton('---')
Account = types.KeyboardButton('---')
markup.add(Showcase,Vakancy)
markup.add(City)
markup.add(Account)
bot.send_message(message.chat.id,'Приветсвую тебя',reply_markup=markup)
if __name__ == "__main__":
bot.polling()
你可以看到我做了什么改变..
推荐阅读
- python - 如何在python的列表中找到重复的对?
- spring-kafka - ConcurrentMessageListenerContainer 中的分区分配为空 [] 用于 2/3 个线程,而我正在尝试将并发设置为 3
- c# - 有没有办法声明将任何 lambda 作为参数的方法?
- mysql - 删除所有 IFRAME
- python - 对二叉树的字符串输入进行排序和字母排序
- javascript - ReactJS:为什么我的 textarea 值总是呈现不可见?
- python - 如何制作名称以相同顺序存储在元组中的文件列表
- linux - 无法在 Manjaro KDE 上导入 Tkinter
- flutter - 如何检查用户是否已经使用 Google Sign in 和 Firebase Auth 登录来检索他们的数据?
- mongodb - MongoDB多层次嵌入式数组查询