Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import asyncio
- from aiogram import Bot, Dispatcher, types
- from aiogram import executor
- """example_bot"""
- API_TOKEN = "7286581991:AAFGS0iOufIK4-NSQs2HXIgRV8r2hiyRzTY"
- bot = Bot(token=API_TOKEN)
- dp = Dispatcher(bot)
- """Урок с кнопками Inline"""
- @dp.message_handler(commands=["start"])
- async def start_handler(message: types.Message):
- keyboard = types.InlineKeyboardMarkup(row_width=2)
- button_photo1 = types.InlineKeyboardButton("фото1", callback_data="photo1")
- button_photo2 = types.InlineKeyboardButton("фото2", callback_data="photo2")
- keyboard.add(button_photo1, button_photo2)
- await bot.send_message(message.chat.id,"Привет!", reply_markup=keyboard)
- @dp.message_handler(commands=["help"])
- async def help_handler(message: types.Message):
- await message.reply("Помощь!")
- print(message)
- @dp.callback_query_handler(text="photo1")
- async def photo_handler(callback: types.CallbackQuery):
- await bot.send_photo(callback.from_user.id, photo="https://static.wikia.nocookie.net/heartforest/images/d/d5/S1200_%285%29.jpg/revision/latest?cb=20191028134430&path-prefix=ru")
- print(callback)
- if __name__ == "__main__":
- executor.start_polling(dp, skip_updates=True)
Advertisement
Add Comment
Please, Sign In to add comment