При нажатии "Выбрать товар" вылетает ошибка и бот останавливается что не так?:(
import telebot
#from telebot import *
from telebot import types
import config
bot = telebot.TeleBot(config.token)
@bot.message_handler(commands=['start'])
def send_welcome(message):
markup = types.ReplyKeyboardMarkup(True)
markup.add('Томск', 'Новосибирск')
msg = bot.send_message(message.chat.id, 'Выбери город', reply_markup=markup)
bot.register_next_step_handler(msg, choose_city)
def choose_city(message):
if (message.text == 'Томск'):
markup = types.ReplyKeyboardMarkup(True)
markup.add('Выбрать товар')
markup.add('Главное меню')
msg = bot.send_message(message.chat.id, 'Томск. Нажми выбрать товар', reply_markup=markup)
bot.register_next_step_handler(msg, 'choose_tsk, menu')
elif (message.text == 'Новосибирск'):
markup = types.ReplyKeyboardMarkup(True)
markup.add('Выбрать товар')
markup.add('Главное меню')
msg = bot.send_message(message.chat.id, 'Новосибирск. Нажми выбрать товар', reply_markup=markup)
bot.register_next_step_handler(msg, 'choose_nsk, menu')
@bot.message_handler(regexp='Главное меню')
def menu(message):
markup = types.ReplyKeyboardMarkup(True)
markup.row('Томск', 'Новосибирск')
msg = bot.send_message(message.chat.id, 'Главное меню, выберите город', reply_markup=markup)
bot.register_next_step_handler(msg, choose_city)
@bot.message_handler(regexp='Томск')
def choose_tsk(message):
if (message.text == 'Выбрать товар'):
markup = types.ReplyKeyboardMarkup(True)
markup.add('Ягоды')
markup.add('Главное меню')
msg = bot.send_message(message.chat.id, 'Томск. Выберите товар из списка', reply_markup=markup)
msg()
@bot.message_handler(regexp='Новосибирск')
def choose_nsk(message):
if (message.text == 'Выбрать товар'):
markup = types.ReplyKeyboardMarkup(True)
markup.add('Ягоды')
markup.add('Главное меню')
msg = bot.send_message(message.chat.id, 'Новосибирск. Выберите товар из списка', reply_markup=markup)
msg()
bot.polling(none_stop=True)
Ошибка"C:\Program Files\Python36-32\python.exe" "C:/my programms/bot telega/test 1.py"
2017-11-27 15:34:02,408 (util.py:64 WorkerThread2) ERROR - TeleBot: "TypeError occurred, args=("'str' object is not callable",)
Traceback (most recent call last):
File "C:\Program Files\Python36-32\lib\site-packages\telebot\util.py", line 58, in run
task(*args, **kwargs)
TypeError: 'str' object is not callable
"
Traceback (most recent call last):
File "C:/my programms/bot telega/test 1.py", line 52, in
bot.polling(none_stop=True)
File "C:\Program Files\Python36-32\lib\site-packages\telebot\__init__.py", line 264, in polling
self.__threaded_polling(none_stop, interval, timeout)
File "C:\Program Files\Python36-32\lib\site-packages\telebot\__init__.py", line 288, in __threaded_polling
2017-11-27 15:34:02,413 (util.py:64 WorkerThread1) ERROR - TeleBot: "TypeError occurred, args=("'str' object is not callable",)
Traceback (most recent call last):
File "C:\Program Files\Python36-32\lib\site-packages\telebot\util.py", line 58, in run
task(*args, **kwargs)
TypeError: 'str' object is not callable
"
self.worker_pool.raise_exceptions()
File "C:\Program Files\Python36-32\lib\site-packages\telebot\util.py", line 107, in raise_exceptions
six.reraise(self.exc_info[0], self.exc_info[1], self.exc_info[2])
File "C:\Program Files\Python36-32\lib\site-packages\six.py", line 693, in reraise
raise value
File "C:\Program Files\Python36-32\lib\site-packages\telebot\util.py", line 58, in run
task(*args, **kwargs)
TypeError: 'str' object is not callable
Process finished with exit code 1