Почему не сработало bot.register_next_step_handler(message, welcome)?

Вот код
import telebot
import config
import random
import time
import pyowm
import datetime
import calendar

from random import choice
from telebot import types

School = ["Физ-ра\nРусский\nАнглийский\nИстория\nФизика\nАлгебра\nГеометрия","Иформатика\nГеография\nФиз-ра\nМузыка\nРусский\nЛитература\nОБЖ", 
"Физ-ра\nХимия\nАлгебра\nРусский\nРусский\nГеография", "Биология\nИстория\nТруд\nОбщество\nЛитература\nАнглийский", 
"Химия\n Английский\nАлгеьра\nГеометрия\nФизика\nБиология\nАлгебра", "Выходной"]

schedule = "1. с 8.00 до 8.45\n2. с 8.50 до 9.35\n3. с 9.40 до 10.25\n4. с 10.40 до 11.25\n5. с 11.30 до 12.15\n6. с 12.20 до 13.05\n7. с 13.25 до 14.10 "

today = datetime.datetime.today()

mydate = today.strftime("%d.%m.%Y")

workdate = datetime.datetime.strptime(mydate, "%d.%m.%Y")
day = calendar.day_abbr[workdate.date().weekday()]

owm = pyowm.OWM(config.owmm, language = "ru")

observation = owm.weather_at_place(config.place)
w = observation.get_weather()

temp = w.get_temperature('celsius')["temp"] 

adv = ['В разработке']
Creator = 'Меня создал Илья Бугаец'
groups = ['Создатель', 'Модер', 'Помощник', 'Смертный']

bot = telebot.TeleBot(config.TOKEN)

@bot.message_handler(commands=['start'])
def welcome(message):
	markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
	item1 = types.KeyboardButton("☁️Погода☁️")
	item2 = types.KeyboardButton("Мой создатель")
	item3 = types.KeyboardButton("Уроки")
	item4 = types.KeyboardButton("Звонки")
	item5 = types.KeyboardButton("Меню")
	markup.add(item1, item2, item3, item4, item5)
	bot.send_message(message.chat.id, "Привет",reply_markup=markup)
	bot.register_next_step_handler(message, testfunction)

@bot.message_handler(commands=['help'])
def welcome_help(message):
    bot.send_message(message.chat.id, Creator)

@bot.message_handler(commands=['groups'])
def welcome_help(message):
    bot.send_message(message.chat.id, groups)


@bot.message_handler(content_types=['text'])
def lalka(message):
	if message.chat.type == 'private' and message.text == "Меню":
		bot.register_next_step_handler(message, welcome)
	elif message.chat.type == 'private' and message.text == "☁️Погода☁️":
		bot.send_message(message.chat.id, "В судаке сейчас " + w.get_detailed_status() + "\n" + "Температура в районе " + str(temp))
	elif message.chat.type == 'private' and message.text == "Мой Создатель":
		bot.register_next_step_handler(message, testfunction)
	elif message.text == "Уроки":
		if day == "Mon":
				bot.send_message(message.chat.id, School[0])
		elif day == "Tue":
				bot.send_message(message.chat.id, School[1])
		elif day == "Wed":
				bot.send_message(message.chat.id, School[2])
		elif day == "Thu":
				bot.send_message(message.chat.id, School[3])
		elif day == "Fri":
				bot.send_message(message.chat.id, School[4])
		elif day == "Sun":
				bot.send_message(message.chat.id, School[5])
		elif day == "Sat":
				bot.send_message(message.chat.id, School[5])
	elif message.text == "Звонки":
		bot.send_message(message.chat.id, schedule)

@bot.message_handler(content_types=['text'])
def testfunction(message):
    if message.text == 'Мой создатель':
        markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
        item1 = types.KeyboardButton("Vkontakte")
        item2 = types.KeyboardButton("Telegram")
        item3 = types.KeyboardButton("Меню")
        markup.add(item1, item2, item3)
        bot.send_message(message.chat.id, 'Выберете вконтакте или телеграм', reply_markup=markup)
    elif message.text == 'Меню':
    	bot.register_next_step_handler(message, welcome)
bot.polling( none_stop=True )
  • Вопрос задан
  • 317 просмотров
Пригласить эксперта
Ответы на вопрос 1
@anerev
@bot.message_handler(commands=['start'])
def welcome(message):
  markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
  item1 = types.KeyboardButton("☁️Погода☁️")
  item2 = types.KeyboardButton("Мой создатель")
  item3 = types.KeyboardButton("Уроки")
  item4 = types.KeyboardButton("Звонки")
  item5 = types.KeyboardButton("Меню")
  markup.add(item1, item2, item3, item4, item5)
  bot.send_message(message.chat.id, "Привет",reply_markup=markup)
  bot.register_next_step_handler(message, testfunction)

def testfunction(message):
    if message.text == 'Мой создатель':
        markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
        item1 = types.KeyboardButton("Vkontakte")
        item2 = types.KeyboardButton("Telegram")
        item3 = types.KeyboardButton("Меню")
        markup.add(item1, item2, item3)
        bot.send_message(message.chat.id, 'Выберете вконтакте или телеграм', reply_markup=markup)
    elif message.text == 'Меню':
    	bot.register_next_step_handler(message, welcome)
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы