Requests clients to resize the keyboard vertically for optimal fit (e.g., make the keyboard smaller if there are just two rows of buttons). Defaults to false, in which case the custom keyboard is always of the same height as the app's standard keyboard.
@form_router.message(Form.name)
async def process_name(message: Message, state: FSMContext):
@form_router.message(Form.name)
async def process_name(message: Message, state: FSMContext):
await state.update_data(name=message.text)
await message.answer('Выберите кнопку ниже', reply_markup=ReplyKeyboardMarkup(keyboard=[[KeyboardButton(text='Купить'),KeyboardButton(text='Продать'),]],resize_keyboard=True,))
if message.text == 'Продать':
await state.set_state(Form.kolvo)
await message.answer('Введи количество')
from aiogram.filters import BaseFilter
admin_ids = [123, 456]
class IsAdmin(BaseFilter):
def __init__(self, admin_ids) -> None:
self.admin_ids = admin_ids
async def __call__(self, message: Message) -> bool:
return message.from_user.id in self.admin_ids
@router.message(IsAdmin(admin_ids), F.text == "admin")
async def admin_handler(message: Message) -> None:
kb_admin = [
[types.KeyboardButton(text="Статистика")],
[types.KeyboardButton(text="Выход")],
[types.KeyboardButton(text="Настройки")],
]
keyboard_admin = types.ReplyKeyboardMarkup(
keyboard=kb_admin,
resize_keyboard=True
)
await message.answer("Меню администратора", reply_markup=keyboard_admin)
KeyboardButton(
text="Группа с форумами",
request_chat=types.KeyboardButtonRequestChat(
request_id=1,
chat_is_channel=False,
chat_is_forum=True
)
)
from aiogram.dispatcher.filters import Filter
admins = [12345, 67890]
class IsAdmin(Filter):
async def check_adm(self, message: types.Message):
return message.from_user.id in admins
@dp.message_handler(IsAdmin())
async def admin_handler(message: types.Message):
await message.reply("Это админ")
@dp.message(Command("hello"))
async def hello(message: types.Message):
builder = InlineKeyboardBuilder()
builder.add(types.InlineKeyboardButton(text='rrtgtgt'))
await message.reply('Hello', reply_markup=builder)
class aiogram.types.inline_keyboard_markup.InlineKeyboardMarkup(*, inline_keyboard: List[List[InlineKeyboardButton]], **extra_data: Any)
inline_keyboard: List[List[InlineKeyboardButton]]
Array of button rows, each represented by an Array of aiogram.types.inline_keyboard_button.InlineKeyboardButton objects