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-1.0.2.tar.gz
(5.2 kB
view details)
Built Distribution
File details
Details for the file aiogram3_form-1.0.2.tar.gz
.
File metadata
- Download URL: aiogram3_form-1.0.2.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 | 31dd133744d7c6ab0e6b671f73c38b4aacddca264c8fd49a2e0820df80e993e3 |
|
MD5 | a287469c36f87f0da760223d3d070db6 |
|
BLAKE2b-256 | 87cc1ab2b0ecfcbc2e0fd3750e7c64cda87eee8eae76cf7b1dfc77953e59ad1e |
File details
Details for the file aiogram3_form-1.0.2-py3-none-any.whl
.
File metadata
- Download URL: aiogram3_form-1.0.2-py3-none-any.whl
- Upload date:
- Size: 6.5 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 | 54952d16dd73d309864e6e293ab1b00c0f3d50d71503f969c5b4321152ce8ae1 |
|
MD5 | 71fd2378ebe2ef701789f782941135bf |
|
BLAKE2b-256 | 1f679856e2ffdbab6d4e00dc910cca0fb04a5cdd9846f2c43bac3cfada5e5f36 |