@@ -76,7 +76,7 @@ class BasePersistence(Generic[UD, CD, BD], ABC):
76
76
store_bot_data (:obj:`bool`, optional): Whether bot_data should be saved by this
77
77
persistence class. Default is :obj:`True`.
78
78
store_callback_data (:obj:`bool`, optional): Whether callback_data should be saved by this
79
- persistence class. Default is :obj:`False `.
79
+ persistence class. Default is :obj:`True `.
80
80
81
81
.. versionadded:: 13.6
82
82
@@ -176,7 +176,7 @@ def __init__(
176
176
store_user_data : bool = True ,
177
177
store_chat_data : bool = True ,
178
178
store_bot_data : bool = True ,
179
- store_callback_data : bool = False ,
179
+ store_callback_data : bool = True ,
180
180
):
181
181
self .store_user_data = store_user_data
182
182
self .store_chat_data = store_chat_data
@@ -439,17 +439,20 @@ def get_bot_data(self) -> BD:
439
439
:class:`telegram.ext.utils.types.BD`: The restored bot data.
440
440
"""
441
441
442
+ @abstractmethod
442
443
def get_callback_data (self ) -> Optional [CDCData ]:
443
444
"""Will be called by :class:`telegram.ext.Dispatcher` upon creation with a
444
445
persistence object. If callback data was stored, it should be returned.
445
446
446
447
.. versionadded:: 13.6
447
448
449
+ .. versionchanged:: 14.0
450
+ Changed this method into an ``@abstractmethod``.
451
+
448
452
Returns:
449
453
Optional[:class:`telegram.ext.utils.types.CDCData`]: The restored meta data or
450
454
:obj:`None`, if no data was stored.
451
455
"""
452
- raise NotImplementedError
453
456
454
457
@abstractmethod
455
458
def get_conversations (self , name : str ) -> ConversationDict :
@@ -510,56 +513,75 @@ def update_bot_data(self, data: BD) -> None:
510
513
:attr:`telegram.ext.Dispatcher.bot_data`.
511
514
"""
512
515
516
+ @abstractmethod
513
517
def refresh_user_data (self , user_id : int , user_data : UD ) -> None :
514
518
"""Will be called by the :class:`telegram.ext.Dispatcher` before passing the
515
519
:attr:`user_data` to a callback. Can be used to update data stored in :attr:`user_data`
516
520
from an external source.
517
521
518
522
.. versionadded:: 13.6
519
523
524
+ .. versionchanged:: 14.0
525
+ Changed this method into an ``@abstractmethod``.
526
+
520
527
Args:
521
528
user_id (:obj:`int`): The user ID this :attr:`user_data` is associated with.
522
529
user_data (:class:`telegram.ext.utils.types.UD`): The ``user_data`` of a single user.
523
530
"""
524
531
532
+ @abstractmethod
525
533
def refresh_chat_data (self , chat_id : int , chat_data : CD ) -> None :
526
534
"""Will be called by the :class:`telegram.ext.Dispatcher` before passing the
527
535
:attr:`chat_data` to a callback. Can be used to update data stored in :attr:`chat_data`
528
536
from an external source.
529
537
530
538
.. versionadded:: 13.6
531
539
540
+ .. versionchanged:: 14.0
541
+ Changed this method into an ``@abstractmethod``.
542
+
532
543
Args:
533
544
chat_id (:obj:`int`): The chat ID this :attr:`chat_data` is associated with.
534
545
chat_data (:class:`telegram.ext.utils.types.CD`): The ``chat_data`` of a single chat.
535
546
"""
536
547
548
+ @abstractmethod
537
549
def refresh_bot_data (self , bot_data : BD ) -> None :
538
550
"""Will be called by the :class:`telegram.ext.Dispatcher` before passing the
539
551
:attr:`bot_data` to a callback. Can be used to update data stored in :attr:`bot_data`
540
552
from an external source.
541
553
542
554
.. versionadded:: 13.6
543
555
556
+ .. versionchanged:: 14.0
557
+ Changed this method into an ``@abstractmethod``.
558
+
544
559
Args:
545
560
bot_data (:class:`telegram.ext.utils.types.BD`): The ``bot_data``.
546
561
"""
547
562
563
+ @abstractmethod
548
564
def update_callback_data (self , data : CDCData ) -> None :
549
565
"""Will be called by the :class:`telegram.ext.Dispatcher` after a handler has
550
566
handled an update.
551
567
552
568
.. versionadded:: 13.6
553
569
570
+ .. versionchanged:: 14.0
571
+ Changed this method into an ``@abstractmethod``.
572
+
554
573
Args:
555
574
data (:class:`telegram.ext.utils.types.CDCData`): The relevant data to restore
556
575
:class:`telegram.ext.CallbackDataCache`.
557
576
"""
558
- raise NotImplementedError
559
577
578
+ @abstractmethod
560
579
def flush (self ) -> None :
561
580
"""Will be called by :class:`telegram.ext.Updater` upon receiving a stop signal. Gives the
562
581
persistence a chance to finish up saving or close a database connection gracefully.
582
+
583
+ .. versionchanged:: 14.0
584
+ Changed this method into an ``@abstractmethod``.
563
585
"""
564
586
565
587
REPLACED_BOT : ClassVar [str ] = 'bot_instance_replaced_by_ptb_persistence'
0 commit comments