bot_data as global memory#1322
Closed
Bibo-Joshi wants to merge 3 commits intopython-telegram-bot:masterfrom
Bibo-Joshi:bot-data
Closed
bot_data as global memory#1322Bibo-Joshi wants to merge 3 commits intopython-telegram-bot:masterfrom Bibo-Joshi:bot-data
Bibo-Joshi wants to merge 3 commits intopython-telegram-bot:masterfrom
Bibo-Joshi:bot-data
Conversation
This was referenced Jan 7, 2019
Member
|
I really like what you've done here, but I'm sorry to report that you'll probably have to make a couple of changes. I haven't looked very much into it, but since you've based it on master instead of the V12 development branch, you don't use the new Context object which this feature definitely should. |
Member
Author
|
Replaced by #1325 |
Eldinnie
added a commit
that referenced
this pull request
Feb 2, 2020
* Update AUTHORS.rst * Update AUTHORS.rst * Add bot_data to CallbackContext as global memory * Minor fixes in docstrings * Incorp. req. changes, Flake8 Fixes * Persist before stop * Fix CI errors * Implement #1342 for bot_data * Add check pickle_persistence_only_bot similar to #1462 * Fix test_persistence * Try dispatching error before logging it * Fix test Co-authored-by: Eldinnie <Eldinnie@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR implements the global memory proposed in #1318 by providing a dictionary
bot_datain addition touser_dataandchat_data.I've integrated
bot_datain the dispatcher class and the handler classes. Since thebot_datais a global memory, I've also integrated it in those handlers, that are not meant for telegram.Updates (e.g. StringCommandHandler).Integration in persistence is also provided. Note, that in
update_bot_data, the data is updated byin contrast to the current implentation for
user/chat_dataThis is to avoid problems as described in #1297. However, to leave this PR self-contained, I didn't change it for
user_dataandchat_data.In
DictPersistence, I just usedjson.loads()to decode serialized data. Foruser_dataandchat_data, a function from the helpers module is used to allow integer keys. imo, this is not really necessary and may lead to problems (e.g. when using'3'as a key, that will be decoded as3), so I left it out. If I just didn't get the point of it, I will gladly add this.Also, I've started to adjust the test routines. I will add them, once I get
make testto work again (see #1321 )