René's URL Explorer Experiment


Title: Make filters and/or-able using bitwise operators. by jsmnbom · Pull Request #411 · python-telegram-bot/python-telegram-bot · GitHub

Open Graph Title: Make filters and/or-able using bitwise operators. by jsmnbom · Pull Request #411 · python-telegram-bot/python-telegram-bot

X Title: Make filters and/or-able using bitwise operators. by jsmnbom · Pull Request #411 · python-telegram-bot/python-telegram-bot

Description: Would allow filters to be and'ed/or'ed. Using syntax like this: handler = MessageHandler((Filters.text | Filters.venue) & Filters.forwarded, callback) Currently this isn't too useful since the only filter that can be and'ed to any other is forwarded, but that should all change with #409. The code currently requires all filters to be created as a class and then initiated before they can be used, which could be an inconvenience to the user if they want to create their own filters. To remedy this we could add a decorator like this: def Filter(f): def wrapper(self, message): return f(message) return type(f.__name__, (BaseFilter,), {'__call__': wrapper})() That would allow users (and us) to make filters like this: @Filter def Text(self, message): return bool(message.text and not message.text.startswith('/')) The reason I didn't immediately go with this, is that it might be confusing if someone (especially someone new to python) reading the code stumbles upon a dynamic class creator. Thoughts? Figure out implementation Write the code Write the docs Add snippet to wiki Wait for #409 to get merged? Edit: After talking in dev group, the decorator has been declared too gross to look at :P

Open Graph Description: Would allow filters to be and'ed/or'ed. Using syntax like this: handler = MessageHandler((Filters.text | Filters.venue) & Filters.forwarded, callback) Currently this isn't too usefu...

X Description: Would allow filters to be and'ed/or'ed. Using syntax like this: handler = MessageHandler((Filters.text | Filters.venue) & Filters.forwarded, callback) Currently this isn&...

Opengraph URL: https://github.com/python-telegram-bot/python-telegram-bot/pull/411

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:829300f9-a80c-b50f-c2aa-5de7b63a1052
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idC104:A4600:A8EEB9:E3235F:6A5CE8D1
html-safe-nonce87a2d4f4dbdb830ca0fac782064cfb1fd590fa8f4feea007f859be4fdeeb9cc8
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMTA0OkE0NjAwOkE4RUVCOTpFMzIzNUY6NkE1Q0U4RDEiLCJ2aXNpdG9yX2lkIjoiMTYzMzc3MzkwMjk3ODkzNDk5MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmace2fbb796a8a1b18b4402fbecc8993d8a324b1245b7a78485cfe08d930b53f8e4
hovercard-subject-tagpull_request:85272372
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/python-telegram-bot/python-telegram-bot/pull/411/files
twitter:imagehttps://avatars.githubusercontent.com/u/3002987?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/3002987?s=400&v=4
og:image:altWould allow filters to be and'ed/or'ed. Using syntax like this: handler = MessageHandler((Filters.text | Filters.venue) & Filters.forwarded, callback) Currently this isn't too usefu...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None5290d7e14309ad1e76106a9c4237bd1041517e83ea182c8ab756752cb0c6940b
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/python-telegram-bot/python-telegram-bot git https://github.com/python-telegram-bot/python-telegram-bot.git
octolytics-dimension-user_id16178365
octolytics-dimension-user_loginpython-telegram-bot
octolytics-dimension-repository_id38696925
octolytics-dimension-repository_nwopython-telegram-bot/python-telegram-bot
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id38696925
octolytics-dimension-repository_network_root_nwopython-telegram-bot/python-telegram-bot
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release9c975978430e9ad293956f2bbdaf153b1bd84a99
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python-telegram-bot/python-telegram-bot/pull/411/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython-telegram-bot%2Fpython-telegram-bot%2Fpull%2F411%2Ffiles
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython-telegram-bot%2Fpython-telegram-bot%2Fpull%2F411%2Ffiles
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=python-telegram-bot%2Fpython-telegram-bot
Reloadhttps://github.com/python-telegram-bot/python-telegram-bot/pull/411/files
Reloadhttps://github.com/python-telegram-bot/python-telegram-bot/pull/411/files
Reloadhttps://github.com/python-telegram-bot/python-telegram-bot/pull/411/files
Please reload this pagehttps://github.com/python-telegram-bot/python-telegram-bot/pull/411/files
python-telegram-bot https://github.com/python-telegram-bot
python-telegram-bothttps://github.com/python-telegram-bot/python-telegram-bot
Notifications https://github.com/login?return_to=%2Fpython-telegram-bot%2Fpython-telegram-bot
Fork 6.1k https://github.com/login?return_to=%2Fpython-telegram-bot%2Fpython-telegram-bot
Star 29.3k https://github.com/login?return_to=%2Fpython-telegram-bot%2Fpython-telegram-bot
Code https://github.com/python-telegram-bot/python-telegram-bot
Issues 24 https://github.com/python-telegram-bot/python-telegram-bot/issues
Pull requests 9 https://github.com/python-telegram-bot/python-telegram-bot/pulls
Discussions https://github.com/python-telegram-bot/python-telegram-bot/discussions
Actions https://github.com/python-telegram-bot/python-telegram-bot/actions
Projects https://github.com/python-telegram-bot/python-telegram-bot/projects
Wiki https://github.com/python-telegram-bot/python-telegram-bot/wiki
Security and quality 0 https://github.com/python-telegram-bot/python-telegram-bot/security
Insights https://github.com/python-telegram-bot/python-telegram-bot/pulse
Code https://github.com/python-telegram-bot/python-telegram-bot
Issues https://github.com/python-telegram-bot/python-telegram-bot/issues
Pull requests https://github.com/python-telegram-bot/python-telegram-bot/pulls
Discussions https://github.com/python-telegram-bot/python-telegram-bot/discussions
Actions https://github.com/python-telegram-bot/python-telegram-bot/actions
Projects https://github.com/python-telegram-bot/python-telegram-bot/projects
Wiki https://github.com/python-telegram-bot/python-telegram-bot/wiki
Security and quality https://github.com/python-telegram-bot/python-telegram-bot/security
Insights https://github.com/python-telegram-bot/python-telegram-bot/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fpython-telegram-bot%2Fpython-telegram-bot%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fpython-telegram-bot%2Fpython-telegram-bot%2Fissues%2Fnew%2Fchoose
jsmnbomhttps://github.com/jsmnbom
masterhttps://github.com/python-telegram-bot/python-telegram-bot/tree/master
bitwise-filtershttps://github.com/python-telegram-bot/python-telegram-bot/tree/bitwise-filters
Conversation 4 https://github.com/python-telegram-bot/python-telegram-bot/pull/411
Commits 14 https://github.com/python-telegram-bot/python-telegram-bot/pull/411/commits
Checks 0 https://github.com/python-telegram-bot/python-telegram-bot/pull/411/checks
Files changed https://github.com/python-telegram-bot/python-telegram-bot/pull/411/files
Please reload this pagehttps://github.com/python-telegram-bot/python-telegram-bot/pull/411/files
Make filters and/or-able using bitwise operators. https://github.com/python-telegram-bot/python-telegram-bot/pull/411/files#top
Show all changes 14 commits https://github.com/python-telegram-bot/python-telegram-bot/pull/411/files
71e74da Make filters and/or-able using bitwise operators. jsmnbom Sep 14, 2016 https://github.com/python-telegram-bot/python-telegram-bot/pull/411/commits/71e74da0a2b2e70f91e9aad6d73066249fdfc084
2161681 Use filter method instead of __call__ jsmnbom Sep 24, 2016 https://github.com/python-telegram-bot/python-telegram-bot/pull/411/commits/2161681131aa9d3fcee1a49953fff61c62ecb5dd
921fbae Merge branch 'master' into bitwise-filters jsmnbom Sep 24, 2016 https://github.com/python-telegram-bot/python-telegram-bot/pull/411/commits/921fbae2f3f9b3430f7131718404709b75a7fbf7
be0f5bc Merge branch 'master' into bitwise-filters jsmnbom Sep 24, 2016 https://github.com/python-telegram-bot/python-telegram-bot/pull/411/commits/be0f5bc519853601a8f298c967be8128596de9d9
6159640 __call__ should return the result jsmnbom Sep 24, 2016 https://github.com/python-telegram-bot/python-telegram-bot/pull/411/commits/61596400e18de8d3ecf37ecc2f443329e49e0e4f
3244417 Add docs for filters. jsmnbom Sep 24, 2016 https://github.com/python-telegram-bot/python-telegram-bot/pull/411/commits/3244417f6178c21d9ce9814dd3a0ad019967e1de
79e065a Add __str__ and __repr__ to MergedFilter. jsmnbom Sep 25, 2016 https://github.com/python-telegram-bot/python-telegram-bot/pull/411/commits/79e065a730dc8b1df93b99a200229813b892be46
79bdfe4 Allow filters to be passed without list. jsmnbom Sep 29, 2016 https://github.com/python-telegram-bot/python-telegram-bot/pull/411/commits/79bdfe4c5d4a5659c3ff2dc7e725ab95e7029e7b
ca5e314 Fix docstring according to Jannes' commentns. jsmnbom Oct 14, 2016 https://github.com/python-telegram-bot/python-telegram-bot/pull/411/commits/ca5e3146c6578d9e2bc482ee090a863eafbfa573
c626044 Add "all" filter jsmnbom Oct 15, 2016 https://github.com/python-telegram-bot/python-telegram-bot/pull/411/commits/c626044a3033432c778984d879467c3acc461c39
f99b2f8 Inprove coverage jsmnbom Oct 15, 2016 https://github.com/python-telegram-bot/python-telegram-bot/pull/411/commits/f99b2f8f3b7215c95ff10921a23e7a0bb704421d
29e0cc6 Fix py2 compat jsmnbom Oct 15, 2016 https://github.com/python-telegram-bot/python-telegram-bot/pull/411/commits/29e0cc64e99c94ed00266e1a71189d8a6aaa5d9c
5408c23 assertRegexMatches still exists for now. Use it. jsmnbom Oct 16, 2016 https://github.com/python-telegram-bot/python-telegram-bot/pull/411/commits/5408c23e3306bb253428d6de644b6247359d753b
39832d2 __str__ behaves differntly on py2 apparently. jsmnbom Oct 16, 2016 https://github.com/python-telegram-bot/python-telegram-bot/pull/411/commits/39832d2f6b848c3a9fc9ea3c85615e11e7c89808
Clear filters https://github.com/python-telegram-bot/python-telegram-bot/pull/411/files
Please reload this pagehttps://github.com/python-telegram-bot/python-telegram-bot/pull/411/files
Please reload this pagehttps://github.com/python-telegram-bot/python-telegram-bot/pull/411/files
telegram.ext.filters.rst https://github.com/python-telegram-bot/python-telegram-bot/pull/411/files#diff-e313f0b078472b2ce324dc15823bfc8ca84d10239fdb59b3ecee8891503b9a4f
telegram.ext.rst https://github.com/python-telegram-bot/python-telegram-bot/pull/411/files#diff-ff001bb81d18e38762a8c6c6815249230e877a992e016474a7a9b974cf343f55
__init__.py https://github.com/python-telegram-bot/python-telegram-bot/pull/411/files#diff-a2540ae3258b51edd104b57321ec5cf175d07674b907609900ba296eec12c600
filters.py https://github.com/python-telegram-bot/python-telegram-bot/pull/411/files#diff-6260592e9e0d28a464b383edf7c50a882910ff6d502f609313dc44e3cbfdae6c
messagehandler.py https://github.com/python-telegram-bot/python-telegram-bot/pull/411/files#diff-779dd6103ae2b10c4dc6140cbf1f55334998699e8b2c00113a5ffdf71255680b
test_filters.py https://github.com/python-telegram-bot/python-telegram-bot/pull/411/files#diff-c42c96171310ba36a50fc20ad759507f08aa8212df793d97e33579522ffb39c4
test_updater.py https://github.com/python-telegram-bot/python-telegram-bot/pull/411/files#diff-906c8650352f360773f89fb317f460569c63aacf8ad9234a567b6b977ebe0bfe
docs/source/telegram.ext.filters.rsthttps://github.com/python-telegram-bot/python-telegram-bot/pull/411/files#diff-e313f0b078472b2ce324dc15823bfc8ca84d10239fdb59b3ecee8891503b9a4f
View file https://github.com/python-telegram-bot/python-telegram-bot/blob/39832d2f6b848c3a9fc9ea3c85615e11e7c89808/docs/source/telegram.ext.filters.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python-telegram-bot/python-telegram-bot/pull/411/{{ revealButtonHref }}
docs/source/telegram.ext.rsthttps://github.com/python-telegram-bot/python-telegram-bot/pull/411/files#diff-ff001bb81d18e38762a8c6c6815249230e877a992e016474a7a9b974cf343f55
View file https://github.com/python-telegram-bot/python-telegram-bot/blob/39832d2f6b848c3a9fc9ea3c85615e11e7c89808/docs/source/telegram.ext.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python-telegram-bot/python-telegram-bot/pull/411/{{ revealButtonHref }}
https://github.com/python-telegram-bot/python-telegram-bot/pull/411/files#diff-ff001bb81d18e38762a8c6c6815249230e877a992e016474a7a9b974cf343f55
https://github.com/python-telegram-bot/python-telegram-bot/pull/411/files#diff-ff001bb81d18e38762a8c6c6815249230e877a992e016474a7a9b974cf343f55
telegram/ext/__init__.pyhttps://github.com/python-telegram-bot/python-telegram-bot/pull/411/files#diff-a2540ae3258b51edd104b57321ec5cf175d07674b907609900ba296eec12c600
View file https://github.com/python-telegram-bot/python-telegram-bot/blob/39832d2f6b848c3a9fc9ea3c85615e11e7c89808/telegram/ext/__init__.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python-telegram-bot/python-telegram-bot/pull/411/{{ revealButtonHref }}
https://github.com/python-telegram-bot/python-telegram-bot/pull/411/files#diff-a2540ae3258b51edd104b57321ec5cf175d07674b907609900ba296eec12c600
https://github.com/python-telegram-bot/python-telegram-bot/pull/411/files#diff-a2540ae3258b51edd104b57321ec5cf175d07674b907609900ba296eec12c600
telegram/ext/filters.pyhttps://github.com/python-telegram-bot/python-telegram-bot/pull/411/files#diff-6260592e9e0d28a464b383edf7c50a882910ff6d502f609313dc44e3cbfdae6c
View file https://github.com/python-telegram-bot/python-telegram-bot/blob/39832d2f6b848c3a9fc9ea3c85615e11e7c89808/telegram/ext/filters.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python-telegram-bot/python-telegram-bot/pull/411/{{ revealButtonHref }}
jh0kerhttps://github.com/jh0ker
Oct 10, 2016https://github.com/python-telegram-bot/python-telegram-bot/pull/411/files#r82587083
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/python-telegram-bot/python-telegram-bot/pull/411/files
telegram/ext/messagehandler.pyhttps://github.com/python-telegram-bot/python-telegram-bot/pull/411/files#diff-779dd6103ae2b10c4dc6140cbf1f55334998699e8b2c00113a5ffdf71255680b
View file https://github.com/python-telegram-bot/python-telegram-bot/blob/39832d2f6b848c3a9fc9ea3c85615e11e7c89808/telegram/ext/messagehandler.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python-telegram-bot/python-telegram-bot/pull/411/{{ revealButtonHref }}
https://github.com/python-telegram-bot/python-telegram-bot/pull/411/files#diff-779dd6103ae2b10c4dc6140cbf1f55334998699e8b2c00113a5ffdf71255680b
https://github.com/python-telegram-bot/python-telegram-bot/pull/411/files#diff-779dd6103ae2b10c4dc6140cbf1f55334998699e8b2c00113a5ffdf71255680b
https://github.com/python-telegram-bot/python-telegram-bot/pull/411/files#diff-779dd6103ae2b10c4dc6140cbf1f55334998699e8b2c00113a5ffdf71255680b
https://github.com/python-telegram-bot/python-telegram-bot/pull/411/files#diff-779dd6103ae2b10c4dc6140cbf1f55334998699e8b2c00113a5ffdf71255680b
Please reload this pagehttps://github.com/python-telegram-bot/python-telegram-bot/pull/411/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.