The bot stops at the start_game function, and nothing happens after it, although easy_game should go on.
The main task of my bot is for it to guess countries, and the user to guess the capital of this country. I have two questions.:
- Why does my penultimate function not go to the last one,
- How to process the user’s response
<code>import telebot
from telebot import types
from config import TOKEN
import random
bot = telebot.TeleBot(TOKEN)
country_easy={
'Москва': "Россия",
'Париж': "Франция",
"Абу-Даби": "Арабские Эмираты"
}
country_easy = ["Россия"]
@bot.message_handler(commands=['start'])
def start_messages(message):
bot.send_message(message.chat.id, 'Привет! Я бот-игра в столицы! Для начала игры введи /play')
@bot.message_handler(commands=['play'])
def play_message(message):
bot.send_message(message.chat.id, 'Выбирай сложность игры!')
markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
btn1 = types.KeyboardButton("Easy")
btn2 = types.KeyboardButton("Medium")
btn3 = types.KeyboardButton("High")
markup.add(btn1, btn2,btn3)
bot.send_message(message.chat.id,
text="Нажимай на кнопку для выбора сложности:".format(
message.from_user), reply_markup=markup)
@bot.message_handler(content_types=["text"])
def easy(message):
if (message.text == "Easy"):
markup = types.ReplyKeyboardRemove()
bot.send_message(message.chat.id, "Хороший выбор, давай начнем игру!",reply_markup=markup)
markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
btn1 = types.KeyboardButton("Запуск")
markup.add(btn1)
reply_markup = markup
msg = bot.send_message(message.chat.id, "Запускай игру!", reply_markup=markup)
bot.register_next_step_handler(msg, start_game)
@bot.message_handler(content_types=["text"])
def start_game(message):
if (message.text == "Запуск"):
bot.send_message(message.chat.id,"Игра запущена!")
markup = types.ReplyKeyboardRemove()
msg = bot.send_message(message.chat.id, "Какая столица у этой cтраны?", reply_markup=markup)
bot.register_next_step_handler(msg, easy_game)
def easy_game(message):
msg = bot.send_message(message.chat.id, random.choice(country_easy))
otvet = message.text
if otvet == ("Москва","Париж", "Арабские Эмираты"):
bot.send_message((message.chat.id,"Правильный ответ!"))
bot.send_message(message.chat.id, random.choice(country_easy))
else:
bot.send_message((message.chat.id, "Неправильный ответ!"))
if __name__ == '__main__':
bot.polling(none_stop=True)
</code>
<code>import telebot
from telebot import types
from config import TOKEN
import random
bot = telebot.TeleBot(TOKEN)
country_easy={
'Москва': "Россия",
'Париж': "Франция",
"Абу-Даби": "Арабские Эмираты"
}
country_easy = ["Россия"]
@bot.message_handler(commands=['start'])
def start_messages(message):
bot.send_message(message.chat.id, 'Привет! Я бот-игра в столицы! Для начала игры введи /play')
@bot.message_handler(commands=['play'])
def play_message(message):
bot.send_message(message.chat.id, 'Выбирай сложность игры!')
markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
btn1 = types.KeyboardButton("Easy")
btn2 = types.KeyboardButton("Medium")
btn3 = types.KeyboardButton("High")
markup.add(btn1, btn2,btn3)
bot.send_message(message.chat.id,
text="Нажимай на кнопку для выбора сложности:".format(
message.from_user), reply_markup=markup)
@bot.message_handler(content_types=["text"])
def easy(message):
if (message.text == "Easy"):
markup = types.ReplyKeyboardRemove()
bot.send_message(message.chat.id, "Хороший выбор, давай начнем игру!",reply_markup=markup)
markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
btn1 = types.KeyboardButton("Запуск")
markup.add(btn1)
reply_markup = markup
msg = bot.send_message(message.chat.id, "Запускай игру!", reply_markup=markup)
bot.register_next_step_handler(msg, start_game)
@bot.message_handler(content_types=["text"])
def start_game(message):
if (message.text == "Запуск"):
bot.send_message(message.chat.id,"Игра запущена!")
markup = types.ReplyKeyboardRemove()
msg = bot.send_message(message.chat.id, "Какая столица у этой cтраны?", reply_markup=markup)
bot.register_next_step_handler(msg, easy_game)
def easy_game(message):
msg = bot.send_message(message.chat.id, random.choice(country_easy))
otvet = message.text
if otvet == ("Москва","Париж", "Арабские Эмираты"):
bot.send_message((message.chat.id,"Правильный ответ!"))
bot.send_message(message.chat.id, random.choice(country_easy))
else:
bot.send_message((message.chat.id, "Неправильный ответ!"))
if __name__ == '__main__':
bot.polling(none_stop=True)
</code>
import telebot
from telebot import types
from config import TOKEN
import random
bot = telebot.TeleBot(TOKEN)
country_easy={
'Москва': "Россия",
'Париж': "Франция",
"Абу-Даби": "Арабские Эмираты"
}
country_easy = ["Россия"]
@bot.message_handler(commands=['start'])
def start_messages(message):
bot.send_message(message.chat.id, 'Привет! Я бот-игра в столицы! Для начала игры введи /play')
@bot.message_handler(commands=['play'])
def play_message(message):
bot.send_message(message.chat.id, 'Выбирай сложность игры!')
markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
btn1 = types.KeyboardButton("Easy")
btn2 = types.KeyboardButton("Medium")
btn3 = types.KeyboardButton("High")
markup.add(btn1, btn2,btn3)
bot.send_message(message.chat.id,
text="Нажимай на кнопку для выбора сложности:".format(
message.from_user), reply_markup=markup)
@bot.message_handler(content_types=["text"])
def easy(message):
if (message.text == "Easy"):
markup = types.ReplyKeyboardRemove()
bot.send_message(message.chat.id, "Хороший выбор, давай начнем игру!",reply_markup=markup)
markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
btn1 = types.KeyboardButton("Запуск")
markup.add(btn1)
reply_markup = markup
msg = bot.send_message(message.chat.id, "Запускай игру!", reply_markup=markup)
bot.register_next_step_handler(msg, start_game)
@bot.message_handler(content_types=["text"])
def start_game(message):
if (message.text == "Запуск"):
bot.send_message(message.chat.id,"Игра запущена!")
markup = types.ReplyKeyboardRemove()
msg = bot.send_message(message.chat.id, "Какая столица у этой cтраны?", reply_markup=markup)
bot.register_next_step_handler(msg, easy_game)
def easy_game(message):
msg = bot.send_message(message.chat.id, random.choice(country_easy))
otvet = message.text
if otvet == ("Москва","Париж", "Арабские Эмираты"):
bot.send_message((message.chat.id,"Правильный ответ!"))
bot.send_message(message.chat.id, random.choice(country_easy))
else:
bot.send_message((message.chat.id, "Неправильный ответ!"))
if __name__ == '__main__':
bot.polling(none_stop=True)