Dolban1337

Untitled

Aug 30th, 2020
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.12 KB | None | 0 0
  1. import telebot
  2. from telebot.types import InlineKeyboardMarkup, InlineKeyboardButton
  3.  
  4. bot = telebot.TeleBot('1331182453:AAFJnouzpJeoi5jYKK8EddDFJ-t8ZI8bilc')
  5.  
  6. keyboardMain = InlineKeyboardMarkup()
  7. keyboardMain.row_width = 1
  8. keyboardMain.add(InlineKeyboardButton("Раздел 1", callback_data="section1"))
  9.  
  10.  
  11. keyboardBt = InlineKeyboardMarkup()
  12. keyboardBt.row_width = 1
  13. keyboardBt.add(InlineKeyboardButton("Кнопка 1", callback_data="bt1"))
  14.  
  15.  
  16.  
  17.  
  18. @bot.message_handler(commands=['start'])
  19. def start(message):
  20.     bot.send_message(message.chat.id, 'Привет очередной.', reply_markup=keyboardMain)
  21.  
  22.  
  23.  
  24.  
  25. @bot.callback_query_handler(func=lambda call: True)
  26. def callback_query(call):
  27.     if call.data == 'section1':
  28.         msg = bot.send_message(call.from_user.id, 'текст', reply_markup=keyboardBt)
  29.         bot.register_next_step_handler(msg, button)
  30.         print(call.data)
  31.         if call.data == 'bt1':
  32.             bot.send_message(call.from_user.id, 'какой-то текст')
  33.  
  34. #def button(call):
  35. #   print(call.data)
  36. #   if call.data == 'bt1':
  37. #       bot.send_message(call.from_user.id, 'какой-то текст')
  38. bot.polling()
Advertisement
Add Comment
Please, Sign In to add comment