Доброго вечера!!!
Пишу асинхронного бота в библиотеке aiogram,и незнаю почему невиходить зделать клавиатуру.
Буду благодарний за подсказки.
@dp.message_handler(commands=["Час"])
async def sendInlineMessageForBookingTime(message: types.Message):
global buttons
current_time = datetime.datetime.now()
current_hour = str(current_time)[11:13]
if int(current_hour) < 8:
buttons = [
types.InlineKeyboardButton(text='8:00'),
types.InlineKeyboardButton(text='9:00'),
types.InlineKeyboardButton(text='10:00'),
types.InlineKeyboardButton(text='11:00'),
types.InlineKeyboardButton(text='12:00'),
types.InlineKeyboardButton(text='13:00'),
types.InlineKeyboardButton(text='14:00'),
types.InlineKeyboardButton(text='15:00'),
types.InlineKeyboardButton(text='16:00'),
types.InlineKeyboardButton(text='17:00'),
types.InlineKeyboardButton(text='18:00'),
types.InlineKeyboardButton(text='19:00'),
]
elif 8 <= int(current_hour) < 10:\
buttons = [
types.InlineKeyboardButton(text='10:00'),
types.InlineKeyboardButton(text='11:00'),
types.InlineKeyboardButton(text='12:00'),
types.InlineKeyboardButton(text='13:00'),
types.InlineKeyboardButton(text='14:00'),
types.InlineKeyboardButton(text='15:00'),
types.InlineKeyboardButton(text='16:00'),
types.InlineKeyboardButton(text='17:00'),
types.InlineKeyboardButton(text='18:00'),
types.InlineKeyboardButton(text='19:00'),
]
elif 10 <= int(current_hour) < 12:\
buttons = [
types.InlineKeyboardButton(text='12:00'),
types.InlineKeyboardButton(text='13:00'),
types.InlineKeyboardButton(text='14:00'),
types.InlineKeyboardButton(text='15:00'),
types.InlineKeyboardButton(text='16:00'),
types.InlineKeyboardButton(text='17:00'),
types.InlineKeyboardButton(text='18:00'),
types.InlineKeyboardButton(text='19:00'),
]
elif 12 <= int(current_hour) < 14:\
buttons = [
types.InlineKeyboardButton(text='14:00'),
types.InlineKeyboardButton(text='15:00'),
types.InlineKeyboardButton(text='16:00'),
types.InlineKeyboardButton(text='17:00'),
types.InlineKeyboardButton(text='18:00'),
types.InlineKeyboardButton(text='19:00'),
]
elif 14 <= int(current_hour) < 16:\
buttons= [
types.InlineKeyboardButton(text='16:00'),
types.InlineKeyboardButton(text='17:00'),
types.InlineKeyboardButton(text='18:00'),
types.InlineKeyboardButton(text='19:00'),
]
elif 16 <= int(current_hour) < 18:\
buttons = [
types.InlineKeyboardButton(text='18:00'),
types.InlineKeyboardButton(text='19:00'),
]
elif 18 <= int(current_hour) < 20:\
buttons = [
types.InlineKeyboardButton(text='19:00'),
]
keyboard = types.InlineKeyboardMarkup(row_width=2)
keyboard.row(*buttons)
await bot.send_message(message.chat.id, f"{message.from_user.last_name} виберіть зручний час для запису",reply_markup=keyboard)