@kyberscholnik123

Почему бот не отвечает на текстовые собщения?

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('Обществознание')
item_history = types.KeyboardButton('История')
item_literature = types.KeyboardButton('Литература')
item_russian = types.KeyboardButton('Русский язык')

markup.add(item_social, item_history, item_literature, item_russian)

# приветственное сообщение и вывод клавиатуры
bot.send_message(message.chat.id, ' Приветствую тебя! Я твой будущий бот помошник по школьной программе AK ботан бот! ', reply_markup=markup)

# проверка какой предмет выбран
@bot.message_handler(content_types=['text'])
def wichsubject(message):
if message.chat.type == 'private':
#ОБЩАГА
if message.text == 'Обществознание':

markup = types.ReplyKeyboardMarkup(resize_keyboard=True, one_time_keyboard=True)
back = types.KeyboardButton('Назад')
item_term1 = types.KeyboardButton('Абсентеизм')
markup.add(back, item_term1)

bot.send_message(message.chat.id, 'Вы можете ввести интересующий вас термин из курса Обществознания.', reply_markup=markup )

@bot.message_handler(content_types=['text'])
def send_infosocial(message):
if message.text == 'Абсентеизм':
bot.send_message(message.chat.id, 'В науке конституционного права термин, означающий добровольное неучастие избирателей в голосовании на выборах или референдуме.', reply_markup=markup)
else:
bot.send_message(message.chat.id, 'Пока я этого не знаю', reply_markup=markup)

#ИСТОРИЯ
elif message.text == 'История':
markup = types.ReplyKeyboardMarkup(resize_keyboard=True, one_time_keyboard=True)
back = types.KeyboardButton('Назад')
markup.add(back)

bot.send_message(message.chat.id, 'Вы можете ввести интересующую вас дату исторического события, или термин.', reply_markup=markup)

@bot.message_handler(content_types=['text'])
def send_infohistory(message):
if message.text == '1941':
bot.send_message(message.chat.id, 'Великая Отечественная война.', reply_markup=markup)

elif '1861' in message.text.lower():
bot.send_message(message.chat.id, 'Отмена крепостного права', reply_markup=markup)

else:
bot.send_message(message.chat.id, 'Пока я этого не знаю', reply_markup=markup)


# ЛИТЕРАТУРА
elif message.text == 'Литература':
markup = types.ReplyKeyboardMarkup(resize_keyboard=True, one_time_keyboard=True)
back = types.KeyboardButton('Назад')
markup.add(back)


bot.send_message(message.chat.id, 'Вы можете ввести название произведения без кавычек, а я постараюсь показать краткую информацию о нем.', reply_markup=markup)

# РУССКИЙ
elif message.text == 'Русский язык':
markup = types.ReplyKeyboardMarkup(resize_keyboard=True, one_time_keyboard=True)
back = types.KeyboardButton('Назад')
markup.add(back)
bot.send_message(message.chat.id, 'Вы можете ввести интересующее вас правило , а я постараюсь выдать на него определение.', reply_markup=markup)



# Если выбрана Кнопка Назад
elif message.text == 'Назад':
# keyboard
markup = types.ReplyKeyboardMarkup(resize_keyboard=True, one_time_keyboard=True)
item_social = types.KeyboardButton('Обществознание')
item_history = types.KeyboardButton('История')
item_literature = types.KeyboardButton('Литература')
item_russian = types.KeyboardButton('Русский язык')

markup.add(item_social, item_history, item_literature, item_russian)

bot.send_message(message.chat.id, 'Выберите предмет, который хотите изучить', reply_markup=markup)



# RUN
while True:
try:
bot.polling(none_stop=True)

except Exception as e:
print(e)

time.sleep(15)
  • Вопрос задан
  • 95 просмотров
Пригласить эксперта
Ваш ответ на вопрос

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

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