Advertisement
Guest User

Untitled

a guest
Feb 29th, 2020
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. import telebot
  2. import config
  3. from logic import *
  4. import sql
  5. from telebot import types
  6. import random
  7.  
  8. bot = telebot.TeleBot(config.token)
  9.  
  10.  
  11. @bot.message_handler(commands=['start', 'help'])
  12. def welcome(message):
  13. #markup
  14. menu = types.InlineKeyboardMarkup()
  15. item1 = types.InlineKeyboardButton(text = 'Игра', callback_data='game')
  16. item2 = types.InlineKeyboardButton(text = 'Профиль', callback_data='profile')
  17. menu.add(item1,item2)
  18. #send message
  19. bot.send_message(message.chat.id, "Главное меню",reply_markup=menu, parse_mode='html')
  20.  
  21. @bot.callback_query_handler(func=lambda call: call.data == i)
  22. def call(call):
  23. if call.data == sql.quiz(2)[6]:
  24. bot.edit_message_text('Верно',call.message.chat.id, call.message.message_id)
  25. else:
  26. bot.edit_message_text('Неверно',call.message.chat.id, call.message.message_id)
  27.  
  28. @bot.callback_query_handler(func=lambda call: True)
  29. def callback(call):
  30. if call.data == 'game':
  31. #Inline markup | game type choose
  32. gameType = types.InlineKeyboardMarkup(row_width=1)
  33. item1 = types.InlineKeyboardButton(text = 'Тест', callback_data = 'testGame')
  34. item2 = types.InlineKeyboardButton(text = 'Бесконечные игра', callback_data = 'infinityGame')
  35. gameType.add(item1,item2)
  36. #send message with choos type game
  37. bot.edit_message_text('Игра',call.message.chat.id, call.message.message_id,reply_markup=gameType)
  38.  
  39. if call.data == 'testGame':
  40. #generate message and markup
  41. numberQuiz = random.randint(1,57)
  42. #send message with question
  43. bot.edit_message_text('1-ый вопрос',call.message.chat.id, call.message.message_id,reply_markup=generateMarkup(2))
  44.  
  45.  
  46.  
  47. if __name__ == "__main__":
  48. print("Good luck!")
  49. bot.infinity_polling()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement