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.1.tar.gz
(5.2 kB
view details)
Built Distribution
File details
Details for the file aiogram3_form-2.0.1.tar.gz
.
File metadata
- Download URL: aiogram3_form-2.0.1.tar.gz
- Upload date:
- Size: 5.2 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 | b7f3a99ec9943debe3fbb994628dc28ad19e95a0ef989972557f81c23d910781 |
|
MD5 | 49d596eaa182103cab021a48a7b0a258 |
|
BLAKE2b-256 | 25ae23e8e72c44ca0a454510f7a80c4924f3472b377d7f0ba0aa70ec93160f61 |
File details
Details for the file aiogram3_form-2.0.1-py3-none-any.whl
.
File metadata
- Download URL: aiogram3_form-2.0.1-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 | a12bb6647bb621a98d373024e7acf9e68fe09894d1040984759a1099a4b29f07 |
|
MD5 | ecedee471ca2eace0662628ce190a9d8 |
|
BLAKE2b-256 | 55ec1a0464acbdb6a5ce462a442a302e21d97d394a6eea67e88af8df69b9bd69 |