Skip to content

Conversation

@Bibo-Joshi
Copy link
Member

This PR implements the global memory proposed in #1318 by providing a dictionary bot_data in addition to user_data and chat_data.

I've integrated bot_data in the dispatcher class and the handler classes. Since the bot_data is 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 by

self.bot_data = data.copy()

in contrast to the current implentation for user/chat_data

self.user_data[chat_id] = data

This is to avoid problems as described in #1297. However, to leave this PR self-contained, I didn't change it for user_data and chat_data.

In DictPersistence, I just used json.loads() to decode serialized data. For user_data and chat_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 as 3), 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 test to work again (see #1321 )

@jsmnbom
Copy link
Member

jsmnbom commented Jan 9, 2019

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.
You're very welcome to base it on V12 branch and rewrite the stuff that needs rewriting and then we'll take a look. It should be fairly simple - mostly switching the pass_xxx over to the Context system.
Feel free to contact me on telegram under this username if you have questions :)

@Bibo-Joshi
Copy link
Member Author

Replaced by #1325

@Bibo-Joshi Bibo-Joshi closed this Jan 12, 2019
@Bibo-Joshi Bibo-Joshi deleted the bot-data branch January 12, 2019 17:35
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>
@github-actions github-actions bot locked and limited conversation to collaborators Aug 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants