
Security News
/Research
npm Phishing Email Targets Developers with Typosquatted Domain
A phishing attack targeted developers using a typosquatted npm domain (npnjs.com) to steal credentials via fake login pages - watch out for similar scams.
aiogram-forms
is an addition for aiogram
which allows you to create different forms and process user input step by step easily.
Documentation can be found here.
pip install aiogram-forms
Create form you need by subclassing aiogram_forms.forms.Form
. Fields can be added from aiogram_forms.forms.fields
subpackage.
from aiogram_forms import dispatcher
from aiogram_forms.forms import Form, fields, FormsManager
from aiogram_forms.errors import ValidationError
def validate_username_format(value: str):
"""Validate username starts with leading @."""
if not value.startswith('@'):
raise ValidationError('Username should starts with "@".', code='username_prefix')
@dispatcher.register('test-form')
class TestForm(Form):
username = fields.TextField(
'Username', min_length=4, validators=[validate_username_format],
error_messages={'min_length': 'Username must contain at least 4 characters!'}
)
email = fields.EmailField('Email', help_text='We will send confirmation code.')
phone = fields.PhoneNumberField('Phone number', share_contact=True)
language = fields.ChoiceField('Language', choices=(
('English', 'en'),
('Russian', 'ru')
))
@classmethod
async def callback(cls, message: types.Message, forms: FormsManager, **data) -> None:
data = await forms.get_data('test-form') # Get form data from state
await message.answer(
text=f'Thank you, {data["username"]}!',
reply_markup=types.ReplyKeyboardRemove() # Use this for reset if last field contains keyboard
)
router = Router()
@router.message(Command(commands=['start']))
async def command_start(message: types.Message, forms: FormsManager) -> None:
await forms.show('test-form') # Start form processing
async def main():
dp = Dispatcher()
dp.include_router(router)
dispatcher.attach(dp) # Attach aiogram to forms dispatcher
bot = Bot(...)
await dp.start_polling(bot)
All notable changes to this project will be documented in CHANGELOG file.
FAQs
Forms for aiogram
We found that aiogram-forms demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
/Research
A phishing attack targeted developers using a typosquatted npm domain (npnjs.com) to steal credentials via fake login pages - watch out for similar scams.
Security News
Knip hits 500 releases with v5.62.0, refining TypeScript config detection and updating plugins as monthly npm downloads approach 12M.
Security News
The EU Cyber Resilience Act is prompting compliance requests that open source maintainers may not be obligated or equipped to handle.