Repository: python-telegram-bot/python-telegram-bot

Issue:
Pickle Persistence Not Saving Bot_data[BUG]
<!--
Thanks for reporting issues of python-telegram-bot!

Use this template to notify us if you found a bug.

To make it easier for us to help you please enter detailed information below.

Please note, we only support the latest version of python-telegram-bot and
master branch. Please make sure to upgrade & recreate the issue on the latest
version prior to opening an issue.
-->
### Steps to reproduce
1.
In line 282 of picklepersistence.py:
[BUG]   if self.user_data or self.chat_data or self.conversations:
[FIX]  if self.user_data or self.chat_data or self.conversations or self.bot_data:

2.
Add self.bot_data in the if-check
3.

### Expected behaviour
When you register the pickle persistence with (store_user_data=False, store_chat_data=False), the bot should save bot_data to pickle file every time it calls flush().


### Actual behaviour
In the current version, the bot only checks user_data/chat_data/conversation to be non-empty to save the pickle file, which when the case (store_user_data=False, store_chat_data=False), the bot never checks bot_data in order to save the pickle file. In my case, user_data/chat_data are always empty, so bot doesn't save to pickle file

### Configuration
**Operating System:**


**Version of Python, python-telegram-bot & dependencies:**

``$ python -m telegram``

### Logs
Insert logs here (if necessary)

Pickle Persistence Not Saving Bot_data[BUG]
<!--
Thanks for reporting issues of python-telegram-bot!

Use this template to notify us if you found a bug.

To make it easier for us to help you please enter detailed information below.

Please note, we only support the latest version of python-telegram-bot and
master branch. Please make sure to upgrade & recreate the issue on the latest
version prior to opening an issue.
-->
### Steps to reproduce
1.
In line 282 of picklepersistence.py:
[BUG]   if self.user_data or self.chat_data or self.conversations:
[FIX]  if self.user_data or self.chat_data or self.conversations or self.bot_data:

2.
Add self.bot_data in the if-check
3.

### Expected behaviour
When you register the pickle persistence with (store_user_data=False, store_chat_data=False), the bot should save bot_data to pickle file every time it calls flush().


### Actual behaviour
In the current version, the bot only checks user_data/chat_data/conversation to be non-empty to save the pickle file, which when the case (store_user_data=False, store_chat_data=False), the bot never checks bot_data in order to save the pickle file. In my case, user_data/chat_data are always empty, so bot doesn't save to pickle file

### Configuration
**Operating System:**


**Version of Python, python-telegram-bot & dependencies:**

``$ python -m telegram``

### Logs
Insert logs here (if necessary)



Discussion:

Resolving patch:
diff --git a/telegram/ext/picklepersistence.py b/telegram/ext/picklepersistence.py
--- a/telegram/ext/picklepersistence.py
+++ b/telegram/ext/picklepersistence.py
@@ -277,7 +277,7 @@ def flush(self):
         """ Will save all data in memory to pickle file(s).
         """
         if self.single_file:
-            if self.user_data or self.chat_data or self.conversations:
+            if self.user_data or self.chat_data or self.bot_data or self.conversations:
                 self.dump_singlefile()
         else:
             if self.user_data:


Test patch: