Сообщество IT-специалистов
Ответы на любые вопросы об IT
Профессиональное развитие в IT
Удаленная работа для IT-специалистов
import telebot
from telebot import types
bot = telebot.TeleBot("тут токен")
@bot.message_handler(commands=['start'])
def start(message):
bot.send_message(message.chat.id, 'виберіть розмір холсту', reply_markup=keyboard_page1())
def keyboard_page1():
keyboard = types.InlineKeyboardMarkup(row_width=2)
btn1 = types.InlineKeyboardButton(text="3x3", callback_data="3x3")
btn2 = types.InlineKeyboardButton(text="4x4", callback_data="4x4")
btn3 = types.InlineKeyboardButton(text="5x5", callback_data="5x5")
keyboard.add(btn1,btn2,btn3)
return keyboard
def keyboard_page2():
keyboard = types.InlineKeyboardMarkup(row_width=3)
btn1 = types.InlineKeyboardButton(text="⬜️", callback_data="1")
btn2 = types.InlineKeyboardButton(text="⬜️", callback_data="2")
btn3 = types.InlineKeyboardButton(text="⬜️", callback_data="3")
btn4 = types.InlineKeyboardButton(text="⬜️", callback_data="4")
btn5 = types.InlineKeyboardButton(text="⬜️", callback_data="5")
btn6 = types.InlineKeyboardButton(text="⬜️", callback_data="6")
btn7 = types.InlineKeyboardButton(text="⬜️", callback_data="7")
btn8 = types.InlineKeyboardButton(text="⬜️", callback_data="8")
btn9 = types.InlineKeyboardButton(text="⬜️", callback_data="9")
keyboard.add(btn1,btn2,btn3,btn4,btn5,btn6,btn7,btn8,btn9)
return keyboard
@bot.callback_query_handler(func = lambda call: True)
def callback(call):
if call.data == "3x3":
bot.edit_message_text(
chat_id = call.message.chat.id,
text = "знизу палітра, а тепер малюйте",
message_id = call.message.message_id,
reply_markup = keyboard_page2()
)
if call.data == "4x4":
bot.edit_message_text(
chat_id = call.message.chat.id,
text = "First page of keyboard.",
message_id = call.message.message_id,
reply_markup = keyboard_page1()
)
bot.infinity_polling()