Skip to main content

Custom version of Command filter for aiogram 3

Project description

Filter CommandMk2 Aiogram 3

Python


Improved command filter

class RestrictModel(BaseModel):
    period: date
    reason: Optional[str]


@router.message(CommandMk2('ban {period} {reason}', response_model=RestrictModel, response_model_name='vars'))
async def ban_user(message: Message, period: date, reason: Optional[str]):
    ...

Diff:

  • Command arguments parsing, not just leaving single string like built-in aiogram filter
  • Command arguments separation and validation using Pydantic model.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

command_mk2-0.1.1.tar.gz (3.0 kB view hashes)

Uploaded source

Built Distribution

command_mk2-0.1.1-py3-none-any.whl (3.1 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page