A library to create forms in aiogram3
Project description
aiogram3-form
A library to create forms in aiogram3
pip install aiogram3-form
Example
import asyncio
from aiogram import Bot, Dispatcher, F, Router
from aiogram3_form import Form, FormField
from aiogram.fsm.context import FSMContext
bot = Bot(token="YOUR_TOKEN")
dispatcher = Dispatcher()
router = Router()
dispatcher.include_router(router)
class NameForm(Form):
first_name: str = FormField(enter_message_text="Enter your first name please")
second_name: str = FormField(
enter_message_text="Enter your second name please",
filter=(F.text.len() > 10) & F.text,
)
age: int = FormField(enter_message_text="Enter age as integer")
@NameForm.submit(router=router)
async def name_form_submit_handler(form: NameForm):
# handle form data
# also supports aiogram standart DI (e. g. middlewares, filter data, etc)
await form.answer(f"{form.first_name} {form.second_name} of age {form.age}")
@router.message(F.text == "/form")
async def form_handler(_, state: FSMContext):
await NameForm.start(bot, state) # start your form
asyncio.run(dispatcher.start_polling(bot))
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
aiogram3_form-2.0.2.tar.gz
(5.3 kB
view details)
Built Distribution
File details
Details for the file aiogram3_form-2.0.2.tar.gz
.
File metadata
- Download URL: aiogram3_form-2.0.2.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.12.1 Darwin/23.2.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7932075f5e1f51f23ddc01bd5751fc95876425484bc1a7950a8a1564515712f1 |
|
MD5 | 28d07183a1c89b1030ff7b9910e6852a |
|
BLAKE2b-256 | 3a52f7f8882a0ca6c40304d8edd612973667e473c2ef8c1e7054a2ab2baf7f06 |
File details
Details for the file aiogram3_form-2.0.2-py3-none-any.whl
.
File metadata
- Download URL: aiogram3_form-2.0.2-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.12.1 Darwin/23.2.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5219b5dcf4ab10cc15ff43efb9a71af1d0ac12da404b9b9f1a6372c35ab4b713 |
|
MD5 | bf8f1f14f239b515f62bf07210b72403 |
|
BLAKE2b-256 | cbcc5d0cb235c702a5f4d48f40260c25bcb855f819c0b9e3c23233cd03f91029 |