Title: [BUG] Persistence of Bots · Issue #1992 · python-telegram-bot/python-telegram-bot · GitHub
Open Graph Title: [BUG] Persistence of Bots · Issue #1992 · python-telegram-bot/python-telegram-bot
X Title: [BUG] Persistence of Bots · Issue #1992 · python-telegram-bot/python-telegram-bot
Description: Steps to reproduce Add an object with a bot attribute to e.g. chat_data and persist it Change the bots token and restart the updater Expected behaviour The reloaded bot should have the new token. Actual behaviour The bot in the loaded ch...
Open Graph Description: Steps to reproduce Add an object with a bot attribute to e.g. chat_data and persist it Change the bots token and restart the updater Expected behaviour The reloaded bot should have the new token. A...
X Description: Steps to reproduce Add an object with a bot attribute to e.g. chat_data and persist it Change the bots token and restart the updater Expected behaviour The reloaded bot should have the new token. A...
Opengraph URL: https://github.com/python-telegram-bot/python-telegram-bot/issues/1992
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[BUG] Persistence of Bots","articleBody":"\u003c!--\r\nThanks for reporting issues of python-telegram-bot!\r\n\r\nUse this template to notify us if you found a bug.\r\n\r\nTo make it easier for us to help you please enter detailed information below.\r\n\r\nPlease note, we only support the latest version of python-telegram-bot and\r\nmaster branch. Please make sure to upgrade & recreate the issue on the latest\r\nversion prior to opening an issue.\r\n-->\r\n### Steps to reproduce\r\n1. Add an object with a bot attribute to e.g. `chat_data` and persist it\r\n\r\n2. Change the bots token and restart the updater\r\n\r\n### Expected behaviour\r\nThe reloaded bot should have the new token.\r\n\r\n### Actual behaviour\r\nThe bot in the loaded `chat_data` still has the old token. Similar for the other bot attributes\r\n\r\n### Proposed solution\r\n1. Remove `__reduce__` from `Bot` , as we don't want to encourage pickling bots\r\n2. Add static methods `replace_bots(object)` and `set_bots(objects, bot)` (or other naming) to `BasePersistence`, where `replace_bots` implements the logic to replace every `Bot` instance in an object, be it a dict, a list, a custom object … with some special placeholder `BOT_INSTANCE` or whatever and `set_bots` in turn replaces `BOT_INSTANCE` with the given bot. To make `get_*_data` and `update_*_data` use those, we have several options:\r\n 1. Just call them in `get/update_`. Custom subclasses of `BasePersistence` will have to adjust.\r\n 2. Add a `__new__` method to make the `get/update_` methods call the methods under the hood. that way custom subclasses don't need to change anything\r\n 3. Add methods `get/update_*_replace_bot`, which call `set/replace_bots` and before/after `get/update_*`. Use those in `Updater`. This way, custom classes also don't need to be changed.\r\n\r\n don't know, whats better …\r\n3. Alternatively to passing the bot to `set_bots`, we could add `set_bot` to `BasePersistence` so that we can use `self.bot` in `set_bot`. That would save us from having to pass `bot` to `get_*` as well ","author":{"url":"https://github.com/Bibo-Joshi","@type":"Person","name":"Bibo-Joshi"},"datePublished":"2020-06-10T19:01:15Z","url":"https://github.com/python-telegram-bot/python-telegram-bot/issues/1992"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| 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:d695d3db-85e1-9919-2029-5beb223a5cde |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9FD0:14EB6E:25C433E:316722E:6B0253EF |
| html-safe-nonce | a029544eb3c4910c06d0c626abe2a36157c218327e1bd19ff99beab4f2955147 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RkQwOjE0RUI2RToyNUM0MzNFOjMxNjcyMkU6NkIwMjUzRUYiLCJ2aXNpdG9yX2lkIjoiODQ1NzI0NzcyNTI4MzU5NTI0NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 3964574500010dbe782ab59aa00f1f4d836e61743a4520cbef372d207126a020 |
| hovercard-subject-tag | issue:636477310 |
| 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/1992/issue_layout |
| twitter:image | https://opengraph.githubassets.com/54b1094b3d8b2c46cf0d1eedd3b1981295c504b99306f7ce91104d5902a2362b/python-telegram-bot/python-telegram-bot/issues/1992 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/54b1094b3d8b2c46cf0d1eedd3b1981295c504b99306f7ce91104d5902a2362b/python-telegram-bot/python-telegram-bot/issues/1992 |
| og:image:alt | Steps to reproduce Add an object with a bot attribute to e.g. chat_data and persist it Change the bots token and restart the updater Expected behaviour The reloaded bot should have the new token. A... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Bibo-Joshi |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| 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 | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width