state="*", func=(lambda call: call.metadata.startswith('welcome-menu-'))) async def menu_handler(qb: QuickButtonSelected): text = 'You chose' if qb.metadata.endswith('inline'): text += ' inline buttons' await bot.send_message(qb.dialog.id, text, inline_commands=INLINE_COMMAND_MENU) if qb.metadata.endswith('reply'): text += ' reply buttons' await bot.send_message(qb.dialog.id, text, reply_keyboard=REPLY_COMMAND_MENU) if qb.metadata.endswith('quick'): text += ' quick buttons' await bot.send_message(qb.dialog.id, text, quick_button_commands=QUICK_BUTTON_COMMAND_MENU) @dp.inline_command_handler( state="*", func=(lambda call: call.metadata.startswith('inline-command-data-'))) async def inline_menu_handler(ic: InlineCommandSelected): await bot.send_message( ic.dialog.id, "Got data from inline command: {}".format(ic.metadata)) if __name__ == '__main__': executor.start_polling(dp)
options=Options(closeable=True)) bottom_bar = BottomBar(content_id="bottom_bar_id", title="Bottom Bar", form_action=FormAction( action="submit_form", data_template="Message from bottom bar")) return Form(_id=form_id, header=header, content=[], bottom_bar=bottom_bar) @dispatcher.message_handler() async def handle(message: Message): form = make_form() await bot.send_form(message.chat.id, form=form) @dispatcher.form_submitted_handler() async def handle_submission(submitted_form: FormSubmitted): await bot.send_message( submitted_form.chat.id, "Oh, it seems I have received text from you, look:\n" + f"{submitted_form.metadata}") @dispatcher.form_closed_handler() async def handle_form_closing(closed_form: FormClosed): await bot.send_message(closed_form.chat.id, "Form is closed") if __name__ == '__main__': executor.start_polling(dispatcher)