user = {
'name': ' ',
'phone': ' ',
'email': ' ',
}
@bot.message_handler(commands=['start'])
def name(msg):
bot.send_message(msg.chat.id, 'Введите ФИО')
@bot.message_handler(content_types=['text'])
def data_name(msg):
user['name'] = msg.text
bot.register_next_step_handler(msg, phone(msg))
def phone(msg):
bot.send_message(msg.chat.id, 'Введите номер телефона')
@bot.message_handler(content_types=['text'])
def data_phone(msg):
user['phone'] = msg.text
bot.register_next_step_handler(msg, email(msg))
def email(msg):
bot.send_message(msg.chat.id, 'Введите Email')
@bot.message_handler(content_types=['text'])
def data_email(msg):
user['email'] = msg.text
bot.register_next_step_handler(msg, send_data(msg))
def send_data(msg):
bot.send_message(
msg.chat.id, f"ФИО: {user['name']}, телефон: {user['phone']}, email: {user['email']}")
Traceback (most recent call last):
File "C:\Users\sasha\Desktop\проекты\боевая техничка\bot.py", line 44, in <module>
bot.polling()
File "C:\Users\sasha\AppData\Local\Programs\Python\Python39\lib\site-packages\telebot\__init__.py", line 619, in polling
self.__threaded_polling(none_stop, interval, timeout, long_polling_timeout, allowed_updates)
File "C:\Users\sasha\AppData\Local\Programs\Python\Python39\lib\site-packages\telebot\__init__.py", line 678, in __threaded_polling
raise e
File "C:\Users\sasha\AppData\Local\Programs\Python\Python39\lib\site-packages\telebot\__init__.py", line 641, in __threaded_polling
self.worker_pool.raise_exceptions()
File "C:\Users\sasha\AppData\Local\Programs\Python\Python39\lib\site-packages\telebot\util.py", line 130, in raise_exceptions
raise self.exception_info
File "C:\Users\sasha\AppData\Local\Programs\Python\Python39\lib\site-packages\telebot\util.py", line 82, in run
task(*args, **kwargs)
TypeError: 'NoneType' object is not callable
@bot.message_handler(content_types=['text'])
т.к. они тут ни к чему. Вот собственно код:user_data= {
'name': '',
'phone': '',
'email': '',
'message': ''
}
@bot.message_handler(commands=['start', 'go'])
def start_handler(message):
msg = bot.send_message(message.chat.id, 'Введите Ваше ФИО')
bot.register_next_step_handler(msg, user_phone)
def user_phone(message):
user_data['name'] = message.text
msg = bot.send_message(message.chat.id, 'Введите свой номер телефона')
bot.register_next_step_handler(msg, user_email)
def user_email(message):
user_data['phone'] = message.text
msg = bot.send_message(message.chat.id, 'Введите Вашу эл. почту')
bot.register_next_step_handler(msg, user_message)
def user_message(message):
user_data['email'] = message.text
msg = bot.send_message(message.chat.id, 'Введите ваше сообщение')
bot.register_next_step_handler(msg, getresults)
def getresults(message):
user_data['message'] = message.text
bot.send_message(message.chat.id, f"ФИО: {user_data['name']} \nТел: {user_data['phone']} \nПочта: {user_data['email']} \nСообщение: {user_data['message']}")
bot.clear_step_handler(message)
bot.register_next_step_handler(msg, phone)
from telebot import TeleBot
TOKEN = "" #token was removed, but I use it on myside
bot = TeleBot(TOKEN)
@bot.message_handler(commands=['start'])
def start(message):
bot.send_message(message.chat.id, 'Enter var1: ')
bot.register_next_step_handler(message, tmf1)
def tmf1(message):
var1 = message.text
bot.send_message(message.chat.id, 'Enter var2: ')
bot.register_next_step_handler(message, tmf2, var1)
def tmf2(message, var1):
var2 = message.text
bot.send_message(message.chat.id, f"String sum = {var1 + var2} !")
bot.register_next_step_handler(message, start(message))
bot.polling()