§
    ­eîi]Y  ã                   óÞ  — d Z ddlZddlmZ ddlmZ ddlmZ ddlm	Z	m
Z
mZmZ ddlmZmZ ddlmZ dd	lmZ dd
lmZmZ ddlmZ ddlmZmZmZmZmZmZ dZ dZ! e
de¬¦  «        Z"de#e"         de$e#e"                  fd„Z%de#e"         de&de"fd„Z'de"de(ee(e#e"         e&f         f         fd„Z) G d„ dej*        ¦  «        Z+ G d„ dej,        ¦  «        Z- G d„ deeeef         ¦  «        Z.dS )z1This module contains the PicklePersistence class.é    N)ÚCallable)Údeepcopy)ÚPath)ÚAnyÚTypeVarÚcastÚoverload)ÚBotÚTelegramObject)ÚFilePathInput)Úwarn)ÚBasePersistenceÚPersistenceInput)ÚContextTypes)ÚBDÚCDÚUDÚCDCDataÚConversationDictÚConversationKeyz/a known bot replaced by PTB's PicklePersistencez2an unknown bot replaced by PTB's PicklePersistenceÚTelegramObj)ÚboundÚclsÚreturnc                 ó‚   — |                       ¦   «         }t          |¦  «                             d„ |D ¦   «         ¦  «        S )zsGets all subclasses of the specified object, recursively. from
    https://stackoverflow.com/a/3862957/9706202
    c                 ó6   — g | ]}t          |¦  «        D ]}|‘ŒŒS © )Ú_all_subclasses)Ú.0ÚcÚss      úc/home/div/.hermes/hermes-agent/venv/lib/python3.11/site-packages/telegram/ext/_picklepersistence.pyú
<listcomp>z#_all_subclasses.<locals>.<listcomp>-   s.   € Ð!TÐ!TÐ!T¨ÅÐQRÑASÔASÐ!TÐ!T¸A !Ð!TÐ!TÐ!TÐ!Tó    )Ú__subclasses__ÚsetÚunion)r   Ú
subclassess     r"   r   r   (   s>   € ð ×#Ò#Ñ%Ô%€JÝˆz‰?Œ?× Ò Ð!TÐ!T¨ZÐ!TÑ!TÔ!TÑUÔUÐUr$   Úkwargsc                 óZ   — |                       | ¦  «        }|                     |¦  «         |S )a�  
    This method is used for unpickling. The data, which is in the form a dictionary, is
    converted back into a class. Works mostly the same as :meth:`TelegramObject.__setstate__`.
    This function should be kept in place for backwards compatibility even if the pickling logic
    is changed, since `_custom_reduction` places references to this function into the pickled data.
    )Ú__new__Ú__setstate__)r   r)   Úobjs      r"   Ú_reconstruct_tor.   0   s.   € ð �+Š+�cÑ
Ô
€CØ×Ò�VÑÔÐØ€Jr$   c                 ó~   — |                       d¬¦  «        }t          |d         ¦  «        |d<   t          | j        |ffS )z€
    This method is used for pickling. The bot attribute is preserved so _BotPickler().persistent_id
    works as intended.
    T)Úinclude_privateÚ
api_kwargs)Ú
_get_attrsÚdictr.   Ú	__class__)r   Údatas     r"   Ú_custom_reductionr6   <   sB   € ð
 �>Š>¨$ˆ>Ñ/Ô/€Dõ ˜d <Ô0Ñ1Ô1€DˆÑÝ˜Sœ]¨DÐ1Ð1Ð1r$   c                   ó‚   ‡ — e Zd ZdZdededefˆ fd„Zdedee	ee
e         ef         f         fd„Zdeded	z  fd
„Zˆ xZS )Ú_BotPickler©Ú_botÚbotÚargsr)   c                 óH   •— || _          t          ¦   «         j        |i |¤Ž d S ©N©r:   ÚsuperÚ__init__©Úselfr;   r<   r)   r4   s       €r"   rA   z_BotPickler.__init__K   ó,   ø€ ØˆŒ	Ø�‰ŒÔ˜$Ð) &Ð)Ð)Ð)Ð)Ð)r$   r-   r   c                 óX   — t          |t          ¦  «        st          S t          |¦  «        S )zŒ
        This method is used for pickling. The bot attribute is preserved so
        _BotPickler().persistent_id works as intended.
        )Ú
isinstancer   ÚNotImplementedr6   ©rC   r-   s     r"   Úreducer_overridez_BotPickler.reducer_overrideO   s*   € õ ˜#�~Ñ.Ô.ð 	"Ý!Ð!å  Ñ%Ô%Ð%r$   Nc                 ó€   — || j         u rt          S t          |t          ¦  «        rt	          dd¬¦  «         t
          S dS )z¢Used to 'mark' the Bot, so it can be replaced later. See
        https://docs.python.org/3/library/pickle.html#pickle.Pickler.persistent_id for more info
        zHUnknown bot instance found. Will be replaced by `None` during unpicklingé   )Ú
stacklevelN)r:   Ú_REPLACED_KNOWN_BOTrF   r
   r   Ú_REPLACED_UNKNOWN_BOTrH   s     r"   Úpersistent_idz_BotPickler.persistent_id[   sS   € ð �$”)ÐÐÝ&Ð&Ý�c�3ÑÔð 	)ÝØZØðñ ô ð õ )Ð(Øˆtr$   )Ú__name__Ú
__module__Ú__qualname__Ú	__slots__r
   r   rA   r   Útupler   Útyper3   rI   ÚobjectÚstrrO   Ú__classcell__©r4   s   @r"   r8   r8   H   sº   ø€ € € € € Ø€Ið*˜Cð *¨ð *°sð *ð *ð *ð *ð *ð *ð
&Øð
&à	ˆx˜˜t KÔ0°$Ð6Ô7Ð7Ô	8ð
&ð 
&ð 
&ð 
&ð ð ¨C°$©Jð ð ð ð ð ð ð ð r$   r8   c                   óF   ‡ — e Zd ZdZdededefˆ fd„Zdededz  fd	„Zˆ xZ	S )
Ú_BotUnpicklerr9   r;   r<   r)   c                 óH   •— || _          t          ¦   «         j        |i |¤Ž d S r>   r?   rB   s       €r"   rA   z_BotUnpickler.__init__m   rD   r$   Úpidr   Nc                 óh   — |t           k    r| j        S |t          k    rdS t          j        d¦  «        ‚)zSReplaces the bot with the current bot if known, else it is replaced by :obj:`None`.Nz,Found unknown persistent id when unpickling!)rM   r:   rN   ÚpickleÚUnpicklingError)rC   r]   s     r"   Úpersistent_loadz_BotUnpickler.persistent_loadq   s9   € àÕ%Ò%Ð%Ø”9ÐØÕ'Ò'Ð'Ø�4ÝÔ$Ð%SÑTÔTÐTr$   )
rP   rQ   rR   rS   r
   r   rA   rW   ra   rX   rY   s   @r"   r[   r[   j   s‡   ø€ € € € € Ø€Ið*˜Cð *¨ð *°sð *ð *ð *ð *ð *ð *ðU 3ð U¨3°©:ð Uð Uð Uð Uð Uð Uð Uð Ur$   r[   c                   ól  ‡ — e Zd ZdZdZe	 	 	 	 d1ddd	ed
edz  dedede	fd„¦   «         Z
e	 	 	 	 	 d2ddd	ed
edz  dedede	deeeeef         dz  fd„¦   «         Z
	 	 	 	 	 d2d	ed
edz  dedede	deeeeef         dz  fˆ fd„Z
d3d„Zd	edefd„Zd3d„Zd	ededdfd„Zdeeef         fd„Zdeeef         fd„Zdefd„Zdedz  fd„Zdedefd„Zdede d edz  ddfd!„Z!d"ededdfd#„Z"d$ededdfd%„Z#deddfd&„Z$deddfd'„Z%d$eddfd(„Z&d"eddfd)„Z'd"ed*eddfd+„Z(d$ed,eddfd-„Z)d.eddfd/„Z*d3d0„Z+ˆ xZ,S )4ÚPicklePersistenceaq  Using python's builtin :mod:`pickle` for making your bot persistent.

    Attention:
        The interface provided by this class is intended to be accessed exclusively by
        :class:`~telegram.ext.Application`. Calling any of the methods below manually might
        interfere with the integration of persistence into :class:`~telegram.ext.Application`.

    Note:
        This implementation of :class:`BasePersistence` uses the functionality of the pickle module
        to support serialization of bot instances. Specifically any reference to
        :attr:`~BasePersistence.bot` will be replaced by a placeholder before pickling and
        :attr:`~BasePersistence.bot` will be inserted back when loading the data.

    Examples:
        :any:`Persistent Conversation Bot <examples.persistentconversationbot>`

    .. seealso:: :wiki:`Making Your Bot Persistent <Making-your-bot-persistent>`

    .. versionchanged:: 20.0

        * The parameters and attributes ``store_*_data`` were replaced by :attr:`store_data`.
        * The parameter and attribute ``filename`` were replaced by :attr:`filepath`.
        * :attr:`filepath` now also accepts :obj:`pathlib.Path` as argument.

    Args:
        filepath (:obj:`str` | :obj:`pathlib.Path`): The filepath for storing the pickle files.
            When :attr:`single_file` is :obj:`False` this will be used as a prefix.
        store_data (:class:`~telegram.ext.PersistenceInput`, optional): Specifies which kinds of
            data will be saved by this persistence instance. By default, all available kinds of
            data will be saved.
        single_file (:obj:`bool`, optional): When :obj:`False` will store 5 separate files of
            `filename_user_data`, `filename_bot_data`, `filename_chat_data`,
            `filename_callback_data` and `filename_conversations`. Default is :obj:`True`.
        on_flush (:obj:`bool`, optional): When :obj:`True` will only save to file when
            :meth:`flush` is called and keep data in memory until that happens. When
            :obj:`False` will store data on any transaction *and* on call to :meth:`flush`.
            Default is :obj:`False`.
        context_types (:class:`telegram.ext.ContextTypes`, optional): Pass an instance
            of :class:`telegram.ext.ContextTypes` to customize the types used in the
            ``context`` interface. If not passed, the defaults documented in
            :class:`telegram.ext.ContextTypes` will be used.

            .. versionadded:: 13.6
        update_interval (:obj:`int` | :obj:`float`, optional): The
            :class:`~telegram.ext.Application` will update
            the persistence in regular intervals. This parameter specifies the time (in seconds) to
            wait between two consecutive runs of updating the persistence. Defaults to 60 seconds.

            .. versionadded:: 20.0
    Attributes:
        filepath (:obj:`str` | :obj:`pathlib.Path`): The filepath for storing the pickle files.
            When :attr:`single_file` is :obj:`False` this will be used as a prefix.
        store_data (:class:`~telegram.ext.PersistenceInput`): Specifies which kinds of data will
            be saved by this persistence instance.
        single_file (:obj:`bool`): Optional. When :obj:`False` will store 5 separate files of
            `filename_user_data`, `filename_bot_data`, `filename_chat_data`,
            `filename_callback_data` and `filename_conversations`. Default is :obj:`True`.
        on_flush (:obj:`bool`): Optional. When :obj:`True` will only save to file when
            :meth:`flush` is called and keep data in memory until that happens. When
            :obj:`False` will store data on any transaction *and* on call to :meth:`flush`.
            Default is :obj:`False`.
        context_types (:class:`telegram.ext.ContextTypes`): Container for the types used
            in the ``context`` interface.

            .. versionadded:: 13.6
    )	Úbot_dataÚcallback_dataÚ	chat_dataÚcontext_typesÚconversationsÚfilepathÚon_flushÚsingle_fileÚ	user_dataNTFé<   rC   zAPicklePersistence[dict[Any, Any], dict[Any, Any], dict[Any, Any]]ri   Ú
store_datark   rj   Úupdate_intervalc                 ó   — d S r>   r   )rC   ri   rn   rk   rj   ro   s         r"   rA   zPicklePersistence.__init__Ê   s	   € ð €sr$   zPicklePersistence[UD, CD, BD]rg   c                 ó   — d S r>   r   )rC   ri   rn   rk   rj   ro   rg   s          r"   rA   zPicklePersistence.__init__Ô   s	   € ð €sr$   c                 ó  •— t          ¦   «                              ||¬¦  «         t          |¦  «        | _        || _        || _        d | _        d | _        d | _        d | _	        d | _
        t          d|pt          ¦   «         ¦  «        | _        d S )N)rn   ro   zContextTypes[Any, UD, CD, BD])r@   rA   r   ri   rk   rj   rl   rf   rd   re   rh   r   r   rg   )rC   ri   rn   rk   rj   ro   rg   r4   s          €r"   rA   zPicklePersistence.__init__ß   s‰   ø€ õ 	‰Œ×Ò JÀÐÑPÔPÐPÝ" 8™nœnˆŒØ(3ˆÔØ%-ˆŒØ/3ˆŒØ/3ˆŒØ#'ˆŒØ-1ˆÔØTXˆÔÝ<@Ø+¨]Ð-L½l¹n¼nñ=
ô =
ˆÔÐÐr$   r   c                 óð  — 	 | j                              d¦  «        5 }t          | j        |¦  «                             ¦   «         }d d d ¦  «         n# 1 swxY w Y   |d         | _        |d         | _        |                     d| j         	                    ¦   «         ¦  «        | _	        |                     di ¦  «        | _
        |d         | _        d S # t          $ r> i | _        i | _        i | _        | j         	                    ¦   «         | _	        d | _
        Y d S t          j        $ r%}| j         j        }t!          d|› d�¦  «        |‚d }~wt"          $ r"}t!          d	| j         j        › �¦  «        |‚d }~ww xY w)
NÚrbrl   rf   rd   re   rh   úFile ú# does not contain valid pickle dataú Something went wrong unpickling )ri   Úopenr[   r;   Úloadrl   rf   Úgetrg   rd   re   rh   ÚOSErrorr_   r`   ÚnameÚ	TypeErrorÚ	Exception)rC   Úfiler5   ÚexcÚfilenames        r"   Ú_load_singlefilez"PicklePersistence._load_singlefileõ   sÈ  € ð	^Ø”×#Ò# DÑ)Ô)ð <¨TÝ$ T¤X¨tÑ4Ô4×9Ò9Ñ;Ô;�ð<ð <ð <ñ <ô <ð <ð <ð <ð <ð <ð <øøøð <ð <ð <ð <ð " +Ô.ˆDŒNØ! +Ô.ˆDŒNà ŸHšH Z°Ô1C×1LÒ1LÑ1NÔ1NÑOÔOˆDŒMØ!%§¢¨/¸2Ñ!>Ô!>ˆDÔØ!% oÔ!6ˆDÔÐÐøÝð 	&ð 	&ð 	&Ø!#ˆDÔØˆDŒNØˆDŒNØ Ô.×7Ò7Ñ9Ô9ˆDŒMØ!%ˆDÔÐÐÐÝÔ%ð 	\ð 	\ð 	\Ø”}Ô)ˆHÝÐQ HÐQÐQÐQÑRÔRÐX[Ð[øøøøÝð 	^ð 	^ð 	^ÝÐS¸t¼}Ô?QÐSÐSÑTÔTÐZ]Ð]øøøøð	^øøøsN   ‚C œ(AÁC ÁAÁC ÁAÁA7C ÃAE5ÄE5Ä& EÅE5ÅE0Å0E5c                 ór  — 	 |                      d¦  «        5 }t          | j        |¦  «                             ¦   «         cd d d ¦  «         S # 1 swxY w Y   d S # t          $ r Y d S t
          j        $ r}t          d|j        › d�¦  «        |‚d }~wt          $ r}t          d|j        › �¦  «        |‚d }~ww xY w)Nrt   ru   rv   rw   )
rx   r[   r;   ry   r{   r_   r`   r}   r|   r~   )rC   ri   r   r€   s       r"   Ú
_load_filezPicklePersistence._load_file  s+  € ð		YØ—’˜tÑ$Ô$ð <¨Ý$ T¤X¨tÑ4Ô4×9Ò9Ñ;Ô;ð<ð <ð <ð <ñ <ô <ð <ð <ð <ð <ð <ð <øøøð <ð <ð <ð <ð <ð <øõ ð 	ð 	ð 	Ø�4�4ÝÔ%ð 	að 	að 	aÝÐV H¤MÐVÐVÐVÑWÔWÐ]`Ð`øøøøÝð 	Yð 	Yð 	YÝÐN¸x¼}ÐNÐNÑOÔOÐUXÐXøøøøð	YøøøsK   ‚A —'A¾A ÁAÁA ÁAÁA Á
B6Á%B6Á3BÂB6ÂB1Â1B6c                 ó  — | j         | j        | j        | j        | j        dœ}| j                             d¦  «        5 }t          | j        |t          j
        ¬¦  «                             |¦  «         d d d ¦  «         d S # 1 swxY w Y   d S )N)rh   rl   rf   rd   re   Úwb©Úprotocol)rh   rl   rf   rd   re   ri   rx   r8   r;   r_   ÚHIGHEST_PROTOCOLÚdump)rC   r5   r   s      r"   Ú_dump_singlefilez"PicklePersistence._dump_singlefile  sÝ   € à!Ô/ØœØœØœØ!Ô/ð
ð 
ˆð Œ]×Ò Ñ%Ô%ð 	U¨Ý˜œ $µÔ1HÐIÑIÔI×NÒNÈtÑTÔTÐTð	Uð 	Uð 	Uñ 	Uô 	Uð 	Uð 	Uð 	Uð 	Uð 	Uð 	Uð 	Uøøøð 	Uð 	Uð 	Uð 	Uð 	Uð 	Us   ¼5A>Á>BÂBr5   c                 óÊ   — |                      d¦  «        5 }t          | j        |t          j        ¬¦  «                             |¦  «         d d d ¦  «         d S # 1 swxY w Y   d S )Nr†   r‡   )rx   r8   r;   r_   r‰   rŠ   )rC   ri   r5   r   s       r"   Ú
_dump_filezPicklePersistence._dump_file#  s°   € Ø�]Š]˜4Ñ Ô ð 	U DÝ˜œ $µÔ1HÐIÑIÔI×NÒNÈtÑTÔTÐTð	Uð 	Uð 	Uñ 	Uô 	Uð 	Uð 	Uð 	Uð 	Uð 	Uð 	Uð 	Uøøøð 	Uð 	Uð 	Uð 	Uð 	Uð 	Us   –5AÁAÁAc              ƒ   óà   K  — | j         rnQ| j        s6|                      t          | j        › d�¦  «        ¦  «        }|si }|| _         n|                      ¦   «          t          | j         ¦  «        S )z®Returns the user_data from the pickle file if it exists or an empty :obj:`dict`.

        Returns:
            dict[:obj:`int`, :obj:`dict`]: The restored user data.
        Ú
_user_data)rl   rk   r„   r   ri   r‚   r   ©rC   r5   s     r"   Úget_user_datazPicklePersistence.get_user_data'  ó|   è è € ð Œ>ð 	$ØØÔ!ð 	$Ø—?’?¥4¨4¬=Ð(DÐ(DÐ(DÑ#EÔ#EÑFÔFˆDØð Ø�Ø!ˆDŒNˆNà×!Ò!Ñ#Ô#Ð#Ý˜œÑ'Ô'Ð'r$   c              ƒ   óà   K  — | j         rnQ| j        s6|                      t          | j        › d�¦  «        ¦  «        }|si }|| _         n|                      ¦   «          t          | j         ¦  «        S )z®Returns the chat_data from the pickle file if it exists or an empty :obj:`dict`.

        Returns:
            dict[:obj:`int`, :obj:`dict`]: The restored chat data.
        Ú
_chat_data)rf   rk   r„   r   ri   r‚   r   r�   s     r"   Úget_chat_datazPicklePersistence.get_chat_data8  r’   r$   c              ƒ   ó  K  — | j         rnh| j        sM|                      t          | j        › d�¦  «        ¦  «        }|s| j                              ¦   «         }|| _         n|                      ¦   «          t          | j         ¦  «        S )a  Returns the bot_data from the pickle file if it exists or an empty object of type
        :obj:`dict` | :attr:`telegram.ext.ContextTypes.bot_data`.

        Returns:
            :obj:`dict` | :attr:`telegram.ext.ContextTypes.bot_data`: The restored bot data.
        Ú	_bot_data)rd   rk   r„   r   ri   rg   r‚   r   r�   s     r"   Úget_bot_datazPicklePersistence.get_bot_dataI  s‹   è è € ð Œ=ð 	$ØØÔ!ð 	$Ø—?’?¥4¨4¬=Ð(CÐ(CÐ(CÑ#DÔ#DÑEÔEˆDØð 5ØÔ)×2Ò2Ñ4Ô4�Ø ˆDŒMˆMà×!Ò!Ñ#Ô#Ð#Ý˜œÑ&Ô&Ð&r$   c              ƒ   óò   K  — | j         rnQ| j        s6|                      t          | j        › d�¦  «        ¦  «        }|sd}|| _         n|                      ¦   «          | j         €dS t          | j         ¦  «        S )ad  Returns the callback data from the pickle file if it exists or :obj:`None`.

        .. versionadded:: 13.6

        Returns:
            tuple[list[tuple[:obj:`str`, :obj:`float`, dict[:obj:`str`, :class:`object`]]],
            dict[:obj:`str`, :obj:`str`]] | :obj:`None`: The restored metadata or :obj:`None`,
            if no data was stored.
        Ú_callback_dataN)re   rk   r„   r   ri   r‚   r   r�   s     r"   Úget_callback_dataz#PicklePersistence.get_callback_data[  sŽ   è è € ð Ôð 	$ØØÔ!ð 	$Ø—?’?¥4¨4¬=Ð(HÐ(HÐ(HÑ#IÔ#IÑJÔJˆDØð Ø�Ø!%ˆDÔÐà×!Ò!Ñ#Ô#Ð#ØÔÐ%Ø�4Ý˜Ô*Ñ+Ô+Ð+r$   r|   c              ƒ   ó  K  — | j         rnS| j        s8|                      t          | j        › d�¦  «        ¦  «        }|s|i i}|| _         n|                      ¦   «          | j                              |i ¦  «                             ¦   «         S )zîReturns the conversations from the pickle file if it exists or an empty dict.

        Args:
            name (:obj:`str`): The handlers name.

        Returns:
            :obj:`dict`: The restored conversations for the handler.
        Ú_conversations)rh   rk   r„   r   ri   r‚   rz   Úcopy)rC   r|   r5   s      r"   Úget_conversationsz#PicklePersistence.get_conversationsr  s˜   è è € ð Ôð 	$ØØÔ!ð 	$Ø—?’?¥4¨4¬=Ð(HÐ(HÐ(HÑ#IÔ#IÑJÔJˆDØð "Ø˜b�z�Ø!%ˆDÔÐà×!Ò!Ñ#Ô#Ð#ØÔ!×%Ò% d¨BÑ/Ô/×4Ò4Ñ6Ô6Ð6r$   ÚkeyÚ	new_statec              ƒ   óZ  K  — | j         si | _         | j                              |i ¦  «                             |¦  «        |k    rdS || j         |         |<   | j        sO| j        s2|                      t          | j        › d�¦  «        | j         ¦  «         dS |                      ¦   «          dS dS )aJ  Will update the conversations for the given handler and depending on :attr:`on_flush`
        save the pickle file.

        Args:
            name (:obj:`str`): The handler's name.
            key (:obj:`tuple`): The key the state is changed for.
            new_state (:class:`object`): The new state for the given key.
        Nr�   )	rh   Ú
setdefaultrz   rj   rk   r�   r   ri   r‹   )rC   r|   r    r¡   s       r"   Úupdate_conversationz%PicklePersistence.update_conversation†  sÅ   è è € ð Ô!ð 	$Ø!#ˆDÔØÔ×(Ò(¨¨rÑ2Ô2×6Ò6°sÑ;Ô;¸yÒHÐHØˆFØ(1ˆÔ˜4Ô  Ñ%ØŒ}ð 	(ØÔ#ð (Ø—’¥¨¬Ð%EÐ%EÐ%EÑ FÔ FÈÔHZÑ[Ô[Ð[Ð[Ð[à×%Ò%Ñ'Ô'Ð'Ð'Ð'ð		(ð 	(r$   Úuser_idc              ƒ   ó&  K  — | j         €i | _         | j                              |¦  «        |k    rdS || j         |<   | j        sO| j        s2|                      t          | j        › d�¦  «        | j         ¦  «         dS |                      ¦   «          dS dS )a  Will update the user_data and depending on :attr:`on_flush` save the pickle file.

        Args:
            user_id (:obj:`int`): The user the data might have been changed for.
            data (:obj:`dict`): The :attr:`telegram.ext.Application.user_data` ``[user_id]``.
        Nr�   )rl   rz   rj   rk   r�   r   ri   r‹   )rC   r¥   r5   s      r"   Úupdate_user_dataz"PicklePersistence.update_user_dataœ  ó©   è è € ð Œ>Ð!ØˆDŒNØŒ>×Ò˜gÑ&Ô&¨$Ò.Ð.ØˆFØ"&ˆŒ�wÑØŒ}ð 	(ØÔ#ð (Ø—’¥¨¬Ð%AÐ%AÐ%AÑ BÔ BÀDÄNÑSÔSÐSÐSÐSà×%Ò%Ñ'Ô'Ð'Ð'Ð'ð		(ð 	(r$   Úchat_idc              ƒ   ó&  K  — | j         €i | _         | j                              |¦  «        |k    rdS || j         |<   | j        sO| j        s2|                      t          | j        › d�¦  «        | j         ¦  «         dS |                      ¦   «          dS dS )a  Will update the chat_data and depending on :attr:`on_flush` save the pickle file.

        Args:
            chat_id (:obj:`int`): The chat the data might have been changed for.
            data (:obj:`dict`): The :attr:`telegram.ext.Application.chat_data` ``[chat_id]``.
        Nr”   )rf   rz   rj   rk   r�   r   ri   r‹   )rC   r©   r5   s      r"   Úupdate_chat_dataz"PicklePersistence.update_chat_data®  r¨   r$   c              ƒ   óÞ   K  — | j         |k    rdS || _         | j        sO| j        s2|                      t	          | j        › d�¦  «        | j         ¦  «         dS |                      ¦   «          dS dS )zôWill update the bot_data and depending on :attr:`on_flush` save the pickle file.

        Args:
            data (:obj:`dict` | :attr:`telegram.ext.ContextTypes.bot_data`): The
                :attr:`telegram.ext.Application.bot_data`.
        Nr—   )rd   rj   rk   r�   r   ri   r‹   r�   s     r"   Úupdate_bot_dataz!PicklePersistence.update_bot_dataÀ  s‡   è è € ð Œ=˜DÒ Ð ØˆFØˆŒØŒ}ð 	(ØÔ#ð (Ø—’¥¨¬Ð%@Ð%@Ð%@Ñ AÔ AÀ4Ä=ÑQÔQÐQÐQÐQà×%Ò%Ñ'Ô'Ð'Ð'Ð'ð		(ð 	(r$   c              ƒ   óÞ   K  — | j         |k    rdS || _         | j        sO| j        s2|                      t	          | j        › d�¦  «        | j         ¦  «         dS |                      ¦   «          dS dS )aŠ  Will update the callback_data (if changed) and depending on :attr:`on_flush` save the
        pickle file.

        .. versionadded:: 13.6

        Args:
            data (tuple[list[tuple[:obj:`str`, :obj:`float`,                 dict[:obj:`str`, :class:`object`]]], dict[:obj:`str`, :obj:`str`]]):
                The relevant data to restore :class:`telegram.ext.CallbackDataCache`.
        Nrš   )re   rj   rk   r�   r   ri   r‹   r�   s     r"   Úupdate_callback_dataz&PicklePersistence.update_callback_dataÐ  sŠ   è è € ð Ô Ò%Ð%ØˆFØ!ˆÔØŒ}ð 	(ØÔ#ð (Ø—’¥¨¬Ð%EÐ%EÐ%EÑ FÔ FÈÔHZÑ[Ô[Ð[Ð[Ð[à×%Ò%Ñ'Ô'Ð'Ð'Ð'ð		(ð 	(r$   c              ƒ   óþ   K  — | j         €dS | j                              |d¦  «         | j        sO| j        s2|                      t          | j        › d�¦  «        | j         ¦  «         dS |                      ¦   «          dS dS )zúWill delete the specified key from the ``chat_data`` and depending on
        :attr:`on_flush` save the pickle file.

        .. versionadded:: 20.0

        Args:
            chat_id (:obj:`int`): The chat id to delete from the persistence.
        Nr”   )rf   Úpoprj   rk   r�   r   ri   r‹   )rC   r©   s     r"   Údrop_chat_dataz PicklePersistence.drop_chat_dataä  ó“   è è € ð Œ>Ð!ØˆFØŒ×Ò˜7 DÑ)Ô)Ð)àŒ}ð 	(ØÔ#ð (Ø—’¥¨¬Ð%AÐ%AÐ%AÑ BÔ BÀDÄNÑSÔSÐSÐSÐSà×%Ò%Ñ'Ô'Ð'Ð'Ð'ð		(ð 	(r$   c              ƒ   óþ   K  — | j         €dS | j                              |d¦  «         | j        sO| j        s2|                      t          | j        › d�¦  «        | j         ¦  «         dS |                      ¦   «          dS dS )zúWill delete the specified key from the ``user_data`` and depending on
        :attr:`on_flush` save the pickle file.

        .. versionadded:: 20.0

        Args:
            user_id (:obj:`int`): The user id to delete from the persistence.
        Nr�   )rl   r±   rj   rk   r�   r   ri   r‹   )rC   r¥   s     r"   Údrop_user_dataz PicklePersistence.drop_user_data÷  r³   r$   rl   c              ƒ   ó
   K  — dS )z‚Does nothing.

        .. versionadded:: 13.6
        .. seealso:: :meth:`telegram.ext.BasePersistence.refresh_user_data`
        Nr   )rC   r¥   rl   s      r"   Úrefresh_user_dataz#PicklePersistence.refresh_user_data
  ó
   è è € € € r$   rf   c              ƒ   ó
   K  — dS )z‚Does nothing.

        .. versionadded:: 13.6
        .. seealso:: :meth:`telegram.ext.BasePersistence.refresh_chat_data`
        Nr   )rC   r©   rf   s      r"   Úrefresh_chat_dataz#PicklePersistence.refresh_chat_data  r¸   r$   rd   c              ƒ   ó
   K  — dS )z�Does nothing.

        .. versionadded:: 13.6
        .. seealso:: :meth:`telegram.ext.BasePersistence.refresh_bot_data`
        Nr   )rC   rd   s     r"   Úrefresh_bot_dataz"PicklePersistence.refresh_bot_data  r¸   r$   c              ƒ   ó¸  K  — | j         r;| j        s| j        s| j        s| j        s| j        r|                      ¦   «          dS dS | j        r0|                      t          | j	        › d�¦  «        | j        ¦  «         | j        r0|                      t          | j	        › d�¦  «        | j        ¦  «         | j        r0|                      t          | j	        › d�¦  «        | j        ¦  «         | j        r0|                      t          | j	        › d�¦  «        | j        ¦  «         | j        r2|                      t          | j	        › d�¦  «        | j        ¦  «         dS dS )z/Will save all data in memory to pickle file(s).r�   r”   r—   rš   r�   N)
rk   rl   rf   rd   re   rh   r‹   r�   r   ri   )rC   s    r"   ÚflushzPicklePersistence.flush  sŒ  è è € àÔð 	\à”ð(à”>ð(ð ”=ð(ð Ô%ð	(ð
 Ô%ð(ð ×%Ò%Ñ'Ô'Ð'Ð'Ð'ð(ð (ð Œ~ð TØ—’¥¨¬Ð%AÐ%AÐ%AÑ BÔ BÀDÄNÑSÔSÐSØŒ~ð TØ—’¥¨¬Ð%AÐ%AÐ%AÑ BÔ BÀDÄNÑSÔSÐSØŒ}ð RØ—’¥¨¬Ð%@Ð%@Ð%@Ñ AÔ AÀ4Ä=ÑQÔQÐQØÔ!ð \Ø—’¥¨¬Ð%EÐ%EÐ%EÑ FÔ FÈÔHZÑ[Ô[Ð[ØÔ!ð \Ø—’¥¨¬Ð%EÐ%EÐ%EÑ FÔ FÈÔHZÑ[Ô[Ð[Ð[Ð[ð\ð \r$   )NTFrm   )NTFrm   N)r   N)-rP   rQ   rR   Ú__doc__rS   r	   r   r   ÚboolÚfloatrA   r   r   r   r   r   r‚   r   r„   r‹   rV   r�   r3   Úintr‘   r•   r˜   r   r›   rW   r   rŸ   r   r¤   r§   r«   r­   r¯   r²   rµ   r·   rº   r¼   r¾   rX   rY   s   @r"   rc   rc   z   s„  ø€ € € € € ðAð AðF
€Ið ð /3Ø ØØ!#ðð ØQðàðð % tÑ+ðð ð	ð
 ðð ðð ð ñ „Xðð ð /3Ø ØØ!#Ø>Bðð Ø-ðàðð % tÑ+ðð ð	ð
 ðð ðð $ C¨¨R° OÔ4°tÑ;ðð ð ñ „Xðð /3Ø ØØ!#Ø>Bð
ð 
àð
ð % tÑ+ð
ð ð	
ð
 ð
ð ð
ð $ C¨¨R° OÔ4°tÑ;ð
ð 
ð 
ð 
ð 
ð 
ð,^ð ^ð ^ð ^ð.
Y 4ð 
Y¨Cð 
Yð 
Yð 
Yð 
Yð	Uð 	Uð 	Uð 	UðU 4ð U¨vð U¸$ð Uð Uð Uð Uð( T¨#¨r¨'¤]ð (ð (ð (ð (ð"( T¨#¨r¨'¤]ð (ð (ð (ð (ð"' Bð 'ð 'ð 'ð 'ð$,¨°4©ð ,ð ,ð ,ð ,ð.7¨Cð 7Ð4Dð 7ð 7ð 7ð 7ð((Øð(Ø-ð(Ø:@À4¹-ð(à	ð(ð (ð (ð (ð,(¨cð (¸ð (Àð (ð (ð (ð (ð$(¨cð (¸ð (Àð (ð (ð (ð (ð$(¨"ð (°ð (ð (ð (ð (ð (¨wð (¸4ð (ð (ð (ð (ð((¨Cð (°Dð (ð (ð (ð (ð&(¨Cð (°Dð (ð (ð (ð (ð&¨sð ¸rð Àdð ð ð ð ð¨sð ¸rð Àdð ð ð ð ð¨rð °dð ð ð ð ð\ð \ð \ð \ð \ð \ð \ð \r$   rc   )/r¿   r_   Úcollections.abcr   rž   r   Úpathlibr   Útypingr   r   r   r	   Útelegramr
   r   Útelegram._utils.typesr   Útelegram._utils.warningsr   Útelegram.extr   r   Útelegram.ext._contexttypesr   Útelegram.ext._utils.typesr   r   r   r   r   r   rM   rN   r   rU   r&   r   r3   r.   rT   r6   ÚPicklerr8   Ú	Unpicklerr[   rc   r   r$   r"   ú<module>rÎ      s|  ðð& 8Ð 7à €€€Ø $Ð $Ð $Ð $Ð $Ð $Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø /Ð /Ð /Ð /Ð /Ð /Ð /Ð /Ð /Ð /Ð /Ð /à (Ð (Ð (Ð (Ð (Ð (Ð (Ð (Ø /Ð /Ð /Ð /Ð /Ð /Ø )Ð )Ð )Ð )Ð )Ð )Ø :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ø 3Ð 3Ð 3Ð 3Ð 3Ð 3Ø \Ð \Ð \Ð \Ð \Ð \Ð \Ð \Ð \Ð \Ð \Ð \Ð \Ð \Ð \Ð \àGÐ ØLÐ àˆg�m¨>Ð:Ñ:Ô:€ðV˜˜kÔ*ð V¨s°4¸Ô3DÔ/Eð Vð Vð Vð Vð	˜˜kÔ*ð 	°Dð 	¸[ð 	ð 	ð 	ð 	ð	2˜;ð 	2¨5°¸5ÀÀkÔARÐTXÐAXÔ;YÐ1YÔ+Zð 	2ð 	2ð 	2ð 	2ðð ð ð ð �&”.ñ ô ð ðDUð Uð Uð Uð U�FÔ$ñ Uô Uð Uð z\ð z\ð z\ð z\ð z\˜¨¨B°¨
Ô3ñ z\ô z\ð z\ð z\ð z\r$   