René's URL Explorer Experiment


Title: EasyConversationHandler by 123yagel · Pull Request #3042 · python-telegram-bot/python-telegram-bot · GitHub

Open Graph Title: EasyConversationHandler by 123yagel · Pull Request #3042 · python-telegram-bot/python-telegram-bot

X Title: EasyConversationHandler by 123yagel · Pull Request #3042 · python-telegram-bot/python-telegram-bot

Description: Hey! I found myself struggling a lot with ConversationHandler state machine, so I came up with new idea that I didn't found out there: Programming bot logic with regular functions that waits for input from the user! I implemented POC (MVP actually) here, and want to open a discussion about it. What relevant, what less relevant, and improving implementation. Example async def collect_number(context): """ Collects an int from the user """ while True: update = await context.get_update() if update.message.text.isdigit(): return int(update.message.text) await update.message.reply_text('This is not a number. Enter a number:') And we can use this function in other funtions: await context.last_update.message.reply_text(f'How many apples?') how_many = await collect_number(context) Adding handler: application.add_handler(EasyConversationHandler(siblings_callback, first_message_filter=Regex('/siblings'))) See the full example in examples/easyconversationbot.py Checklist for PRs I didn't checked all of this yet, but will do after some discussion and CR Added .. versionadded:: version, .. versionchanged:: version or .. deprecated:: version to the docstrings for user facing changes (for methods/class descriptions, arguments and attributes) Created new or adapted existing unit tests Documented code changes according to the CSI standard Added myself alphabetically to AUTHORS.rst (optional) Added new classes & modules to the docs and all suitable __all__ s Added new shortcuts: In Chat & User for all methods that accept chat/user_id In Message for all methods that accept chat_id and message_id For new Message shortcuts: Added quote argument if methods accepts reply_to_message_id In CallbackQuery for all methods that accept either chat_id and message_id or inline_message_id If relevant: Added new constants at telegram.constants and shortcuts to them as class variables Link new and existing constants in docstrings instead of hard coded number and strings Add new message types to Message.effective_attachment Added new handlers for new update types Add the handlers to the warning loop in the ConversationHandler Added new filters for new message (sub)types Added or updated documentation for the changed class(es) and/or method(s) Added or updated bot_methods.rst Updated the Bot API version number in all places: README.rst and README_RAW.rst (including the badge), as well as telegram.constants.BOT_API_VERSION Added logic for arbitrary callback data in tg.ext.Bot for new methods that either accept a reply_markup in some form or have a return type that is/contains telegram.Message

Open Graph Description: Hey! I found myself struggling a lot with ConversationHandler state machine, so I came up with new idea that I didn't found out there: Programming bot logic with regular functions that waits fo...

X Description: Hey! I found myself struggling a lot with ConversationHandler state machine, so I came up with new idea that I didn't found out there: Programming bot logic with regular functions that wait...

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

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:42f6ee81-0eca-55eb-61ee-7bb96d1dd300
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idAD34:36CA7B:D5499:10C25F:6B028223
html-safe-nonce2d8dcdda559febbe9d5ad2422041ba5745ee1c89b68fc77337a4704f666fc233
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRDM0OjM2Q0E3QjpENTQ5OToxMEMyNUY6NkIwMjgyMjMiLCJ2aXNpdG9yX2lkIjoiNDc2NTI5MzgyOTA1MjA3MjQ4MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmaca626bad0b89768eb3e6779e99463504b0c5c591ce40ed919fb38eb73aca49d2f
hovercard-subject-tagpull_request:939083352
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/3042/files
twitter:imagehttps://avatars.githubusercontent.com/u/20226707?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/20226707?s=400&v=4
og:image:altHey! I found myself struggling a lot with ConversationHandler state machine, so I came up with new idea that I didn't found out there: Programming bot logic with regular functions that waits fo...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456
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
release423dbb54c5e7bfecc838eb387c1435eb3d0e760d
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python-telegram-bot/python-telegram-bot/pull/3042/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython-telegram-bot%2Fpython-telegram-bot%2Fpull%2F3042%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
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
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://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
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython-telegram-bot%2Fpython-telegram-bot%2Fpull%2F3042%2Ffiles
Sign uphttps://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/3042/files
Reloadhttps://github.com/python-telegram-bot/python-telegram-bot/pull/3042/files
Reloadhttps://github.com/python-telegram-bot/python-telegram-bot/pull/3042/files
python-telegram-bothttps://github.com/python-telegram-bot
python-telegram-bothttps://github.com/python-telegram-bot/python-telegram-bot
Codehttps://github.com/python-telegram-bot/python-telegram-bot
Issues23 (23)https://github.com/python-telegram-bot/python-telegram-bot/issues
Pull requests19 (19)https://github.com/python-telegram-bot/python-telegram-bot/pulls
Discussionshttps://github.com/python-telegram-bot/python-telegram-bot/discussions
Actionshttps://github.com/python-telegram-bot/python-telegram-bot/actions
Projectshttps://github.com/python-telegram-bot/python-telegram-bot/projects
Wikihttps://github.com/python-telegram-bot/python-telegram-bot/wiki
Security and qualityhttps://github.com/python-telegram-bot/python-telegram-bot/security
Insightshttps://github.com/python-telegram-bot/python-telegram-bot/insights
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
123yagelhttps://github.com/123yagel
python-telegram-bot:masterhttps://github.com/python-telegram-bot/python-telegram-bot/tree/master
123yagel:feature/easy-conversation-handlerhttps://github.com/123yagel/python-telegram-bot/tree/feature/easy-conversation-handler
Conversation 4 https://github.com/python-telegram-bot/python-telegram-bot/pull/3042
Commits 13 https://github.com/python-telegram-bot/python-telegram-bot/pull/3042/commits
Checks 0 https://github.com/python-telegram-bot/python-telegram-bot/pull/3042/checks
Files changed https://github.com/python-telegram-bot/python-telegram-bot/pull/3042/files
Please reload this pagehttps://github.com/python-telegram-bot/python-telegram-bot/pull/3042/files
EasyConversationHandler https://github.com/python-telegram-bot/python-telegram-bot/pull/3042/files#top
Show all changes 13 commits https://github.com/python-telegram-bot/python-telegram-bot/pull/3042/files
6048366 EasyConversationHandler added 123yagel May 17, 2022 https://github.com/python-telegram-bot/python-telegram-bot/pull/3042/commits/604836654328479e7fce033d88c781a8d905171c
27be25b Token in example 123yagel May 17, 2022 https://github.com/python-telegram-bot/python-telegram-bot/pull/3042/commits/27be25becc6eccd16e83ea6908db6f5359d38fb1
a394767 Fix example 123yagel May 17, 2022 https://github.com/python-telegram-bot/python-telegram-bot/pull/3042/commits/a39476729f3af537bf8e381abba86e5934f0a646
e19fa9e Add docstrings and slots 123yagel May 17, 2022 https://github.com/python-telegram-bot/python-telegram-bot/pull/3042/commits/e19fa9ed8ce0925d6ef25d2612890347eace88f7
ae5ed5d [pre-commit.ci] auto fixes from pre-commit.com hooks pre-commit-ci[bot] May 17, 2022 https://github.com/python-telegram-bot/python-telegram-bot/pull/3042/commits/ae5ed5d7879084774589ca8f1866b7e07217b424
67fdd9b Add docstrings, fix 123yagel May 17, 2022 https://github.com/python-telegram-bot/python-telegram-bot/pull/3042/commits/67fdd9b643f7476d0cc076786c2149e6e0da3a1e
8ab3c0d Merge remote-tracking branch 'origin/feature/easy-conversation-handle… 123yagel May 17, 2022 https://github.com/python-telegram-bot/python-telegram-bot/pull/3042/commits/8ab3c0d50436f14a476ce6590ee81f6704acc3a1
752d25d Fix pylints 123yagel May 17, 2022 https://github.com/python-telegram-bot/python-telegram-bot/pull/3042/commits/752d25db02cb3df7978dd19ac59cf005a0c12ee1
72270d0 Fix more pylints 123yagel May 17, 2022 https://github.com/python-telegram-bot/python-telegram-bot/pull/3042/commits/72270d0557eb700f333d9b5ac2b9a6aa4d96d4b0
de42626 Change all ' to " 123yagel May 17, 2022 https://github.com/python-telegram-bot/python-telegram-bot/pull/3042/commits/de4262655cfeb5dda0f0bbdabf256ef9d48d85de
38087c2 fix formatting 123yagel May 17, 2022 https://github.com/python-telegram-bot/python-telegram-bot/pull/3042/commits/38087c2936627f07e2b5940f749b3f005937bd69
e1af424 Add type hints 123yagel May 17, 2022 https://github.com/python-telegram-bot/python-telegram-bot/pull/3042/commits/e1af4242e4ba9d369b01f241824b8d94e335dd93
df4cbc5 more formatting 123yagel May 17, 2022 https://github.com/python-telegram-bot/python-telegram-bot/pull/3042/commits/df4cbc5b675cfaacc688f123dd321ad782c0deb1
Clear filters https://github.com/python-telegram-bot/python-telegram-bot/pull/3042/files
Please reload this pagehttps://github.com/python-telegram-bot/python-telegram-bot/pull/3042/files
Please reload this pagehttps://github.com/python-telegram-bot/python-telegram-bot/pull/3042/files
easyconversationbot.py https://github.com/python-telegram-bot/python-telegram-bot/pull/3042/files#diff-2b454b4716826ed28fcee6093ac2c79f85eed67ab581db0822c685c108c146b7
_easyconversationhandler.py https://github.com/python-telegram-bot/python-telegram-bot/pull/3042/files#diff-167178484a8892d2cde6f554b0011ee47ec20a9bdc916bb8e2832a1da6d2629b
examples/easyconversationbot.pyhttps://github.com/python-telegram-bot/python-telegram-bot/pull/3042/files#diff-2b454b4716826ed28fcee6093ac2c79f85eed67ab581db0822c685c108c146b7
View file https://github.com/123yagel/python-telegram-bot/blob/df4cbc5b675cfaacc688f123dd321ad782c0deb1/examples/easyconversationbot.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python-telegram-bot/python-telegram-bot/pull/3042/{{ revealButtonHref }}
telegram/ext/_easyconversationhandler.pyhttps://github.com/python-telegram-bot/python-telegram-bot/pull/3042/files#diff-167178484a8892d2cde6f554b0011ee47ec20a9bdc916bb8e2832a1da6d2629b
View file https://github.com/123yagel/python-telegram-bot/blob/df4cbc5b675cfaacc688f123dd321ad782c0deb1/telegram/ext/_easyconversationhandler.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python-telegram-bot/python-telegram-bot/pull/3042/{{ revealButtonHref }}
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.