Telegram bot math-trainer

Viewed 25

I'm writing a bot for a school project, a kind of math simulator.So far I am writing, only so that there are examples for the multiplication table, cause the rest of the operations are done by analogy. But I'm stuck right here:

import telebot
import random
from telebot import types
bot = telebot.TeleBot('5787735353:AAFm4z24mGxK_CJ8uyvO6tR0T6yGhFqn2xI')
@bot.message_handler(commands=['start'])

def start(message):
    markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
    btn1 = types.KeyboardButton("✖Умножение")
    btn2 = types.KeyboardButton("➗Деление")
    btn3 = types.KeyboardButton("➕Сложение")
    btn4 = types.KeyboardButton("➖Вычитание")
    markup.add(btn1, btn2,btn3,btn4)
    bot.send_message(message.chat.id,"Привет!Выбери режим".format(message.from_user), reply_markup=markup)

@bot.message_handler(content_types=['text'])
def get_text_messages(message):
    if message.text == "✖Умножение":
        a=random.randint(1,10)
        b=random.randint(1,10)
        bot.send_message(message.chat.id,str(a) + "x" + str(b) + "=" )
        if message.text == str(a*b):
            bot.send_message(message.chat.id, "Молодец! Правильно!")

bot.polling(none_stop=True, interval=0)

I don't understand how to check the user's answer to the example given by the bot, the way I tried to write it doesn't work.

0 Answers
Related