2020import pickle
2121from collections import defaultdict
2222
23+ from telegram .ext import BasePersistence
2324
24- class PicklePersistence (object ):
25+
26+ class PicklePersistence (BasePersistence ):
2527 """Using python's builtin pickle for making you bot persistent.
2628
2729 Attributes:
@@ -34,8 +36,8 @@ class PicklePersistence(object):
3436 single_file (:obj:`bool`): Optional. When ``False`` will store 3 sperate files of
3537 `filename_user_data`, `filename_chat_data` and `filename_conversations`. Default is
3638 ``True``.
37- on_flush (:obj:`bool`): Optional. When ``True` will only save to file when :attr :`flush` is
38- called and keep data in memory until that happens. When False will store data on any
39+ on_flush (:obj:`bool`): Optional. When ``True`` will only save to file when :meth :`flush`
40+ is called and keep data in memory until that happens. When False will store data on any
3941 transaction. Default is ``False``.
4042
4143 Args:
@@ -48,8 +50,8 @@ class PicklePersistence(object):
4850 single_file (:obj:`bool`, optional): When ``False`` will store 3 sperate files of
4951 `filename_user_data`, `filename_chat_data` and `filename_conversations`. Default is
5052 ``True``.
51- on_flush (:obj:`bool`, optional): When ``True` will only save to file when :attr :`flush` is
52- called and keep data in memory until that happens. When False will store data on any
53+ on_flush (:obj:`bool`, optional): When ``True`` will only save to file when :meth :`flush`
54+ is called and keep data in memory until that happens. When False will store data on any
5355 transaction. Default is ``False``.
5456 """
5557
@@ -99,10 +101,10 @@ def dump_file(self, filename, data):
99101 pickle .dump (data , f )
100102
101103 def get_user_data (self ):
102- """" Returns the user_data from the pickle file if it exsists or an empty defaultdict.
104+ """Returns the user_data from the pickle file if it exsists or an empty defaultdict.
103105
104106 Returns:
105- :obj:' defaultdict`: The restored user data.
107+ :obj:` defaultdict`: The restored user data.
106108 """
107109 if self .user_data :
108110 pass
@@ -119,10 +121,10 @@ def get_user_data(self):
119121 return self .user_data .copy ()
120122
121123 def get_chat_data (self ):
122- """" Returns the chat_data from the pickle file if it exsists or an empty defaultdict.
124+ """Returns the chat_data from the pickle file if it exsists or an empty defaultdict.
123125
124126 Returns:
125- :obj:' defaultdict`: The restored chat data.
127+ :obj:` defaultdict`: The restored chat data.
126128 """
127129 if self .chat_data :
128130 pass
@@ -139,13 +141,13 @@ def get_chat_data(self):
139141 return self .chat_data .copy ()
140142
141143 def get_conversations (self , name ):
142- """" Returns the conversations from the pickle file if it exsists or an empty defaultdict.
144+ """Returns the conversations from the pickle file if it exsists or an empty defaultdict.
143145
144146 Args:
145147 name (:obj:`str`): The handlers name.
146148
147149 Returns:
148- :obj:' dict`: The restored conversations for the handler.
150+ :obj:` dict`: The restored conversations for the handler.
149151 """
150152 if self .conversations :
151153 pass
@@ -165,7 +167,7 @@ def update_conversations(self, name, conversations):
165167
166168 Args:
167169 name (:obj:`str`): The handlers name.
168- conversations (:obj:' dict`): The :attr:`telegram.ext.ConversationHandler.conversations`
170+ conversations (:obj:` dict`): The :attr:`telegram.ext.ConversationHandler.conversations`
169171 dict to store.
170172 """
171173 if self .conversations [name ] == conversations :
@@ -179,11 +181,11 @@ def update_conversations(self, name, conversations):
179181 self .dump_singlefile ()
180182
181183 def update_user_data (self , user_data ):
182- """" Will update the user_data (if changed) and depending on :attr:`on_flush` save the
184+ """Will update the user_data (if changed) and depending on :attr:`on_flush` save the
183185 pickle file.
184186
185187 Args:
186- user_data (:obj:' defaultdict`): The :attr:`telegram.ext.dispatcher .user_data`
188+ user_data (:obj:` defaultdict`): The :attr:`telegram.ext.Dispatcher .user_data`
187189 defaultdict to store.
188190 """
189191 if self .user_data == user_data :
@@ -197,11 +199,11 @@ def update_user_data(self, user_data):
197199 self .dump_singlefile ()
198200
199201 def update_chat_data (self , chat_data ):
200- """" Will update the chat_data (if changed) and depending on :attr:`on_flush` save the
202+ """Will update the chat_data (if changed) and depending on :attr:`on_flush` save the
201203 pickle file.
202204
203205 Args:
204- chat_data (:obj:' defaultdict`): The :attr:`telegram.ext.dispatcher .chat_data`
206+ chat_data (:obj:` defaultdict`): The :attr:`telegram.ext.Dispatcher .chat_data`
205207 defaultdict to store.
206208 """
207209 if self .chat_data == chat_data :
0 commit comments