bot_data as global memory #1322
Closed
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 )