M
M
matix1122019-05-21 14:24:02
Python
matix112, 2019-05-21 14:24:02

Error while writing Telegram Bot?

import telebot

bot = telebot.TeleBot('873366214:AAFxTpeP5JRyLzjWsVJvFxq2iE1hpJQoKYQ')

@bot.message_handler(commands='start')
def start(message):
    bot.send_message(message.chat.id, 'Добро пожаловать!')

bot.polling()

2019-05-21 14:16:44,905 (util.py:65 PollingThread) ERROR - TeleBot: "TypeError occurred, args=("'in ' requires string as left operand, not NoneType",)
Traceback (most recent call last ):
File "C:\Users\Alexander\AppData\Local\Programs\Python\Python37-32\lib\site-packages\telebot\util.py", line 59, in run
task(*args, **kwargs)
File "C:\Users\Alexander\AppData\Local\Programs\Python\Python37-32\lib\site-packages\telebot\__init__.py", line 277, in __retrieve_updates
self.process_new_updates(updates)
File "C:\ Users\Alexander\AppData\Local\Programs\Python\Python37-32\lib\site-packages\telebot\__init__.py", line 314, in process_new_updates
self.process_new_messages(new_messages)
File "C:\Users\Alexander\AppData\Local\Programs\Python\Python37-32\lib\site-packages\telebot\__init__.py", line 336, in process_new_messages
self._notify_command_handlers(self.message_handlers, new_messages)
File "C:\Users\Alexander\AppData\Local\Programs\Python\Python37-32\lib\site-packages\telebot\__init__.py", line 1489, in _notify_command_handlers
if self._test_message_handler(message_handler, message):
File " C:\Users\Alexander\AppData\Local\Programs\Python\Python37-32\lib\site-packages\telebot\__init__.py", line 1470, in _test_message_handler
if not self._test_filter(filter, filter_value, message):
File "C:\Users\Alexander\AppData\Local\Programs\Python\Python37-32\lib\site-packages\telebot\__init__.py",line 1484, in _test_filter
return test_cases.get(filter, lambda msg: False)(message)
File "C:\Users\Alexander\AppData\Local\Programs\Python\Python37-32\lib\site-packages\telebot\__init__.py", line 1480, in
'commands': lambda msg: msg.content_type == 'text' and util.extract_command(msg.text) in filter_value,
TypeError: 'in ' requires string as left operand, not NoneType
"
Traceback (most recent call last ):
File "C:/Users/Alexander/Working Base/Self Education/Python new bot/echo/main.py", line 9, in
bot.polling()
File "C:\Users\Alexander\AppData\Local\Programs \Python\Python37-32\lib\site-packages\telebot\__init__.py", line 389, in polling
self.__threaded_polling(none_stop, interval,timeout)
File "C:\Users\Alexander\AppData\Local\Programs\Python\Python37-32\lib\site-packages\telebot\__init__.py", line 412, in __threaded_polling
polling_thread.raise_exceptions()
File "C:\Users \Alexander\AppData\Local\Programs\Python\Python37-32\lib\site-packages\telebot\util.py", line 78, in raise_exceptions
six.reraise(self.exc_info[0], self.exc_info[1] , self.exc_info[2])
File "C:\Users\Alexander\AppData\Local\Programs\Python\Python37-32\lib\site-packages\six.py", line 693, in reraise
raise value
File "C :\Users\Alexander\AppData\Local\Programs\Python\Python37-32\lib\site-packages\telebot\util.py", line 59, in run
task(*args, **kwargs)
File "C:\Users\Alexander\AppData\Local\Programs\Python\Python37-32\lib\site-packages\telebot\__init__.py", line 277, in __retrieve_updates
self.process_new_updates(updates)
File "C:\ Users\Alexander\AppData\Local\Programs\Python\Python37-32\lib\site-packages\telebot\__init__.py", line 314, in process_new_updates
self.process_new_messages(new_messages)
File "C:\Users\Alexander\AppData \Local\Programs\Python\Python37-32\lib\site-packages\telebot\__init__.py", line 336, in process_new_messages
self._notify_command_handlers(self.message_handlers, new_messages)
File "C:\Users\Alexander\AppData\ Local\Programs\Python\Python37-32\lib\site-packages\telebot\__init__.py", line 1489, in _notify_command_handlers
if self._test_message_handler(message_handler, message):
File "C:\Users\Alexander\AppData\Local\Programs\Python\Python37-32\lib\site-packages\telebot\__init__.py", line 1470, in _test_message_handler
if not self._test_filter(filter, filter_value, message):
File "C:\Users\Alexander\AppData\Local\Programs\Python\Python37-32\lib\site-packages\telebot\__init__.py", line 1484, in _test_filter
return test_cases.get(filter, lambda msg: False)(message)
File "C:\Users\Alexander\AppData\Local\Programs\Python\Python37-32\lib\site-packages\telebot\__init__.py", line 1480, in
'commands': lambda msg: msg.content_type == 'text' and util.extract_command(msg.text) in filter_value,
TypeError: 'in ' requires string as left operand, not NoneType
The simplest code, everything worked before, now it gives such an error. I can't figure out the reason.
Help me please!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Danil K., 2019-06-07
@Danya_Violet

@bot.message_handler(commands=['start'])
shouldn't the team name be in square brackets?

C
cython, 2019-05-21
@cython

If you disassemble Traceback, it says that the problem is in the library. Try updating pip and the library.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question