Answer the question
In order to leave comments, you need to log in
Why is the bot not responding to text messages?
import telebot
import config
from telebot import types
bot = telebot.TeleBot(config.TOKEN)
@bot.message_handler(commands=['start'])
def start(message):
# keyboard
markup = types.ReplyKeyboardMarkup(resize_keyboard=True, one_time_keyboard =True)
item_social = types.KeyboardButton('Social Studies')
item_history = types.KeyboardButton('History')
item_literature = types.KeyboardButton('Literature')
item_russian = types.KeyboardButton('Russian')
markup.add(item_social, item_history, item_literature, item_russian)
# welcome message and keyboard output
bot.send_message(message.chat.id, ' Greetings! I'm your future school assistant bot AK nerd bot! ', reply_markup=markup)
# checking which subject is selected
@bot.message_handler(content_types=['text'])
def wichsubject(message):
if message.chat.type == 'private':
#DORM
if message.text == 'Socio':
markup = types.ReplyKeyboardMarkup(resize_keyboard=True, one_time_keyboard=True)
back = types.KeyboardButton( 'Back')
item_term1 = types.KeyboardButton('Absenteeism')
markup.add(back, item_term1)
bot.send_message(message.chat.id, 'You can enter a Social Studies term that interests you.', reply_markup=markup )
@bot.message_handler(content_types=['text'])
def send_infosocial(message):
if message.text == 'Absenteeism':
bot.send_message(message.chat.id, 'In constitutional law, a term for the voluntary non-participation of voters in an election or referendum vote.', reply_markup=markup)
else:
bot.send_message(message.chat.id, 'I don't know yet', reply_markup=markup) #HISTORY
elif
message.text == 'History':
markup = types.ReplyKeyboardMarkup(resize_keyboard=True, one_time_keyboard=True)
back = types.KeyboardButton('Back')
markup.add(back)
bot.send_message(message.chat.id, 'You can enter the historical event date or term you are interested in.', reply_markup=markup)
@bot.message_handler(content_types=['text'])
def send_infohistory(message):
if message .text == '1941':
bot.send_message(message.chat.id, 'World War II.', reply_markup=markup)
elif '1861' in message.text.lower():
bot.send_message(message.chat. id, 'Abolition of serfdom', reply_markup=markup)
else:
bot.send_message(message.chat.id, 'I don't know yet', reply_markup=markup)
# LITERATURE
elif message.text == 'Literature':
markup = types.ReplyKeyboardMarkup(resize_keyboard=True, one_time_keyboard=True)
back = types.KeyboardButton('Back')
markup.add(back)
bot.send_message(message.chat.id, 'You can enter the name of the work without quotes, and I will try to show a brief information about it.', reply_markup=markup)
# RUSSIAN
elif message.text == 'Russian':
markup = types.ReplyKeyboardMarkup(resize_keyboard=True, one_time_keyboard=True)
back = types.KeyboardButton('Back')
markup.add(back)
bot.send_message(message.chat .id, 'You can enter the rule you are interested in, and I will try to define it.', reply_markup=markup)
# If the Back Button is selected
elif message.text == 'Back':
# keyboard
markup = types.ReplyKeyboardMarkup(resize_keyboard=True, one_time_keyboard=True)
item_social = types.KeyboardButton('Social Studies')
item_history = types.KeyboardButton('History')
item_literature = types.KeyboardButton('Literature')
item_russian = types.KeyboardButton( 'Russian language')
markup.add(item_social, item_history, item_literature, item_russian)
bot.send_message(message.chat.id, 'Select the subject you want to learn', reply_markup=markup)
# RUN
while True:
try:
bot.polling (none_stop=True)
except Exception as e:
print(e)
time.sleep(15)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question