Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import telebot
- import config
- from logic import *
- import sql
- from telebot import types
- import random
- bot = telebot.TeleBot(config.token)
- @bot.message_handler(commands=['start', 'help'])
- def welcome(message):
- #markup
- menu = types.InlineKeyboardMarkup()
- item1 = types.InlineKeyboardButton(text = 'Игра', callback_data='game')
- item2 = types.InlineKeyboardButton(text = 'Профиль', callback_data='profile')
- menu.add(item1,item2)
- #send message
- bot.send_message(message.chat.id, "Главное меню",reply_markup=menu, parse_mode='html')
- @bot.callback_query_handler(func=lambda call: call.data == i)
- def call(call):
- if call.data == sql.quiz(2)[6]:
- bot.edit_message_text('Верно',call.message.chat.id, call.message.message_id)
- else:
- bot.edit_message_text('Неверно',call.message.chat.id, call.message.message_id)
- @bot.callback_query_handler(func=lambda call: True)
- def callback(call):
- if call.data == 'game':
- #Inline markup | game type choose
- gameType = types.InlineKeyboardMarkup(row_width=1)
- item1 = types.InlineKeyboardButton(text = 'Тест', callback_data = 'testGame')
- item2 = types.InlineKeyboardButton(text = 'Бесконечные игра', callback_data = 'infinityGame')
- gameType.add(item1,item2)
- #send message with choos type game
- bot.edit_message_text('Игра',call.message.chat.id, call.message.message_id,reply_markup=gameType)
- if call.data == 'testGame':
- #generate message and markup
- numberQuiz = random.randint(1,57)
- #send message with question
- bot.edit_message_text('1-ый вопрос',call.message.chat.id, call.message.message_id,reply_markup=generateMarkup(2))
- if __name__ == "__main__":
- print("Good luck!")
- bot.infinity_polling()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement