Skip to content

Inline keyboard

Misol

import telebot
from telebot import types

bot = telebot.TeleBot("TOKEN")

# Inline keyboard
@bot.message_handler(commands=['inline'])
def inline_keyboard(message):
    inline_keyboard_ = types.InlineKeyboardMarkup(row_width=1)
    inline_keyboard_.add(types.InlineKeyboardButton(text="1", callback_data='1'),
                         types.InlineKeyboardButton(text="2", callback_data='1'))
    inline_keyboard_.add(types.InlineKeyboardButton(text="3", callback_data='1'))
    bot.send_message(
        chat_id=message.chat.id,
        text="Klavyatura",
        parse_mode='html',
        reply_markup=inline_keyboard_
    )


@bot.callback_query_handler(func=lambda call: True)
def call_back(call):
    bot.answer_callback_query(call.id, f"Ogohlantirish: {call.data}", show_alert=False)