Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import telebot
- from telebot import types
- bot = telebot.TeleBot("TOKEN")
- @bot.message_handler(commands=['start'])
- def start(message):
- markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
- item1 = types.KeyboardButton("Выбрать тему")
- item2 = types.KeyboardButton("О авторе")
- markup.add(item1, item2)
- bot.send_message(message.chat.id, f"Привет, {message.from_user.first_name}, я ваш бот! Выберите действие:",
- reply_markup=markup)
- @bot.message_handler(func=lambda message: message.text == "Выбрать тему")
- def choose_topic(message):
- topics_markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
- topic1 = types.KeyboardButton('Бинарный поиск')
- topic2 = types.KeyboardButton('Сортировки')
- topic3 = types.KeyboardButton('Теория графов')
- topic4 = types.KeyboardButton('Динамическое программирование')
- back = types.KeyboardButton("Назад")
- topics_markup.add(topic1, topic2, topic3, topic4, back)
- bot.send_message(message.chat.id, "Выберите тему:", reply_markup=topics_markup)
- @bot.message_handler(func=lambda message: message.text == "О авторе")
- def about_author(message):
- markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
- back = types.KeyboardButton("Назад")
- markup.add(back)
- text = 'Данный бот поможет вам освоить базу алгоритмического программирования. С помощью видеоуроков или статей вы можете изучить материал и закрепить приложенными задачами. Желаю удачи!\nПо вопросам пишите @zuneve'
- bot.send_message(message.chat.id, f"Привет!\n{text}", reply_markup=markup)
- @bot.message_handler(func=lambda message: message.text == "Бинарный поиск")
- def topic1_info(message):
- markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
- back = types.KeyboardButton("Назад")
- markup.add(back)
- text = "https://telegra.ph/Binary-search-Binarnyj-poisk-04-11"
- bot.send_message(message.chat.id, f"Бинарный поиск\n{text}", reply_markup=markup)
- @bot.message_handler(func=lambda message: message.text == "Сортировки")
- def topic2_info(message):
- markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
- back = types.KeyboardButton("Назад")
- markup.add(back)
- text = "https://telegra.ph/Sortirovki-04-11"
- bot.send_message(message.chat.id, f"Сортировки\n{text}", reply_markup=markup)
- @bot.message_handler(func=lambda message: message.text == "Теория графов")
- def topic2_info(message):
- markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
- back = types.KeyboardButton("Назад")
- markup.add(back)
- text = "https://telegra.ph/Teoriya-grafov-04-11"
- bot.send_message(message.chat.id, f"Теория графов\n{text}", reply_markup=markup)
- @bot.message_handler(func=lambda message: message.text == "Динамическое программирование")
- def topic2_info(message):
- markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
- back = types.KeyboardButton("Назад")
- markup.add(back)
- text = 'https://telegra.ph/Dinamicheskoe-programmirovanie-04-11'
- bot.send_message(message.chat.id, f"Динамическое программирование\n{text}", reply_markup=markup)
- @bot.message_handler(func=lambda message: message.text == "Назад")
- def go_back(message):
- markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
- item1 = types.KeyboardButton("Выбрать тему")
- item2 = types.KeyboardButton("О авторе")
- markup.add(item1, item2)
- bot.send_message(message.chat.id, "Выберите действие:", reply_markup=markup)
- bot.polling(none_stop=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement