Skip to content

Extended MagicFilter to get filter result as handler argument #759

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 24, 2021

Conversation

JrooTJunior
Copy link
Member

@JrooTJunior JrooTJunior commented Nov 24, 2021

Description

Added possibility to get MagicFilter result as handler argument

Example

from aiogram import F

...

@router.message(F.text.regexp(r"^(\d+)$").as_("digits"))
async def any_digits_handler(message: Message, digits: Match[str]):
    await message.answer(html.quote(str(digits)))

Type of change

Please delete options that are not relevant.

  • Documentation (typos, code examples or any documentation update)
  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@JrooTJunior JrooTJunior added enhancement Make it better! 3.x Issue or PR for stable 3.x version labels Nov 24, 2021
@JrooTJunior JrooTJunior added this to the 3.0 milestone Nov 24, 2021
@codecov
Copy link

codecov bot commented Nov 24, 2021

Codecov Report

Merging #759 (8529f46) into dev-3.x (092b3f0) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##           dev-3.x      #759   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          277       278    +1     
  Lines         7302      7316   +14     
=========================================
+ Hits          7302      7316   +14     
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
aiogram/__init__.py 100.00% <100.00%> (ø)
aiogram/utils/magic_filter.py 100.00% <100.00%> (ø)

@JrooTJunior JrooTJunior merged commit d7be55b into dev-3.x Nov 24, 2021
@JrooTJunior JrooTJunior deleted the magic-filter-extension branch November 24, 2021 09:31
@evgfilim1 evgfilim1 changed the title Extended MagicFilter with aiogram-specific operation Extended MagicFilter to get filter result as handler argument Nov 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.x Issue or PR for stable 3.x version enhancement Make it better!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant