Title: Handler callback revamp · Issue #1026 · python-telegram-bot/python-telegram-bot · GitHub
Open Graph Title: Handler callback revamp · Issue #1026 · python-telegram-bot/python-telegram-bot
X Title: Handler callback revamp · Issue #1026 · python-telegram-bot/python-telegram-bot
Description: This issue is here to expose to the community a proposed design for the Handlers callback prototype. We have recently closed/rejected PR #859 in this subject as we preferred to go in a different direction. Here we intend to discuss with ...
Open Graph Description: This issue is here to expose to the community a proposed design for the Handlers callback prototype. We have recently closed/rejected PR #859 in this subject as we preferred to go in a different di...
X Description: This issue is here to expose to the community a proposed design for the Handlers callback prototype. We have recently closed/rejected PR #859 in this subject as we preferred to go in a different di...
Opengraph URL: https://github.com/python-telegram-bot/python-telegram-bot/issues/1026
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Handler callback revamp","articleBody":"This issue is here to expose to the community a proposed design for the Handlers callback prototype.\r\nWe have recently closed/rejected PR #859 in this subject as we preferred to go in a different direction. Here we intend to discuss with the community what will be the chosen design.\r\n\r\n**Current situation:**\r\nMinimal callback prototype is `def callback(bot, update)`.\r\nIf users require more data/facilities they can initialize the Handler with extra `pass_` (bool) arguments which mandates the callback to accept more arguments (like `groups`, `args` and others).\r\n\r\nProblems:\r\n * The API is very cumbersome and confusing for new users.\r\n * Adding/pushing new context data into the callbacks requires code changes from the users.\r\nLets say that we want the RegexHandler to provide the match object to the callback. With the current design it will be impossible to add that information without changing the callback prototype and (most likely) impose a new `pass_` parameter during Handler initialization.\r\n\r\n**Proposed API**\r\nIMPORTANT: This change is non backward compatible. We might implement a backward compatibility layer for a certain period like we have done with other deprecated mechanisms in the past.\r\n * Deprecate `pass_` arguments when initializing Handlers.\r\n * Handler callbacks prototype will change to: `def callback(update, ctx)`.\r\n * The above `ctx` will be a context of all information/facilities that users may need. The context will be a Mixin of various context objects, depending on the Handler.\r\nExamples of such information/facilities:\r\n * `bot`\r\n * `update_queue`\r\n * `job_queue` (something to think about: instead of updater_queue \u0026 job_queue, pass the `updater`)\r\n * `user_data`\r\n * `chat_data`\r\n * `match` (instead of `groups`, `groups_dict` and similar for).","author":{"url":"https://github.com/tsnoam","@type":"Person","name":"tsnoam"},"datePublished":"2018-03-01T08:33:24.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":11},"url":"https://github.com/1026/python-telegram-bot/issues/1026"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:ec08b7b9-d836-e4f8-d7fb-cfd405fa39b2 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A350:7D6D8:7BE11:9EE3A:6A601503 |
| html-safe-nonce | 174c5355d55ed71a47dd1e0494c404f72b4cf719ab9fb53f8a2e01a54f2f353d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMzUwOjdENkQ4OjdCRTExOjlFRTNBOjZBNjAxNTAzIiwidmlzaXRvcl9pZCI6IjQyNzYzMjI5MTM0NzIyMjI0NjciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 380b0ea5ba18ba56b30c27bde436a7c3bb8d8bd4882d37c35d3f7d88b0995307 |
| hovercard-subject-tag | issue:301317725 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python-telegram-bot/python-telegram-bot/1026/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4b624ae013ddde4cead9f35bc2829531761b2f0ae317165940d8510187a93cfb/python-telegram-bot/python-telegram-bot/issues/1026 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4b624ae013ddde4cead9f35bc2829531761b2f0ae317165940d8510187a93cfb/python-telegram-bot/python-telegram-bot/issues/1026 |
| og:image:alt | This issue is here to expose to the community a proposed design for the Handlers callback prototype. We have recently closed/rejected PR #859 in this subject as we preferred to go in a different di... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | tsnoam |
| hostname | github.com |
| expected-hostname | github.com |
| None | 399e662401f6b9a532ecd80b305d17b9efadd864681448a290ab2901b98f288a |
| turbo-cache-control | no-preview |
| go-import | github.com/python-telegram-bot/python-telegram-bot git https://github.com/python-telegram-bot/python-telegram-bot.git |
| octolytics-dimension-user_id | 16178365 |
| octolytics-dimension-user_login | python-telegram-bot |
| octolytics-dimension-repository_id | 38696925 |
| octolytics-dimension-repository_nwo | python-telegram-bot/python-telegram-bot |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 38696925 |
| octolytics-dimension-repository_network_root_nwo | python-telegram-bot/python-telegram-bot |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 2f4d68ce236d24a2cd682f94ef8bd8537c09d73d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width