Advertisement
Zuneve

TG BOT by Zuneve

Jul 11th, 2024
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.97 KB | None | 0 0
  1. import telebot
  2. from telebot import types
  3. bot = telebot.TeleBot("TOKEN")
  4.  
  5.  
  6. @bot.message_handler(commands=['start'])
  7. def start(message):
  8.     markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
  9.     item1 = types.KeyboardButton("Выбрать тему")
  10.     item2 = types.KeyboardButton("О авторе")
  11.     markup.add(item1, item2)
  12.  
  13.     bot.send_message(message.chat.id, f"Привет, {message.from_user.first_name}, я ваш бот! Выберите действие:",
  14.                      reply_markup=markup)
  15.  
  16.  
  17. @bot.message_handler(func=lambda message: message.text == "Выбрать тему")
  18. def choose_topic(message):
  19.     topics_markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
  20.     topic1 = types.KeyboardButton('Бинарный поиск')
  21.     topic2 = types.KeyboardButton('Сортировки')
  22.     topic3 = types.KeyboardButton('Теория графов')
  23.     topic4 = types.KeyboardButton('Динамическое программирование')
  24.     back = types.KeyboardButton("Назад")
  25.     topics_markup.add(topic1, topic2, topic3, topic4, back)
  26.  
  27.     bot.send_message(message.chat.id, "Выберите тему:", reply_markup=topics_markup)
  28.  
  29.  
  30. @bot.message_handler(func=lambda message: message.text == "О авторе")
  31. def about_author(message):
  32.     markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
  33.     back = types.KeyboardButton("Назад")
  34.     markup.add(back)
  35.     text = 'Данный бот поможет вам освоить базу алгоритмического программирования. С помощью видеоуроков или статей вы можете изучить материал и закрепить приложенными задачами. Желаю удачи!\nПо вопросам пишите @zuneve'
  36.     bot.send_message(message.chat.id, f"Привет!\n{text}", reply_markup=markup)
  37.  
  38.  
  39. @bot.message_handler(func=lambda message: message.text == "Бинарный поиск")
  40. def topic1_info(message):
  41.     markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
  42.     back = types.KeyboardButton("Назад")
  43.     markup.add(back)
  44.  
  45.     text = "https://telegra.ph/Binary-search-Binarnyj-poisk-04-11"
  46.     bot.send_message(message.chat.id, f"Бинарный поиск\n{text}", reply_markup=markup)
  47.  
  48.  
  49. @bot.message_handler(func=lambda message: message.text == "Сортировки")
  50. def topic2_info(message):
  51.     markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
  52.     back = types.KeyboardButton("Назад")
  53.     markup.add(back)
  54.     text = "https://telegra.ph/Sortirovki-04-11"
  55.     bot.send_message(message.chat.id, f"Сортировки\n{text}", reply_markup=markup)
  56.  
  57.  
  58. @bot.message_handler(func=lambda message: message.text == "Теория графов")
  59. def topic2_info(message):
  60.     markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
  61.     back = types.KeyboardButton("Назад")
  62.     markup.add(back)
  63.     text = "https://telegra.ph/Teoriya-grafov-04-11"
  64.     bot.send_message(message.chat.id, f"Теория графов\n{text}", reply_markup=markup)
  65.  
  66.  
  67. @bot.message_handler(func=lambda message: message.text == "Динамическое программирование")
  68. def topic2_info(message):
  69.     markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
  70.     back = types.KeyboardButton("Назад")
  71.     markup.add(back)
  72.     text = 'https://telegra.ph/Dinamicheskoe-programmirovanie-04-11'
  73.     bot.send_message(message.chat.id, f"Динамическое программирование\n{text}", reply_markup=markup)
  74.  
  75.  
  76. @bot.message_handler(func=lambda message: message.text == "Назад")
  77. def go_back(message):
  78.     markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
  79.     item1 = types.KeyboardButton("Выбрать тему")
  80.     item2 = types.KeyboardButton("О авторе")
  81.     markup.add(item1, item2)
  82.  
  83.     bot.send_message(message.chat.id, "Выберите действие:", reply_markup=markup)
  84.  
  85.  
  86. bot.polling(none_stop=True)
Tags: tg_bot
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement