from telebot.async_telebot import AsyncTeleBot
import asyncio
import telebot
bot = AsyncTeleBot('5880261952:AAHBDo6Tf5pDpBVVmf27Q-2dATVVi_rhjoU')
@bot.message_handler(commands=['button'])
async def send_welcome(message):
keyboard = telebot.types.ReplyKeyboardMarkup(resize_keyboard=True)
keyboard.row('Button 1', 'Button 2')
keyboard.row('Button 3', 'Button 4', 'Button 5')
await bot.send_message(message.chat.id, "Hi! Press a button:", reply_markup=keyboard)
@bot.message_handler(func=lambda message: message.text == 'Button 1')
async def handle_button_press(message):
await bot.send_message(message.chat.id, "You pressed button 1!")
keyboard = telebot.types.ReplyKeyboardMarkup(resize_keyboard=True, one_time_keyboard=True)
keyboard.row('Button 1', 'Button 2')
await bot.send_message(message.chat.id, "Hi! Press a button:", reply_markup=keyboard)
@bot.message_handler(commands=['start'])
async def send_welcome(message):
keyboard = telebot.types.InlineKeyboardMarkup()
url_button = telebot.types.InlineKeyboardButton(text='Open Google', url='https://www.google.com')
callback_button = telebot.types.InlineKeyboardButton(text='Click me', callback_data='test')
keyboard.add(url_button, callback_button)
await bot.send_message(message.chat.id, "Hi! Press a button:", reply_markup=keyboard)
@bot.callback_query_handler(func=lambda call: True)
async def callback_query(call):
if call.data == 'test':
await bot.answer_callback_query(call.id, "You clicked the button!")
asyncio.run(bot.polling())
0 Comments