import asyncio
from aiogram import Bot,Dispatcher,types
from aiogram.filters.command import Command
from api_token import TOKEN
from aiogram.utils.keyboard import InlineKeyboardBuilder,InlineKeyboardButton
from aiogram.types import CallbackQuery
from random import randint
from aiogram import F
bot = Bot(TOKEN)
dp = Dispatcher()
@dp.message(Command('start'))
async def start_command(message: types.Message):
await message.answer('Привет, я бот!')
@dp.message(Command('random_number'))
async def random_number_command(message: types.Message):
builder = InlineKeyboardBuilder()
builder.add(InlineKeyboardButton(text='Выберите число от 1 до 10', callback_data='random_value'))
await message.answer('Нажмите на кнопку', reply_murkup=builder.as_markup())
@dp.callback_query(F.data == 'random_value')
async def send_random_value(callback: CallbackQuery):
await callback.message.answer(str(randint(1,10)))
await callback.answer("Спасибо за использование бота!", show_alert=True)
async def main():
await bot.delete_webhook(drop_pending_updates=True)
await dp.start_polling(bot)
if __name__ == '__main__':
asyncio.run(main())