Ë
    †j«K ã                   ó*  — U d Z ddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZ ddlmZmZmZmZ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mZmZmZmZm Z  dd	l!m"Z" dd
l#m$Z$m%Z%m&Z&m'Z'm(Z( ddl)m*Z* ddl+m,Z, ddl-m.Z.m/Z/m0Z0m1Z1 ddl2m3Z3 ddl4m5Z5 ddl6m7Z7 ddl8m9Z9 ddl:m;Z; ddl<m=Z= ddl>m?Z? ddl@mAZA ddlBmCZC ddlDmEZE ddlFmGZGmHZHmIZImJZJmKZKmLZLmMZMmNZNmOZO ddlPmQZQ er&ddlRmRZR ddlSmTZT ddlUmVZVmWZW ddlXmYZY ddlZm[Z[ ddl\m]Z] dZ^e_e`d <    e d!d"¬#«      Za eb«       Zc e(d«      Zde	jÊ                  d$k\  reeL   Zfned%deLf   eeL   z  Zfee`d&<   efeL   dz  Zgee`d'<    e*eh«      Zi G d(„ d)ej«      Zk G d*„ d"ejØ                  d"   eeHeIeMeJeGeKf   «      Zmy)+z+This module contains the Application class.é    N)Údefaultdict)Ú	AwaitableÚCallableÚ	CoroutineÚ	GeneratorÚMappingÚSequence)Údeepcopy)ÚPath)ÚMappingProxyTypeÚTracebackType)ÚTYPE_CHECKINGÚAnyÚGenericÚNoReturnÚ	TypeAliasÚTypeVar)ÚUpdate)Ú
DEFAULT_80Ú
DEFAULT_IPÚDEFAULT_NONEÚDEFAULT_TRUEÚDefaultValue)Ú
get_logger)Úbuild_repr_with_selected_attrs)ÚSCTÚDVTypeÚODVInputÚ
TimePeriod)Úwarn)ÚTelegramError)ÚBasePersistence)ÚContextTypes)ÚExtBot)ÚBaseHandler)ÚUpdater)Únetwork_retry_loop)Úwas_called_by)ÚTrackingDict)	ÚBDÚBTÚCCTÚCDÚJQÚRTÚUDÚConversationKeyÚHandlerCallback)ÚPTBDeprecationWarning)Úsocket)ÚMessage)ÚConversationHandlerÚJobQueue)ÚInitApplicationBuilder)ÚBaseUpdateProcessor)ÚJobÚDEFAULT_GROUPÚ_AppTypeÚApplication)Úbound©é   é   zasyncio.Future[object]Ú	_CoroTypeÚ_ErrorCoroTypec                   ó8   ‡ — e Zd ZdZdZddedz  ddfˆ fd„Zˆ xZS )ÚApplicationHandlerStopaÜ  
    Raise this in a handler or an error handler to prevent execution of any other handler (even in
    different groups).

    In order to use this exception in a :class:`telegram.ext.ConversationHandler`, pass the
    optional :paramref:`state` parameter instead of returning the next state:

    .. code-block:: python

        async def conversation_callback(update, context):
            ...
            raise ApplicationHandlerStop(next_state)

    Note:
        Has no effect, if the handler or error handler is run in a non-blocking way.

    Args:
        state (:obj:`object`, optional): The next state of the conversation.

    Attributes:
        state (:obj:`object`): Optional. The next state of the conversation.
    )ÚstateNrF   Úreturnc                 ó0   •— t         ‰| �  «        || _        y ©N)ÚsuperÚ__init__rF   )ÚselfrF   Ú	__class__s     €úX/var/www/html/datingFans/myenv/lib/python3.12/site-packages/telegram/ext/_application.pyrK   zApplicationHandlerStop.__init__q   s   ø€ Ü‰ÑÔØ$)ˆ�
ó    rI   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__ÚobjectrK   Ú__classcell__)rM   s   @rN   rE   rE   W   s+   ø„ ñð. €Iñ*˜f t™mð *°t÷ *ñ *rO   rE   c            !       ó  — e Zd ZdZdej
                  dk\  rdndz   Zddded	d
dedz  de	ddde
eeef   dz  deeeeef   dedgeeedf   f   dz  dedgeeedf   f   dz  dedgeeedf   f   dz  fd„Zdedefd„Zdee   dz  dedz  dedz  ddfd„Zdefd„Zedefd„«       Zedefd„«       Z edyd„«       Z!edzd „«       Z"e#de$fd!„«       Z%e#d{d"„«       Z&d|d#„Z'd|d$„Z(d}d&„Z)d|d'„Z*d|d(„Z+d|d)„Z,d|d*„Z-d|d+„Z.d, e/j`                  d-¬.«      d/ddd0e1fd1e2d2e3d3ed4e4e   dz  d5edz  d6ed7e5e4e      ddfd8„Z6e7e8d9ddd/ddddd:d0e1ddfd;e9e   d<e9e   d=ed>ee:z  dz  d?ee:z  dz  d3ed@edz  d4e4e   dz  d5edz  dAedz  dBed6ed7e5e4e      dCedz  dDdEddf dF„Z;dGeddfdH„Z<	 d~dIed7e5e4e      d3ed6eddf
dJ„Z=	 dddKœdLe>e?   dMe@dz  dNedz  ddOfdP„ZA	 	 	 d€dLe>e?   dMe@dz  dQedNedz  ddOf
dR„ZBdSeCjˆ                  ddfdT„ZE	 	 d�dLe>e?   dMe@dz  dQede?fdU„ZFd|dV„ZGd|dW„ZHdMe@ddfdX„ZIdMe@ddfdY„ZJeKfd%eLeeef   dZeddfd[„ZMeNfd\e4eLeeef      eOee4eLeeef      f   z  dZeePe   z  ddfd]„ZQeKfd%eLeeef   dZeddfd^„ZRd_eddfd`„ZSdaeddfdb„ZT	 	 	 d‚dcdddeedz  dfedz  ddfdg„ZUdddhœdMe@dz  didjddfdk„ZV	 dƒdleWe   dz  dmeWe   dz  ddfdn„ZXd|do„ZYd|dp„ZZd|dq„Z[e\fdre]e@edf   dse9e   ddfdt„Z^dre]e@edf   ddfdu„Z_	 	 dƒdMe@dz  dve`didwdLeae?   dz  def
dx„Zby)„r=   a‘  This class dispatches all kinds of updates to its registered handlers, and is the entry
    point to a PTB application.

    Tip:
         This class may not be initialized directly. Use :class:`telegram.ext.ApplicationBuilder`
         or :meth:`builder` (for convenience).

    Instances of this class can be used as asyncio context managers, where

    .. code:: python

        async with application:
            # code

    is roughly equivalent to

    .. code:: python

        try:
            await application.initialize()
            # code
        finally:
            await application.shutdown()

    .. seealso:: :meth:`__aenter__` and :meth:`__aexit__`.

    This class is a :class:`~typing.Generic` class and accepts six type variables:

    1. The type of :attr:`bot`. Must be :class:`telegram.Bot` or a subclass of that class.
    2. The type of the argument ``context`` of callback functions for (error) handlers and jobs.
       Must be :class:`telegram.ext.CallbackContext` or a subclass of that class. This must be
       consistent with the following types.
    3. The type of the values of :attr:`user_data`.
    4. The type of the values of :attr:`chat_data`.
    5. The type of :attr:`bot_data`.
    6. The type of :attr:`job_queue`. Must either be :class:`telegram.ext.JobQueue` or a subclass
       of that or :obj:`None`.

    Examples:
        :any:`Echo Bot <examples.echobot>`

    .. seealso:: :wiki:`Your First Bot <Extensions---Your-first-Bot>`,
        :wiki:`Architecture Overview <Architecture>`

    .. versionchanged:: 20.0

        * Initialization is now done through the :class:`telegram.ext.ApplicationBuilder`.
        * Removed the attribute ``groups``.

    Attributes:
        bot (:class:`telegram.Bot`): The bot object that should be passed to the handlers.
        update_queue (:class:`asyncio.Queue`): The synchronized queue that will contain the
            updates.
        updater (:class:`telegram.ext.Updater`): Optional. The updater used by this application.
        chat_data (:obj:`types.MappingProxyType`): A dictionary handlers can use to store data for
            the chat. For each integer chat id, the corresponding value of this mapping is
            available as :attr:`telegram.ext.CallbackContext.chat_data` in handler callbacks for
            updates from that chat.

            .. versionchanged:: 20.0
                :attr:`chat_data` is now read-only. Note that the values of the mapping are still
                mutable, i.e. editing ``context.chat_data`` within a handler callback is possible
                (and encouraged), but editing the mapping ``application.chat_data`` itself is not.

            .. tip::

                * Manually modifying :attr:`chat_data` is almost never needed and unadvisable.
                * Entries are never deleted automatically from this mapping. If you want to delete
                  the data associated with a specific chat, e.g. if the bot got removed from that
                  chat, please use :meth:`drop_chat_data`.

        user_data (:obj:`types.MappingProxyType`): A dictionary handlers can use to store data for
            the user. For each integer user id, the corresponding value of this mapping is
            available as :attr:`telegram.ext.CallbackContext.user_data` in handler callbacks for
            updates from that user.

            .. versionchanged:: 20.0
                :attr:`user_data` is now read-only. Note that the values of the mapping are still
                mutable, i.e. editing ``context.user_data`` within a handler callback is possible
                (and encouraged), but editing the mapping ``application.user_data`` itself is not.

            .. tip::

               * Manually modifying :attr:`user_data` is almost never needed and unadvisable.
               * Entries are never deleted automatically from this mapping. If you want to delete
                 the data associated with a specific user, e.g. if that user blocked the bot,
                 please use :meth:`drop_user_data`.

        bot_data (:obj:`dict`): A dictionary handlers can use to store data for the bot.
        persistence (:class:`telegram.ext.BasePersistence`): The persistence class to
            store data that should be persistent over restarts.
        handlers (dict[:obj:`int`, list[:class:`telegram.ext.BaseHandler`]]): A dictionary mapping
            each handler group to the list of handlers registered to that group.

            .. seealso::
                :meth:`add_handler`, :meth:`add_handlers`.
        error_handlers (dict[:term:`coroutine function`, :obj:`bool`]): A dictionary where the keys
            are error handlers and the values indicate whether they are to be run blocking.

            .. seealso::
                :meth:`add_error_handler`
        context_types (:class:`telegram.ext.ContextTypes`): Specifies the types used by this
            dispatcher for the ``context`` argument of handler and job callbacks.
        post_init (:term:`coroutine function`): Optional. A callback that will be executed by
            :meth:`Application.run_polling` and :meth:`Application.run_webhook` after initializing
            the application via :meth:`initialize`.
        post_shutdown (:term:`coroutine function`): Optional. A callback that will be executed by
            :meth:`Application.run_polling` and :meth:`Application.run_webhook` after shutting down
            the application via :meth:`shutdown`.
        post_stop (:term:`coroutine function`): Optional. A callback that will be executed by
            :meth:`Application.run_polling` and :meth:`Application.run_webhook` after stopping
            the application via :meth:`stop`.

            .. versionadded:: 20.1

    )Ú__create_task_tasksÚ__update_fetcher_taskÚ__update_persistence_eventÚ__update_persistence_lockÚ__update_persistence_taskÚ__stop_running_markerÚ
_chat_dataÚ&_chat_ids_to_be_deleted_in_persistenceÚ&_chat_ids_to_be_updated_in_persistenceÚ#_conversation_handler_conversationsÚ_initializedÚ
_job_queueÚ_runningÚ_update_processorÚ
_user_dataÚ&_user_ids_to_be_deleted_in_persistenceÚ&_user_ids_to_be_updated_in_persistenceÚbotÚbot_dataÚ	chat_dataÚcontext_typesÚerror_handlersÚhandlersÚpersistenceÚ	post_initÚpost_shutdownÚ	post_stopÚupdate_queueÚupdaterÚ	user_data)r@   é   )Ú__weakref__© rL   z$Application[BT, CCT, UD, CD, BD, JQ]ri   rs   zasyncio.Queue[object]rt   NÚ	job_queueÚupdate_processorr9   ro   rl   rp   rq   rr   c       
         óB  — t        t        j                  «       t        t        «      j
                  j                  «       dz  «      st        dd¬«       || _        || _	        || _
        || _        i | _        i | _        || _        |	| _        |
| _        || _        | j                  j%                  «       | _        t'        | j                  j(                  «      | _        t'        | j                  j,                  «      | _        t1        | j*                  «      | _        t1        | j.                  «      | _        d | _        |rt5        |t6        «      st9        d«      ‚|| _        t;        «       | _        t;        «       | _        t;        «       | _         t;        «       | _!        i | _"        d| _#        d| _$        || _%        d | _&        d | _'        tQ        jR                  «       | _*        tQ        jV                  «       | _,        t;        «       | _-        tQ        jR                  «       | _.        y )Nz_applicationbuilder.pyzE`Application` instances should be built via the `ApplicationBuilder`.é   ©Ú
stacklevelz9persistence must be based on telegram.ext.BasePersistenceF)/r(   ÚinspectÚcurrentframer   Ú__file__ÚparentÚresolver    ri   rs   rl   rt   rn   rm   rp   rq   rr   re   rj   r   ru   rf   rk   r^   r   ro   Ú
isinstancer"   Ú	TypeErrorÚsetr`   rh   r_   rg   ra   rb   rd   rc   Ú!_Application__update_fetcher_taskÚ%_Application__update_persistence_taskÚasyncioÚEventÚ&_Application__update_persistence_eventÚLockÚ%_Application__update_persistence_lockÚ_Application__create_task_tasksÚ!_Application__stop_running_marker)rL   ri   rs   rt   ry   rz   ro   rl   rp   rq   rr   s              rN   rK   zApplication.__init__  sÉ  € ô( Ü× Ñ Ó"¤D¬£N×$9Ñ$9×$AÑ$AÓ$CÐF^Ñ$^ô
ô ØWØõð
 ˆŒØ3?ˆÔØ<IˆÔØ'.ˆŒØEGˆŒð ð 	Ôð
 ð 	Œð
 ð 	Ôð
 ð 	Œð "2ˆÔØ ×.Ñ.×7Ñ7Ó9ˆŒÜ0;¸D×<NÑ<N×<XÑ<XÓ0YˆŒÜ0;¸D×<NÑ<N×<XÑ<XÓ0YˆŒä+;¸D¿O¹OÓ+LˆŒÜ+;¸D¿O¹OÓ+LˆŒà?CˆÔÙœz¨+´ÔGÜÐWÓXÐXØ&ˆÔô ADÃˆÔ3Ü@CÃˆÔ3Ü@CÃˆÔ3Ü@CÃˆÔ3ð ð 	Ô0ð
 "ˆÔØˆŒØ'ˆŒØ:>ˆÔ"Ø>BˆÔ&Ü*1¯-©-«/ˆÔ'Ü)0¯©«ˆÔ&Ü69³eˆÔ Ü%,§]¡]£_ˆÕ"rO   rG   c              ƒ   ó’   K  — 	 | j                  «       ƒ d{  –—†  | S 7 Œ# t        $ r | j                  «       ƒ d{  –—†7   ‚ w xY w­w)a  |async_context_manager| :meth:`initializes <initialize>` the App.

        Returns:
            The initialized App instance.

        Raises:
            :exc:`Exception`: If an exception is raised during initialization, :meth:`shutdown`
                is called in this case.
        N)Ú
initializeÚ	ExceptionÚshutdown©rL   s    rN   Ú
__aenter__zApplication.__aenter__g  sG   è ø€ ð	Ø—/‘/Ó#×#Ð#ð ˆð	 $ùÜò 	Ø—-‘-“/×!Ñ!Øð	üs.   ‚A„  —˜  œAž   A¼?½AÁAÚexc_typeÚexc_valÚexc_tbc              ƒ   ó@   K  — | j                  «       ƒ d{  –—†  y7 Œ­w)z>|async_context_manager| :meth:`shuts down <shutdown>` the App.N)r“   )rL   r–   r—   r˜   s       rN   Ú	__aexit__zApplication.__aexit__x  s   è ø€ ð �m‰m‹o×Òús   ‚–—c                 ó0   — t        | | j                  ¬«      S )a"  Give a string representation of the application in the form ``Application[bot=...]``.

        As this class doesn't implement :meth:`object.__str__`, the default implementation
        will be used, which is equivalent to :meth:`__repr__`.

        Returns:
            :obj:`str`
        )ri   )r   ri   r”   s    rN   Ú__repr__zApplication.__repr__ƒ  s   € ô .¨d¸¿¹ÔAÐArO   c                 ó   — | j                   S )z}:obj:`bool`: Indicates if this application is running.

        .. seealso::
            :meth:`start`, :meth:`stop`
        )rd   r”   s    rN   ÚrunningzApplication.runningŽ  s   € ð �}‰}ÐrO   c                 ó.   — | j                   j                  S )aš  :obj:`int`: The number of concurrent updates that will be processed in parallel. A
        value of ``0`` indicates updates are *not* being processed concurrently.

        .. versionchanged:: 20.4
            This is now just a shortcut to :attr:`update_processor.max_concurrent_updates
            <telegram.ext.BaseUpdateProcessor.max_concurrent_updates>`.

        .. seealso:: :wiki:`Concurrency`
        )re   Úmax_concurrent_updatesr”   s    rN   Úconcurrent_updateszApplication.concurrent_updates—  s   € ð ×%Ñ%×<Ñ<Ð<rO   c                 óL   — | j                   €t        dd¬«       | j                   S )zÂ
        :class:`telegram.ext.JobQueue`: The :class:`JobQueue` used by the
            :class:`telegram.ext.Application`.

        .. seealso:: :wiki:`Job Queue <Extensions---JobQueue>`
        zqNo `JobQueue` set up. To use `JobQueue`, you must install PTB via `pip install "python-telegram-bot[job-queue]"`.r|   r}   )rc   r    r”   s    rN   ry   zApplication.job_queue¤  s+   € ð �?‰?Ð"ÜðBàõð
 �‰ÐrO   c                 ó   — | j                   S )z´:class:`telegram.ext.BaseUpdateProcessor`: The update processor used by this
        application.

        .. seealso:: :wiki:`Concurrency`

        .. versionadded:: 20.4
        )re   r”   s    rN   rz   zApplication.update_processor´  s   € ð ×%Ñ%Ð%rO   c                  ó   — t         ‚rI   )Ú
SystemExitrx   rO   rN   Ú_raise_system_exitzApplication._raise_system_exit¿  s   € äÐrO   c                  ó   — ddl m}   | «       S )ztConvenience method. Returns a new :class:`telegram.ext.ApplicationBuilder`.

        .. versionadded:: 20.0
        r   ©ÚApplicationBuilder)Útelegram.extr©   r¨   s    rN   ÚbuilderzApplication.builderÃ  s   € õ	
ñ "Ó#Ð#rO   c                 ó2   — | j                   st        d«      ‚y )NzBThis Application was not initialized via `Application.initialize`!)rb   ÚRuntimeErrorr”   s    rN   Ú_check_initializedzApplication._check_initializedÐ  s    € Ø× Ò ÜØTóð ð !rO   c              ƒ   óê  K  — | j                   rt        j                  d«       y| j                  j	                  «       ƒ d{  –—†  | j
                  j	                  «       ƒ d{  –—†  | j                  r"| j                  j	                  «       ƒ d{  –—†  | j                  sd| _         y| j                  «       ƒ d{  –—†  ddl	m
} t        j                  j                  | j                  j                  «       «      D ]B  }t!        ||«      sŒ|j"                  sŒ|j$                  sŒ*| j'                  |«      ƒ d{  –—†  ŒD d| _         | j(                  j+                  «        y7 �Œ%7 �Œ7 ŒÚ7 Œ°7 Œ2­w)a<  Initializes the Application by initializing:

        * The :attr:`bot`, by calling :meth:`telegram.Bot.initialize`.
        * The :attr:`updater`, by calling :meth:`telegram.ext.Updater.initialize`.
        * The :attr:`persistence`, by loading persistent conversations and data.
        * The :attr:`update_processor` by calling
          :meth:`telegram.ext.BaseUpdateProcessor.initialize`.

        Does *not* call :attr:`post_init` - that is only done by :meth:`run_polling` and
        :meth:`run_webhook`.

        .. seealso::
            :meth:`shutdown`
        z(This Application is already initialized.NTr   ©r6   )rb   Ú_LOGGERÚdebugri   r‘   re   rt   ro   Ú_initialize_persistenceÚ*telegram.ext._handlers.conversationhandlerr6   Ú	itertoolsÚchainÚfrom_iterablern   Úvaluesr„   Ú
persistentÚnameÚ_add_ch_to_persistencer�   Úclear)rL   r6   Úhandlers      rN   r‘   zApplication.initializeÖ  s,  è ø€ ð ×ÒÜ�M‰MÐDÔEØà�h‰h×!Ñ!Ó#×#Ð#Ø×$Ñ$×/Ñ/Ó1×1Ð1à�<Š<Ø—,‘,×)Ñ)Ó+×+Ð+à×ÒØ $ˆDÔØà×*Ñ*Ó,×,Ð,õ 	Sô !—‘×4Ñ4°T·]±]×5IÑ5IÓ5KÓLò 	;ˆGÜ˜'Ð#6Õ7¸G×<NÓ<NÐSZ×S_ÓS_Ø×1Ñ1°'Ó:×:Ñ:ð	;ð !ˆÔØ×"Ñ"×(Ñ(Õ*ð- 	$ùØ1ùð ,øð 	-øð ;úsm   ‚A E3ÁE'Á!E3Á$E*Á%-E3ÂE-Â+E3Â>E/Â?AE3ÄE3ÄE3Ä*E3Ä>E1Ä?)E3Å*E3Å-E3Å/E3Å1E3r½   c              ƒ   ót   K  — | j                   j                  |j                  | «      ƒ d {  –—† «       y 7 Œ	­wrI   )ra   Úupdater³   )rL   r½   s     rN   r»   z"Application._add_ch_to_persistence  s.   è ø€ Ø×0Ñ0×7Ñ7Ø×1Ñ1°$Ó7×7õ	
Ø7ús   ‚*8¬6­
8c              ƒ   ód  K  — | j                   rt        d«      ‚| j                  st        j	                  d«       y| j
                  j                  «       ƒ d{  –—†  | j                  j                  «       ƒ d{  –—†  | j                  r"| j                  j                  «       ƒ d{  –—†  | j                  rdt        j	                  d«       | j                  «       ƒ d{  –—†  | j                  j                  «       ƒ d{  –—†  t        j	                  d«       d| _        y7 ŒÌ7 Œ¬7 Œ€7 ŒI7 Œ)­w)aŸ  Shuts down the Application by shutting down:

        * :attr:`bot` by calling :meth:`telegram.Bot.shutdown`
        * :attr:`updater` by calling :meth:`telegram.ext.Updater.shutdown`
        * :attr:`persistence` by calling :meth:`update_persistence` and
          :meth:`BasePersistence.flush`
        * :attr:`update_processor` by calling :meth:`telegram.ext.BaseUpdateProcessor.shutdown`

        Does *not* call :attr:`post_shutdown` - that is only done by :meth:`run_polling` and
        :meth:`run_webhook`.

        .. seealso::
            :meth:`initialize`

        Raises:
            :exc:`RuntimeError`: If the application is still :attr:`running`.
        z"This Application is still running!z1This Application is already shut down. Returning.Nz/Updating & flushing persistence before shutdownzUpdated and flushed persistenceF)rž   r­   rb   r±   r²   ri   r“   re   rt   ro   Úupdate_persistenceÚflushr”   s    rN   r“   zApplication.shutdown  sí   è ø€ ð$ �<Š<ÜÐCÓDÐDà× Ò Ü�M‰MÐMÔNØà�h‰h×ÑÓ!×!Ð!Ø×$Ñ$×-Ñ-Ó/×/Ð/à�<Š<Ø—,‘,×'Ñ'Ó)×)Ð)à×ÒÜ�M‰MÐKÔLØ×)Ñ)Ó+×+Ð+Ø×"Ñ"×(Ñ(Ó*×*Ð*Ü�M‰MÐ;Ô<à!ˆÕð 	"øØ/øð *øð ,øØ*úsZ   ‚AD0ÁD&Á!D0Á;D(Á<-D0Â)D*Â*8D0Ã"D,Ã#!D0ÄD.Ä"D0Ä(D0Ä*D0Ä,D0Ä.D0c              ƒ   ó8  K  — | j                   sy| j                   j                  j                  r;| j                  j	                  | j                   j                  «       ƒ d{  –—† «       | j                   j                  j                  r;| j                  j	                  | j                   j                  «       ƒ d{  –—† «       | j                   j                  j                  r}| j                   j                  «       ƒ d{  –—† | _	        t        | j                  | j                  j                  «      s,t        d| j                  j                  j                  › �«      ‚| j                   j                  j                  r‹| j                   j"                  �t| j                   j%                  «       ƒ d{  –—† }|�Ot        |t&        «      rt)        |«      dk7  rt        d«      ‚| j                   j"                  j+                  |«       yyyy7 �Œ­7 �ŒU7 �Œ7 Œa­w)zHThis method basically just loads all the data by awaiting the BP methodsNzbot_data must be of type r|   z)callback_data must be a tuple of length 2)ro   Ú
store_dataru   rf   r¿   Úget_user_datark   r^   Úget_chat_datarj   Úget_bot_datar„   rl   Ú
ValueErrorrP   Úcallback_datari   Úcallback_data_cacheÚget_callback_dataÚtupleÚlenÚload_persistence_data)rL   Úpersistent_datas     rN   r³   z#Application._initialize_persistence-  sœ  è ø€ à×ÒØà×Ñ×&Ñ&×0Ò0Ø�O‰O×"Ñ"¨×)9Ñ)9×)GÑ)GÓ)I×#IÔJØ×Ñ×&Ñ&×0Ò0Ø�O‰O×"Ñ"¨×)9Ñ)9×)GÑ)GÓ)I×#IÔJØ×Ñ×&Ñ&×/Ò/Ø"&×"2Ñ"2×"?Ñ"?Ó"A×AˆDŒMÜ˜dŸm™m¨T×-?Ñ-?×-HÑ-HÔIÜ Ø/°×0BÑ0B×0KÑ0K×0TÑ0TÐ/UÐVóð ð ×Ñ×&Ñ&×4Ò4Ø�H‰H×(Ñ(Ð4à$(×$4Ñ$4×$FÑ$FÓ$H×HˆOØÐ*Ü! /´5Ô9¼SÀÓ=QÐUVÒ=VÜ$Ð%PÓQÐQØ—‘×,Ñ,×BÑBØ#õð +ð 5ð 5ð $Jùà#IùàAùð IúsL   ‚A HÁ"HÁ#AHÂ=HÂ>AHÄHÄB2HÆ6HÆ7AHÈHÈHÈHc              ƒ   óÆ  K  — | j                   rt        d«      ‚| j                  «        d| _        | j                  j                  «        	 | j                  rWt        j                  | j                  «       d| j                  j                  › d�¬«      | _        t        j                  d«       | j                  r7| j                  j!                  «       ƒ d{  –—†  t        j                  d«       t        j                  | j#                  «       d| j                  j                  › d	�¬«      | _        t        j'                  d
«       y7 Œq# t(        $ r	 d| _        ‚ w xY w­w)aé  Starts

        * a background task that fetches updates from :attr:`update_queue` and processes them via
          :meth:`process_update`.
        * :attr:`job_queue`, if set.
        * a background task that calls :meth:`update_persistence` in regular intervals, if
          :attr:`persistence` is set.

        Note:
            This does *not* start fetching updates from Telegram. To fetch updates, you need to
            either start :attr:`updater` manually or use one of :meth:`run_polling` or
            :meth:`run_webhook`.

        Tip:
            When using a custom logic for startup and shutdown of the application, eventual
            cancellation of pending tasks should happen only `after` :meth:`stop` has been called
            in order to ensure that the tasks mentioned above are not cancelled prematurely.

        .. seealso::
            :meth:`stop`

        Raises:
            :exc:`RuntimeError`: If the application is already running or was not initialized.
        z$This Application is already running!TúApplication:z:persistence_updater©rº   z%Loop for updating persistence startedNzJobQueue startedz:update_fetcherzApplication startedF)rž   r­   r®   rd   r‹   r¼   ro   r‰   Úcreate_taskÚ_persistence_updaterri   Úidrˆ   r±   r²   rc   ÚstartÚ_update_fetcherr‡   Úinfor’   r”   s    rN   rÖ   zApplication.startJ  s  è ø€ ð2 �<Š<ÜÐEÓFÐFØ×ÑÔ!àˆŒØ×'Ñ'×-Ñ-Ô/ð	Ø×ÒÜ18×1DÑ1DØ×-Ñ-Ó/Ø'¨¯©¯© }Ð4HÐIô2�Ô.ô —‘ÐEÔFà�ŠØ—o‘o×+Ñ+Ó-×-Ð-Ü—‘Ð0Ô1ä)0×)<Ñ)<Ø×$Ñ$Ó&¨|¸D¿H¹H¿K¹K¸=ÈÐ-Xô*ˆDÔ&ô �L‰LÐ.Õ/ð .ùô ò 	Ø!ˆDŒMØð	üs2   ‚A	E!ÁBE ÃE
ÃA0E Å	E!Å
E ÅEÅE!c              ƒ   óö  K  — | j                   st        d«      ‚d| _        | j                  j	                  «        t
        j                  d«       | j                  r¨| j                  j                  «       r	 | j                  j                  «        nr| j                  j                  t        «      ƒ d{  –—†  t
        j                  d«       | j                  j!                  «       ƒ d{  –—†  | j                  ƒ d{  –—†  t
        j                  d	«       | j"                  rNt
        j                  d
«       | j"                  j%                  d¬«      ƒ d{  –—†  t
        j                  d«       t
        j                  d«       t'        j(                  | j*                  ddiŽƒ d{  –—†  | j,                  ri| j.                  r]t
        j                  d«       | j0                  j3                  «        | j.                  ƒ d{  –—†  | j0                  j	                  «        t
        j                  d«       y# t        $ r#}t
        j                  d|d¬«       Y d}~�Œ]d}~ww xY w7 �Œµ7 �Œ�7 �Œp7 �Œ7 ŒÊ7 Œq­w)aŽ  Stops the process after processing any pending updates or tasks created by
        :meth:`create_task`. Also stops :attr:`job_queue`, if set.
        Finally, calls :meth:`update_persistence` and :meth:`BasePersistence.flush` on
        :attr:`persistence`, if set.

        Warning:
            Once this method is called, no more updates will be fetched from :attr:`update_queue`,
            even if it's not empty.

        .. seealso::
            :meth:`start`

        Note:
            * This does *not* stop :attr:`updater`. You need to either manually call
              :meth:`telegram.ext.Updater.stop` or use one of :meth:`run_polling` or
              :meth:`run_webhook`.
            * Does *not* call :attr:`post_stop` - that is only done by
              :meth:`run_polling` and :meth:`run_webhook`.

        Raises:
            :exc:`RuntimeError`: If the application is not running.
        z This Application is not running!Fz2Application is stopping. This might take a moment.zZFetching updates was aborted due to %r. Suppressing exception to ensure graceful shutdown.T©Úexc_infoNz Waiting for update_queue to joinz(Application stopped fetching of updates.z"Waiting for running jobs to finish)ÚwaitzJobQueue stoppedz/Waiting for `create_task` calls to be processedÚreturn_exceptionsz&Waiting for persistence loop to finishzApplication.stop() complete)rž   r­   rd   r�   r¼   r±   rØ   r‡   ÚdoneÚresultÚBaseExceptionÚcriticalrs   ÚputÚ_STOP_SIGNALr²   Újoinrc   Ústopr‰   ÚgatherrŽ   ro   rˆ   r‹   r†   )rL   Úexcs     rN   rå   zApplication.stop  sî  è ø€ ð. �|Š|ÜÐAÓBÐBàˆŒØ×"Ñ"×(Ñ(Ô*Ü�‰ÐIÔJð ×%Ò%Ø×)Ñ)×.Ñ.Ô0ðØ×.Ñ.×5Ñ5Õ7ð ×'Ñ'×+Ñ+¬LÓ9×9Ð9Ü—‘Ð@ÔAØ×'Ñ'×,Ñ,Ó.×.Ð.Ø×0Ñ0×0Ð0Ü�‰Ð@ÔAà�?Š?Ü�M‰MÐ>Ô?Ø—/‘/×&Ñ&¨DÐ&Ó1×1Ð1Ü�M‰MÐ,Ô-ä�‰ÐGÔHÜ�n‰n˜d×6Ñ6ÐOÈ$ÑO×OÐOð ×Ò × >Ò >Ü�M‰MÐBÔCØ×+Ñ+×/Ñ/Ô1Ø×0Ñ0×0Ð0Ø×+Ñ+×1Ñ1Ô3ä�‰Ð2Õ3øô; %ò Ü×$Ñ$ðAàØ!%ð	 %÷ ò ûðúð :ùà.ùØ0ùð
 2ùð 	Pøð 1ús™   ‚A4I9Á7H: Â#I9Â4I)Â56I9Ã+I,Ã,I9Ã?I/Ä AI9ÅI2ÅAI9Æ*I5Æ+AI9ÈI7È4I9È:	I&ÉI!ÉI9É!I&É&I9É,I9É/I9É2I9É5I9É7I9c                 óÚ   — | j                   r#t        j                  «       j                  «        y| j                  j                  «        | j                  st        j                  d«       yy)a|  This method can be used to stop the execution of :meth:`run_polling` or
        :meth:`run_webhook` from within a handler, job or error callback. This allows a graceful
        shutdown of the application, i.e. the methods listed in :attr:`run_polling` and
        :attr:`run_webhook` will still be executed.

        This method can also be called within :meth:`post_init`. This allows for a graceful,
        early shutdown of the application if some condition is met (e.g., a database connection
        could not be established).

        Note:
            If the application is not running and this method is not called within
            :meth:`post_init`, this method does nothing.

        Warning:
            This method is designed to for use in combination with :meth:`run_polling` or
            :meth:`run_webhook`. Using this method in combination with a custom logic for starting
            and stopping the application is not guaranteed to work as expected. Use at your own
            risk.

        .. versionadded:: 20.5

        .. versionchanged:: 21.2
            Added support for calling within :meth:`post_init`.
        zVApplication is not running and not initialized. `stop_running()` likely has no effect.N)	rž   r‰   Úget_running_looprå   r�   r†   rb   r±   r²   r”   s    rN   Ústop_runningzApplication.stop_runningÁ  sS   € ð2 �<Š<ô ×$Ñ$Ó&×+Ñ+Õ-à×&Ñ&×*Ñ*Ô,Ø×$Ò$Ü—‘ð!õð %rO   g        é
   )Úsecondsr   TÚpoll_intervalÚtimeoutÚbootstrap_retriesÚallowed_updatesÚdrop_pending_updatesÚ
close_loopÚstop_signalsc           
      ó¶   ‡ — ‰ j                   st        d«      ‚dt        ddfˆ fd„}‰ j                  ‰ j                   j	                  ||||||¬«      |||¬«      S )a5  Convenience method that takes care of initializing and starting the app,
        polling updates from Telegram using :meth:`telegram.ext.Updater.start_polling` and
        a graceful shutdown of the app on exit.

        |app_run_shutdown| :paramref:`stop_signals`.

        The order of execution by :meth:`run_polling` is roughly as follows:

        - :meth:`initialize`
        - :meth:`post_init`
        - :meth:`telegram.ext.Updater.start_polling`
        - :meth:`start`
        - Run the application until the users stops it
        - :meth:`telegram.ext.Updater.stop`
        - :meth:`stop`
        - :meth:`post_stop`
        - :meth:`shutdown`
        - :meth:`post_shutdown`

        A small wrapper is passed to :paramref:`telegram.ext.Updater.start_polling.error_callback`
        which forwards errors occurring during polling to
        :meth:`registered error handlers <add_error_handler>`. The update parameter of the callback
        will be set to :obj:`None`.

        .. include:: inclusions/application_run_tip.rst

        .. versionchanged::
            Removed the deprecated parameters ``read_timeout``, ``write_timeout``,
            ``connect_timeout``, and ``pool_timeout``. Use the corresponding methods in
            :class:`telegram.ext.ApplicationBuilder` instead.

        Args:
            poll_interval (:obj:`float`, optional): Time to wait between polling updates from
                Telegram in seconds. Default is ``0.0``.
            timeout (:obj:`int` | :class:`datetime.timedelta`, optional): Passed to
                :paramref:`telegram.Bot.get_updates.timeout`.
                Default is :obj:`timedelta(seconds=10)<datetime.timedelta>`.

                .. versionchanged:: v22.2
                    |time-period-input|
            bootstrap_retries (:obj:`int`, optional): Whether the bootstrapping phase
                (calling :meth:`initialize` and the boostrapping of
                :meth:`telegram.ext.Updater.start_polling`)
                will retry on failures on the Telegram server.

                * < 0 - retry indefinitely
                *   0 - no retries (default)
                * > 0 - retry up to X times

                .. versionchanged:: 21.11
                    The default value will be changed to from ``-1`` to ``0``. Indefinite retries
                    during bootstrapping are not recommended.

            drop_pending_updates (:obj:`bool`, optional): Whether to clean any pending updates on
                Telegram servers before actually starting to poll. Default is :obj:`False`.
            allowed_updates (Sequence[:obj:`str`], optional): Passed to
                :meth:`telegram.Bot.get_updates`.

                .. versionchanged:: 21.9
                    Accepts any :class:`collections.abc.Sequence` as input instead of just a list
            close_loop (:obj:`bool`, optional): If :obj:`True`, the current event loop will be
                closed upon shutdown. Defaults to :obj:`True`.

                .. seealso::
                    :meth:`asyncio.loop.close`
            stop_signals (Sequence[:obj:`int`] | :obj:`None`, optional): Signals that will shut
                down the app. Pass :obj:`None` to not use stop signals.
                Defaults to :data:`signal.SIGINT`, :data:`signal.SIGTERM` and
                :data:`signal.SIGABRT` on non Windows platforms.

                Caution:
                    Not every :class:`asyncio.AbstractEventLoop` implements
                    :meth:`asyncio.loop.add_signal_handler`. Most notably, the standard event loop
                    on Windows, :class:`asyncio.ProactorEventLoop`, does not implement this method.
                    If this method is not available, stop signals can not be set.

        Raises:
            :exc:`RuntimeError`: If the Application does not have an :class:`telegram.ext.Updater`.
        zLApplication.run_polling is only available if the application has an Updater.rç   rG   Nc                 óJ   •— ‰j                  ‰j                  | d ¬«      «       y ©N)Úerrorr¿   )rÓ   Úprocess_error)rç   rL   s    €rN   Úerror_callbackz/Application.run_polling.<locals>.error_callbackD  s!   ø€ Ø×Ñ˜T×/Ñ/°cÀ$Ð/ÓGÕHrO   )rí   rî   rï   rð   rñ   rù   ©Úupdater_coroutineró   rï   rò   )rt   r­   r!   Ú_Application__runÚstart_polling)	rL   rí   rî   rï   rð   rñ   rò   ró   rù   s	   `        rN   Úrun_pollingzApplication.run_pollingæ  s   ø€ ðr �|Š|ÜØ^óð ð	I¤ð 	I°$õ 	Ið �z‰zØ"Ÿl™l×8Ñ8Ø+ØØ"3Ø /Ø%9Ø-ð 9ó ð &Ø/Ø!ð ó 
ð 	
rO   Ú é(   ÚlistenÚportÚurl_pathÚcertÚkeyÚwebhook_urlÚ
ip_addressÚmax_connectionsÚsecret_tokenÚunixzstr | Path | socket | Nonec                 ó¦   — | j                   st        d«      ‚| j                  | j                   j                  |||||||	|||
|||¬«      |||¬«      S )aM  Convenience method that takes care of initializing and starting the app,
        listening for updates from Telegram using :meth:`telegram.ext.Updater.start_webhook` and
        a graceful shutdown of the app on exit.

        |app_run_shutdown| :paramref:`stop_signals`.

        If :paramref:`cert`
        and :paramref:`key` are not provided, the webhook will be started directly on
        ``http://listen:port/url_path``, so SSL can be handled by another
        application. Else, the webhook will be started on
        ``https://listen:port/url_path``. Also calls :meth:`telegram.Bot.set_webhook` as
        required.

        The order of execution by :meth:`run_webhook` is roughly as follows:

        - :meth:`initialize`
        - :meth:`post_init`
        - :meth:`telegram.ext.Updater.start_webhook`
        - :meth:`start`
        - Run the application until the users stops it
        - :meth:`telegram.ext.Updater.stop`
        - :meth:`stop`
        - :meth:`post_stop`
        - :meth:`shutdown`
        - :meth:`post_shutdown`

        Important:
            If you want to use this method, you must install PTB with the optional requirement
            ``webhooks``, i.e.

            .. code-block:: bash

               pip install "python-telegram-bot[webhooks]"

        .. include:: inclusions/application_run_tip.rst

        .. seealso::
            :wiki:`Webhooks`

        Args:
            listen (:obj:`str`, optional): IP-Address to listen on. Defaults to
                `127.0.0.1 <https://en.wikipedia.org/wiki/Localhost>`_.
            port (:obj:`int`, optional): Port the bot should be listening on. Must be one of
                :attr:`telegram.constants.SUPPORTED_WEBHOOK_PORTS` unless the bot is running
                behind a proxy. Defaults to ``80``.
            url_path (:obj:`str`, optional): Path inside url. Defaults to `` '' ``
            cert (:class:`pathlib.Path` | :obj:`str`, optional): Path to the SSL certificate file.
            key (:class:`pathlib.Path` | :obj:`str`, optional): Path to the SSL key file.
            bootstrap_retries (:obj:`int`, optional): Whether the bootstrapping phase
                (calling :meth:`initialize` and the boostrapping of
                :meth:`telegram.ext.Updater.start_polling`)
                will retry on failures on the Telegram server.

                * < 0 - retry indefinitely
                *   0 - no retries (default)
                * > 0 - retry up to X times
            webhook_url (:obj:`str`, optional): Explicitly specify the webhook url. Useful behind
                NAT, reverse proxy, etc. Default is derived from :paramref:`listen`,
                :paramref:`port`, :paramref:`url_path`, :paramref:`cert`, and :paramref:`key`.
            allowed_updates (Sequence[:obj:`str`], optional): Passed to
                :meth:`telegram.Bot.set_webhook`.

                .. versionchanged:: 21.9
                    Accepts any :class:`collections.abc.Sequence` as input instead of just a list
            drop_pending_updates (:obj:`bool`, optional): Whether to clean any pending updates on
                Telegram servers before actually starting to poll. Default is :obj:`False`.
            ip_address (:obj:`str`, optional): Passed to :meth:`telegram.Bot.set_webhook`.
            max_connections (:obj:`int`, optional): Passed to
                :meth:`telegram.Bot.set_webhook`. Defaults to ``40``.
            close_loop (:obj:`bool`, optional): If :obj:`True`, the current event loop will be
                closed upon shutdown. Defaults to :obj:`True`.

                .. seealso::
                    :meth:`asyncio.loop.close`
            stop_signals (Sequence[:obj:`int`] | :obj:`None`, optional): Signals that will shut
                down the app. Pass :obj:`None` to not use stop signals.
                Defaults to :data:`signal.SIGINT`, :data:`signal.SIGTERM` and
                :data:`signal.SIGABRT`.

                Caution:
                    Not every :class:`asyncio.AbstractEventLoop` implements
                    :meth:`asyncio.loop.add_signal_handler`. Most notably, the standard event loop
                    on Windows, :class:`asyncio.ProactorEventLoop`, does not implement this method.
                    If this method is not available, stop signals can not be set.
            secret_token (:obj:`str`, optional): Secret token to ensure webhook requests originate
                from Telegram. See :paramref:`telegram.Bot.set_webhook.secret_token` for more
                details.

                When added, the web server started by this call will expect the token to be set in
                the ``X-Telegram-Bot-Api-Secret-Token`` header of an incoming request and will
                raise a :class:`http.HTTPStatus.FORBIDDEN <http.HTTPStatus>` error if either the
                header isn't set or it is set to a wrong token.

                .. versionadded:: 20.0
            unix (:class:`pathlib.Path` | :obj:`str` | :class:`socket.socket`, optional): Can be
                either:

                * the path to the unix socket file as :class:`pathlib.Path` or :obj:`str`. This
                  will be passed to `tornado.netutil.bind_unix_socket <https://www.tornadoweb.org/
                  en/stable/netutil.html#tornado.netutil.bind_unix_socket>`_ to create the socket.
                  If the Path does not exist, the file will be created.

                * or the socket itself. This option allows you to e.g. restrict the permissions of
                  the socket for improved security. Note that you need to pass the correct family,
                  type and socket options yourself.

                Caution:
                    This parameter is a replacement for the default TCP bind. Therefore, it is
                    mutually exclusive with :paramref:`listen` and :paramref:`port`. When using
                    this param, you must also run a reverse proxy to the unix socket and set the
                    appropriate :paramref:`webhook_url`.

                .. versionadded:: 20.8
                .. versionchanged:: 21.1
                    Added support to pass a socket instance itself.
        zLApplication.run_webhook is only available if the application has an Updater.)r  r  r  r  r  rï   rñ   r  rð   r  r  r	  r
  rú   )rt   r­   rü   Ústart_webhook)rL   r  r  r  r  r  rï   r  rð   rñ   r  r  rò   ró   r	  r
  s                   rN   Úrun_webhookzApplication.run_webhookU  s}   € ðL �|Š|ÜØ^óð ð �z‰zØ"Ÿl™l×8Ñ8ØØØ!ØØØ"3Ø%9Ø'Ø /Ø%Ø /Ø)Øð 9ó ð &Ø/Ø!ð% ó 
ð 	
rO   Úmax_retriesc              ƒ   óR   K  — t        | j                  d|d¬«      ƒ d {  –—†  y 7 Œ­w)Nz Bootstrap Initialize Applicationé   )Ú	action_cbÚdescriptionr  Úinterval)r'   r‘   )rL   r  s     rN   Ú_bootstrap_initializez!Application._bootstrap_initializeõ  s(   è ø€ Ü Ø—o‘oØ:Ø#Øô	
÷ 	
ò 	
ús   ‚'Ÿ% 'rû   c                 ó�
  — 	 t        j                  «       }|t
        u rFt        j                  «       dk7  r/t        j                  t        j                  t        j                  f}	 t        |t        «      s'|xs g D ]  }|j                  || j                  «       Œ  	 |j%                  | j'                  |¬«      «       | j(                  r |j%                  | j)                  | «      «       | j*                  j-                  «       �rt.        j1                  d«       	 |j3                  «        	 | j4                  j6                  r)|j%                  | j4                  j9                  «       «       | j6                  rK|j%                  | j9                  «       «       | j:                  r |j%                  | j;                  | «      «       |j%                  | j=                  «       «       | j>                  r |j%                  | j?                  | «      «       |r|j3                  «        y y |j%                  |«       |j%                  | jA                  «       «       |jC                  «        |j3                  «        	 | j4                  j6                  r)|j%                  | j4                  j9                  «       «       | j6                  rK|j%                  | j9                  «       «       | j:                  r |j%                  | j;                  | «      «       |j%                  | j=                  «       «       | j>                  r |j%                  | j?                  | «      «       |r|j3                  «        y y # t        $ r- t        j                  «       }t        j                  |«       Y �Œ†w xY w# t         $ r}t#        d|› d|›d�d¬«       Y d }~�Œ'd }~ww xY w# |r|j3                  «        w w xY w# tD        tF        f$ r t.        jI                  d	«       Y �Œ©w xY w# |r|j3                  «        w w xY w# |j3                  «        	 | j4                  j6                  r)|j%                  | j4                  j9                  «       «       | j6                  rK|j%                  | j9                  «       «       | j:                  r |j%                  | j;                  | «      «       |j%                  | j=                  «       «       | j>                  r |j%                  | j?                  | «      «       |r|j3                  «        w w # |r|j3                  «        w w xY wxY w)
NÚWindowsz3Could not add signal handlers for the stop signals z due to exception `z_`. If your event loop does not implement `add_signal_handler`, please pass `stop_signals=None`.r@   r}   )r  zCApplication received stop signal via `stop_running`. Shutting down.z0Application received stop signal. Shutting down.)%r‰   Úget_event_loopr­   Únew_event_loopÚset_event_loopr   ÚplatformÚsystemÚsignalÚSIGINTÚSIGTERMÚSIGABRTr„   r   Úadd_signal_handlerr¦   ÚNotImplementedErrorr    Úrun_until_completer  rp   r�   Úis_setr±   rØ   Úclosert   rž   rå   rr   r“   rq   rÖ   Úrun_foreverÚKeyboardInterruptr¥   r²   )rL   rû   ró   rï   rò   ÚloopÚsigrç   s           rN   Ú__runzApplication.__runý  s  € ð	)Ü×)Ñ)Ó+ˆDð œ<Ñ'¬H¯O©OÓ,=ÀÒ,JÜ"ŸM™M¬6¯>©>¼6¿>¹>ÐJˆLð
	Ü˜l¬LÔ9Ø'Ò-¨2ò J�CØ×+Ñ+¨C°×1HÑ1HÕIðJð	!Ø×#Ñ# D×$>Ñ$>ÐK\Ð$>Ó$]Ô^Ø�~Š~Ø×'Ñ'¨¯©°tÓ(<Ô=Ø×)Ñ)×0Ñ0Õ2Ü—‘ÐbÔcØð ×#Ñ#Ô%ð!à—<‘<×'Ò'Ø×+Ñ+¨D¯L©L×,=Ñ,=Ó,?Ô@Ø—<’<Ø×+Ñ+¨D¯I©I«KÔ8à—~’~Ø×/Ñ/°·±¸tÓ0DÔEØ×'Ñ'¨¯©«Ô8Ø×%Ò%Ø×+Ñ+¨D×,>Ñ,>¸tÓ,DÔEáØ—J‘J•Lð ð/ ×#Ñ#Ð$5Ô6Ø×#Ñ# D§J¡J£LÔ1Ø×ÑÔð ×#Ñ#Ô%ð!à—<‘<×'Ò'Ø×+Ñ+¨D¯L©L×,=Ñ,=Ó,?Ô@Ø—<’<Ø×+Ñ+¨D¯I©I«KÔ8à—~’~Ø×/Ñ/°·±¸tÓ0DÔEØ×'Ñ'¨¯©«Ô8Ø×%Ò%Ø×+Ñ+¨D×,>Ñ,>¸tÓ,DÔEáØ—J‘J•Lð øôe ò 	)ä×)Ñ)Ó+ˆDÜ×"Ñ" 4×(ð	)ûô #ò 	ÜØEÀlÀ^ð TØ!˜Wð %4ð4ð ÷	ó ûð	ûñL Ø—J‘J•Lð ûô) "¤:Ð.ò 	NÜ�M‰MÐL×Mð	Nûñ( Ø—J‘J•Lð ûð ×#Ñ#Ô%ð!à—<‘<×'Ò'Ø×+Ñ+¨D¯L©L×,=Ñ,=Ó,?Ô@Ø—<’<Ø×+Ñ+¨D¯I©I«KÔ8à—~’~Ø×/Ñ/°·±¸tÓ0DÔEØ×'Ñ'¨¯©«Ô8Ø×%Ò%Ø×+Ñ+¨D×,>Ñ,>¸tÓ,DÔEáØ—J‘J•Lð ø‘:Ø—J‘J•Lð ýsˆ   ‚M' Á%7N  ÂA=O# Ä,C!O È!A O# É2C!P Í'2NÎNÎ 	OÎ)OÏOÏO Ï#$PÐP& Ð
PÐP& ÐP#Ð&UÐ8C!T-ÔUÔ-UÕUrÒ   Ú	coroutiner¿   rº   zasyncio.Task[RT]c                ó*   — | j                  |||¬«      S )a¨  Thin wrapper around :func:`asyncio.create_task` that handles exceptions raised by
        the :paramref:`coroutine` with :meth:`process_error`.

        Note:
            * If :paramref:`coroutine` raises an exception, it will be set on the task created by
              this method even though it's handled by :meth:`process_error`.
            * If the application is currently running, tasks created by this method will be
              awaited with :meth:`stop`.

        .. seealso:: :wiki:`Concurrency`

        Args:
            coroutine (:term:`awaitable`): The awaitable to run as task.

                .. versionchanged:: 20.2
                    Accepts :class:`asyncio.Future` and generator-based coroutine functions.
                .. deprecated:: 20.4
                    Since Python 3.12, generator-based coroutine functions are no longer accepted.
            update (:obj:`object`, optional): If set, will be passed to :meth:`process_error`
                as additional information for the error handlers. Moreover, the corresponding
                :attr:`chat_data` and :attr:`user_data` entries will be updated in the next run of
                :meth:`update_persistence` after the :paramref:`coroutine` is finished.

        Keyword Args:
            name (:obj:`str`, optional): The name of the task.

                .. versionadded:: 20.4

        Returns:
            :class:`asyncio.Task`: The created task.
        )r*  r¿   rº   )Ú_Application__create_task)rL   r*  r¿   rº   s       rN   rÓ   zApplication.create_task>  s   € ðL ×!Ñ!¨I¸fÈ4Ð!ÓPÐPrO   Úis_error_handlerc                 óú   — t        j                  | j                  |||¬«      |¬«      }| j                  r8| j                  j                  |«       |j                  | j                  «       |S t        dd¬«       |S )N)r*  r¿   r-  rÒ   zpTasks created via `Application.create_task` while the application is not running won't be automatically awaited!r@   r}   )	r‰   rÓ   Ú"_Application__create_task_callbackrž   rŽ   ÚaddÚadd_done_callbackÚ'_Application__create_task_done_callbackr    )rL   r*  r¿   r-  rº   Útasks         rN   Ú__create_taskzApplication.__create_taskf  s…   € ô ")×!4Ñ!4Ø×'Ñ'Ø#¨FÐEUð (ó ð ô	"
ˆð �<Š<Ø×$Ñ$×(Ñ(¨Ô.Ø×"Ñ" 4×#CÑ#CÔDð ˆô ð:àõð ˆrO   r3  c                 óè   — | j                   j                  |«       t        j                  t        j
                  t        j                  «      5  |j                  «        d d d «       y # 1 sw Y   y xY wrI   )rŽ   ÚdiscardÚ
contextlibÚsuppressr‰   ÚCancelledErrorÚInvalidStateErrorÚ	exception)rL   r3  s     rN   Ú__create_task_done_callbackz'Application.__create_task_done_callback„  sS   € Ø× Ñ ×(Ñ(¨Ô.ô × Ñ ¤×!7Ñ!7¼×9RÑ9RÓSñ 	Ø�N‰NÔ÷	÷ 	ñ 	ús   ÁA(Á(A1c              ƒ   ó  K  — 	 t         j                  dk  rTt        |t        «      rDt	        t        dd«      «       t        j                  |«      ƒ d {  –—† | j                  |¬«       S |ƒ d {  –—† | j                  |¬«       S 7 Œ27 Œ# t        $ r[}t        |t        «      rt	        dd¬«       ‚ |rt        j                  d|¬	«       ‚ | j                  |||¬
«      ƒ d {  –—†7   ‚ d }~ww xY w# | j                  |¬«       w xY w­w)Nr?   z20.4zZGenerator-based coroutines are deprecated in create_task and will not work in Python 3.12+©r¿   zKApplicationHandlerStop is not supported with handlers running non-blocking.r  r}   údAn error was raised and an uncaught error was raised while handling the error with an error_handler.rÚ   )r¿   r÷   r*  )ÚsysÚversion_infor„   r   r    r3   r‰   rÓ   Ú_mark_for_persistence_updater’   rE   r±   r;  rø   )rL   r*  r¿   r-  r;  s        rN   Ú__create_task_callbackz"Application.__create_task_callback‹  s  è ø€ ð&	=ä×Ñ 'Ò)¬j¸ÄIÔ.NÜÜ)Øð0óôô %×0Ñ0°Ó;×;ð8 ×-Ñ-°VÐ-Õ<ð3 #—?ð2 ×-Ñ-°VÐ-Õ<ð9 <øð #ùÜò 	Ü˜)Ô%;Ô<ÜØaØ õð( ñ "Ü×!Ñ!ð@à&ð "ô ð ð ×(Ñ(°¸iÐS\Ð(Ó]×]Ñ]ð ûð-	ûð0 ×-Ñ-°VÐ-Õ<üsr   ‚D	„AB ÁBÁB ÁD	Á+B Á0B	Á1B Á4D	ÂB Â	B Â	C/ÂAC*Ã#C&Ã$C*Ã*C/Ã/C2 Ã2DÄD	c              ƒ   ó¨  K  — 	 | j                   j                  «       ƒ d {  –—† }|t        u r| j                   j                  «        y t        j                  d|«       | j                  j                  dkD  r<| j                  | j                  |«      |d| j                  j                  › d�¬«       n| j                  |«      ƒ d {  –—†  ŒÊ7 Œ¬7 Œ­w)NzProcessing update %sr  rÑ   z:process_concurrent_update©r¿   rº   )rs   Úgetrã   Ú	task_doner±   r²   re   r    rÓ   Ú$_Application__process_update_wrapperri   rÕ   ©rL   r¿   s     rN   Ú__update_fetcherzApplication.__update_fetcher¹  s½   è ø€ àØ×,Ñ,×0Ñ0Ó2×2ˆFàœÑ%à×!Ñ!×+Ñ+Ô-Øä�M‰MÐ0°&Ô9à×%Ñ%×<Ñ<¸qÒ@à× Ñ Ø×1Ñ1°&Ó9Ø!Ø'¨¯©¯© }Ð4NÐOð !õ ð ×3Ñ3°FÓ;×;Ð;ð% Ø2øð" <ús"   ‚C¡C¢B&CÃCÃ	CÃCc              ƒ   óþ  K  — 	 | j                  «       ƒ d {  –—†  | j                  j                  «       s†t        j	                  d| j                  j                  «       «       t        j                  t        «      5  | j                  j                  «        d d d «       | j                  j                  «       sŒ…y y 7 Œ¥# 1 sw Y   Œ(xY w# | j                  j                  «       s“t        j	                  d| j                  j                  «       «       t        j                  t        «      5  | j                  j                  «        d d d «       n# 1 sw Y   nxY w| j                  j                  «       sŒ’w w xY w­w)NzDropping pending update: %s)
Ú_Application__update_fetcherrs   Úemptyr±   r²   Ú
get_nowaitr7  r8  rÈ   rG  r”   s    rN   r×   zApplication._update_fetcherÏ  s  è ø€ ð	2Ø×'Ñ'Ó)×)Ð)à×'Ñ'×-Ñ-Ô/Ü—‘Ð;¸T×=NÑ=N×=YÑ=YÓ=[Ô\Ü×(Ñ(¬Ó4ñ 2ð ×%Ñ%×/Ñ/Ô1÷2ð ×'Ñ'×-Ñ-×/ð *ø÷2ð 2ûð ×'Ñ'×-Ñ-Ô/Ü—‘Ð;¸T×=NÑ=N×=YÑ=YÓ=[Ô\Ü×(Ñ(¬Ó4ñ 2ð ×%Ñ%×/Ñ/Ô1÷2÷ 2ñ 2úð ×'Ñ'×-Ñ-×/üsi   ‚E=„C —B=˜C œA!E=Á=B?Â"E=Â;E=Â=C Â?CÃE=ÃA"E:Ä-EÅ	E:ÅEÅ!E:Å8E:Å:E=c              ƒ   óê   K  — 	 | j                   j                  || j                  |«      «      ƒ d {  –—†  | j                  j                  «        y 7 Œ# | j                  j                  «        w xY w­wrI   )re   Úprocess_updaters   rG  rI  s     rN   Ú__process_update_wrapperz$Application.__process_update_wrapperÚ  s^   è ø€ ð	*Ø×(Ñ(×7Ñ7¸À×@SÑ@SÐTZÓ@[Ó\×\Ð\à×Ñ×'Ñ'Õ)ð ]ùà×Ñ×'Ñ'Õ)üs+   ‚A3„.A ²A³A ·A3ÁA ÁA0Á0A3c           
   ƒ   óh  K  — | j                  «        d}d}| j                  j                  «       D �cg c]  }|j                  «       ‘Œ c}D �]#  }	 |D �]  }|j	                  |«      }|�|du rŒ|s?	 | j
                  j                  j                  || «      }|j                  «       ƒ d{  –—†  |j                  || ||«      }	|j                  rb|j                  t        u rt        | j                   t"        «      re| j                   j$                  rO| j                   j$                  j                  s/| j'                  |	|d| j                   j(                  › d|› �¬«       nd}|	ƒ d{  –—†   n �Œ& |r| j1                  |¬«       yyc c}w # t        $ r$}t        j                  d||¬«       Y d}~  yd}~ww xY w7 �Œ7 ŒX# t*        $ r t        j-                  d	«       Y  Œqt        $ rB}| j/                  ||¬
«      ƒ d{  –—†7  rt        j-                  d«       Y d}~ Œ°Y d}~�ŒÝd}~ww xY w­w)a|  Processes a single update and marks the update to be updated by the persistence later.
        Exceptions raised by handler callbacks will be processed by :meth:`process_error`.

        .. seealso:: :wiki:`Concurrency`

        .. versionchanged:: 20.0
            Persistence is now updated in an interval set by
            :attr:`telegram.ext.BasePersistence.update_interval`.

        Args:
            update (:class:`telegram.Update` | :obj:`object` |                 :class:`telegram.error.TelegramError`): The update to process.

        Raises:
            :exc:`RuntimeError`: If the application was not initialized.
        NFzQError while building CallbackContext for update %s. Update will not be processed.rÚ   rÑ   z:process_update_non_blocking:rE  Tz7Stopping further handlers due to ApplicationHandlerStop)r¿   r÷   z'Error handler stopped further handlers.r>  )r®   rn   r¸   ÚcopyÚcheck_updaterl   ÚcontextÚfrom_updater’   r±   rá   Úrefresh_dataÚhandle_updateÚblockr   r„   ri   r$   ÚdefaultsrÓ   rÕ   rE   r²   rø   rB  )
rL   r¿   rU  Úany_blockingÚvrn   r½   Úcheckrç   r*  s
             rN   rP  zApplication.process_updateà  s  è ø€ ð$ 	×ÑÔ!àˆØˆð ,0¯=©=×+?Ñ+?Ó+AÖB a˜Ÿ™�ÒBó 3	ˆHð2à'ó %�GØ#×0Ñ0°Ó8�EØ�}¨°©Ø á"ð#Ø&*×&8Ñ&8×&@Ñ&@×&LÑ&LÈVÐUYÓ&Z˜Gð &×2Ñ2Ó4×4Ð4Ø+2×+@Ñ+@ÀÈÈuÐV]Ó+^�Ià"Ÿ=š=ØŸ™¬Ñ5Ü& t§x¡x´Ô8Ø ŸH™H×-Ò-Ø $§¡× 1Ñ 1× 7Ò 7à×(Ñ(Ø%Ø#)à".¨t¯x©x¯{©{¨mÐ;XÐY`ÐXaÐ bð	 )õ ð (,˜Ø'Ÿ˜ÙðK%ùð3	ñj ð ×-Ñ-°VÐ-Õ<ð	 ùòk Cøô  )ò 	#Ü#×,Ñ,ð%Dð !'Ø),ð -ô ö #ûð	#úð 5ùð$ (ùô *ò Ü—‘ÐWÔXÚô ò Ø×+Ñ+°6ÀÐ+ÓE×EÑEÜ—M‘MÐ"KÔLÝõ Fûðüs¡   ‚1H2³F
Á
H2Á GÁ3&FÂGÂ,F?Â-B<GÅ)GÅ*GÅ1H2Æ	F<ÆF7Æ0GÆ5H2Æ7F<Æ<GÇGÇH/Ç"H2Ç%H/Ç-H*ÈHÈH*ÈH2È*H/È/H2Úgroupc                 ó®  — ddl m} t        |t        «      st	        dt        j
                  › �«      ‚t        |t        «      st	        d«      ‚t        ||«      r�|j                  r„|j                  rx| j                  st        d|j                  › d�«      ‚| j                  rG| j                  | j                  |«      d| j                  j                  › d�¬	«       t!        d
d¬«       || j"                  vr@g | j"                  |<   t%        t'        | j"                  j)                  «       «      «      | _        | j"                  |   j+                  |«       y)aî  Register a handler.

        TL;DR: Order and priority counts. 0 or 1 handlers per group will be used. End handling of
        update with :class:`telegram.ext.ApplicationHandlerStop`.

        A handler must be an instance of a subclass of :class:`telegram.ext.BaseHandler`. All
        handlers
        are organized in groups with a numeric value. The default group is 0. All groups will be
        evaluated for handling an update, but only 0 or 1 handler per group will be used. If
        :class:`telegram.ext.ApplicationHandlerStop` is raised from one of the handlers, no further
        handlers (regardless of the group) will be called.

        The priority/order of handlers is determined as follows:

        * Priority of the group (lower group number == higher priority)
        * The first handler in a group which can handle an update (see
          :attr:`telegram.ext.BaseHandler.check_update`) will be used. Other handlers from the
          group will not be used. The order in which handlers were added to the group defines the
          priority.

        Warning:
            Adding persistent :class:`telegram.ext.ConversationHandler` after the application has
            been initialized is discouraged. This is because the persisted conversation states need
            to be loaded into memory while the application is already processing updates, which
            might lead to race conditions and undesired behavior. In particular, current
            conversation states may be overridden by the loaded data.

        Hint:
            This method currently has no influence on calls to :meth:`process_update` that are
            already in progress.

            .. warning::
                This behavior should currently be considered an implementation detail and not as
                guaranteed behavior.

        Args:
            handler (:class:`telegram.ext.BaseHandler`): A BaseHandler instance.
            group (:obj:`int`, optional): The group identifier. Default is ``0``.

        r   r°   zhandler is not an instance of zgroup is not intzConversationHandler z8 can not be persistent if application has no persistencerÑ   z,:add_handler:conversation_handler_after_initrÒ   zµA persistent `ConversationHandler` was passed to `add_handler`, after `Application.initialize` was called. This is discouraged.See the docs of `Application.add_handler` for details.r|   r}   N)r´   r6   r„   r%   r…   rP   Úintr¹   rº   ro   rÈ   rb   rÓ   r»   ri   rÕ   r    rn   ÚdictÚsortedÚitemsÚappend)rL   r½   r^  r6   s       rN   Úadd_handlerzApplication.add_handler7  s0  € õV 	Sä˜'¤;Ô/ÜÐ<¼[×=QÑ=QÐ<RÐSÓTÐTÜ˜%¤Ô%ÜÐ.Ó/Ð/Ü�gÐ2Ô3¸×8JÒ8JÈwÏ|Ê|Ø×#Ò#Ü Ø*¨7¯<©<¨.ð 9Nð Nóð ð × Ò Ø× Ñ Ø×/Ñ/°Ó8Ø'¨¯©¯© }Ð4`Ðað !ô ô ðMð  !õ	ð ˜Ÿ™Ñ%Ø#%ˆD�M‰M˜%Ñ Ü ¤¨¯©×(;Ñ(;Ó(=Ó!>Ó?ˆDŒMà�‰�eÑ×#Ñ# GÕ,rO   rn   c                 óª  — t        |t        «      rt        |t        «      st        d«      ‚t        |t        «      rQ|j	                  «       D ]=  \  }}t        |t
        «      st        d|› d�«      ‚|D ]  }| j                  ||«       Œ Œ? yt        |t
        «      r-|D ]'  }| j                  |t        j                  |«      «       Œ) yt        d«      ‚)a0  Registers multiple handlers at once. The order of the handlers in the passed
        sequence(s) matters. See :meth:`add_handler` for details.

        .. versionadded:: 20.0

        Args:
            handlers (Sequence[:class:`telegram.ext.BaseHandler`] |                 dict[int, Sequence[:class:`telegram.ext.BaseHandler`]]):
                Specify a sequence of handlers *or* a dictionary where the keys are groups and
                values are handlers.

                .. versionchanged:: 21.7
                    Accepts any :class:`collections.abc.Sequence` as input instead of just a list
                    or tuple.

            group (:obj:`int`, optional): Specify which group the sequence of :paramref:`handlers`
                should be added to. Defaults to ``0``.

        Example::

            app.add_handlers(handlers={
                -1: [MessageHandler(...)],
                1: [CallbackQueryHandler(...), CommandHandler(...)]
            }

        Raises:
            :exc:`TypeError`: If the combination of arguments is invalid.
        zBThe `group` argument can only be used with a sequence of handlers.zHandlers for group z  must be a sequence of handlers.z†The `handlers` argument must be a sequence of handlers or a dictionary where the keys are groups and values are sequences of handlers.N)r„   ra  r   r…   rc  r	   re  Ú	get_value)rL   rn   r^  Úhandler_groupÚgrp_handlersr½   s         rN   Úadd_handlerszApplication.add_handlers€  sÛ   € ôF �h¤Ô%¬j¸ÄÔ.MÜÐ`ÓaÐaä�h¤Ô%Ø/7¯~©~Ó/?ò =Ñ+�˜|Ü! ,´Ô9Ü#Ø-¨m¨_Ð<\Ð]óð ð  ,ò =�GØ×$Ñ$ W¨mÕ<ñ=ñ=ô ˜¤(Ô+Ø#ò I�Ø× Ñ  ¬,×*@Ñ*@ÀÓ*GÕHñIô ð]óð rO   c                 óž   — || j                   |   v r<| j                   |   j                  |«       | j                   |   s| j                   |= yyy)a>  Remove a handler from the specified group.

        Hint:
            This method currently has no influence on calls to :meth:`process_update` that are
            already in progress.

            .. warning::
                This behavior should currently be considered an implementation detail and not as
                guaranteed behavior.

        Args:
            handler (:class:`telegram.ext.BaseHandler`): A :class:`telegram.ext.BaseHandler`
                instance.
            group (:obj:`object`, optional): The group identifier. Default is ``0``.

        N)rn   Úremove)rL   r½   r^  s      rN   Úremove_handlerzApplication.remove_handlerº  sN   € ð& �d—m‘m EÑ*Ñ*Ø�M‰M˜%Ñ ×'Ñ'¨Ô0Ø—=‘= Ò'Ø—M‘M %Ñ(ð (ð +rO   Úchat_idc                 ór   — | j                   j                  |d«       | j                  j                  |«       y)a©  Drops the corresponding entry from the :attr:`chat_data`. Will also be deleted from
        the persistence on the next run of :meth:`update_persistence`, if applicable.

        Warning:
            When using :attr:`concurrent_updates` or the :attr:`job_queue`,
            :meth:`process_update` or :meth:`telegram.ext.Job.run` may re-create this entry due to
            the asynchronous nature of these features. Please make sure that your program can
            avoid or handle such situations.

        .. versionadded:: 20.0

        Args:
            chat_id (:obj:`int`): The chat id to delete. The entry will be deleted even if it is
                not empty.
        N)r^   Úpopr_   r0  )rL   rn  s     rN   Údrop_chat_datazApplication.drop_chat_dataÒ  ó,   € ð  	�‰×Ñ˜G TÔ*Ø×3Ñ3×7Ñ7¸Õ@rO   Úuser_idc                 ór   — | j                   j                  |d«       | j                  j                  |«       y)a©  Drops the corresponding entry from the :attr:`user_data`. Will also be deleted from
        the persistence on the next run of :meth:`update_persistence`, if applicable.

        Warning:
            When using :attr:`concurrent_updates` or the :attr:`job_queue`,
            :meth:`process_update` or :meth:`telegram.ext.Job.run` may re-create this entry due to
            the asynchronous nature of these features. Please make sure that your program can
            avoid or handle such situations.

        .. versionadded:: 20.0

        Args:
            user_id (:obj:`int`): The user id to delete. The entry will be deleted even if it is
                not empty.
        N)rf   rp  rg   r0  )rL   rs  s     rN   Údrop_user_datazApplication.drop_user_dataå  rr  rO   ÚmessagezMessage | NoneÚold_chat_idÚnew_chat_idc                 ó  — |r|s|rt        d«      ‚t        |||f«      st        d«      ‚|rl|j                  €|j                  €t        d«      ‚|j                  xs |j                  j
                  }|j                  xs |j                  j
                  }n+t        |t        «      rt        |t        «      st        d«      ‚| j                  |   | j                  |<   | j                  |«       | j                  j                  |«       y)a  Moves the contents of :attr:`chat_data` at key :paramref:`old_chat_id` to the key
        :paramref:`new_chat_id`. Also marks the entries to be updated accordingly in the next run
        of :meth:`update_persistence`.

        Warning:
            * Any data stored in :attr:`chat_data` at key :paramref:`new_chat_id` will be
              overridden
            * The key :paramref:`old_chat_id` of :attr:`chat_data` will be deleted
            * This does not update the :attr:`~telegram.ext.Job.chat_id` attribute of any scheduled
              :class:`telegram.ext.Job`.

            When using :attr:`concurrent_updates` or the :attr:`job_queue`,
            :meth:`process_update` or :meth:`telegram.ext.Job.run` may re-create the old entry due
            to the asynchronous nature of these features. Please make sure that your program can
            avoid or handle such situations.

        .. seealso:: :wiki:`Storing Bot, User and Chat Related Data            <Storing-bot%2C-user-and-chat-related-data>`

        Args:
            message (:class:`telegram.Message`, optional): A message with either
                :attr:`~telegram.Message.migrate_from_chat_id` or
                :attr:`~telegram.Message.migrate_to_chat_id`.
                Mutually exclusive with passing :paramref:`old_chat_id` and
                :paramref:`new_chat_id`.

                .. seealso::
                    :attr:`telegram.ext.filters.StatusUpdate.MIGRATE`

            old_chat_id (:obj:`int`, optional): The old chat ID.
                Mutually exclusive with passing :paramref:`message`
            new_chat_id (:obj:`int`, optional): The new chat ID.
                Mutually exclusive with passing :paramref:`message`

        Raises:
            ValueError: Raised if the input is invalid.
        z/Message and chat_id pair are mutually exclusivez&chat_id pair or message must be passedNzvInvalid message instance. The message must have either `Message.migrate_from_chat_id` or `Message.migrate_to_chat_id`.z,old_chat_id and new_chat_id must be integers)rÈ   ÚanyÚmigrate_from_chat_idÚmigrate_to_chat_idÚchatrÕ   r„   r`  r^   rq  r`   r0  )rL   rv  rw  rx  s       rN   Úmigrate_chat_datazApplication.migrate_chat_dataø  sê   € ñV ™¡{ÜÐNÓOÐOÜ�G˜[¨+Ð6Ô7ÜÐEÓFÐFáØ×+Ñ+Ð3¸×8RÑ8RÐ8ZÜ ðVóð ð
 "×6Ñ6ÒI¸'¿,¹,¿/¹/ˆKØ!×4Ñ4ÒG¸¿¹¿¹‰Kä˜[¬#Ô.´:¸kÌ3Ô3OÜÐKÓLÐLà'+§¡°{Ñ'Cˆ�‰˜Ñ$Ø×Ñ˜KÔ(à×3Ñ3×7Ñ7¸ÕDrO   )r¿   Újobr  z
Job | Nonec                óÜ  — t        |t        «      rv|j                  r/| j                  j	                  |j                  j
                  «       |j                  r/| j                  j	                  |j                  j
                  «       |rd|j                  r%| j                  j	                  |j                  «       |j                  r&| j                  j	                  |j                  «       y y y rI   )
r„   r   Úeffective_chatr`   r0  rÕ   Úeffective_userrh   rn  rs  )rL   r¿   r  s      rN   rB  z(Application._mark_for_persistence_update;  s«   € ô �fœfÔ%Ø×$Ò$Ø×;Ñ;×?Ñ?À×@UÑ@U×@XÑ@XÔYØ×$Ò$Ø×;Ñ;×?Ñ?À×@UÑ@U×@XÑ@XÔYáØ�{Š{Ø×;Ñ;×?Ñ?ÀÇÁÔLØ�{Š{Ø×;Ñ;×?Ñ?ÀÇÁÕLð ð rO   Úchat_idsÚuser_idsc                 ó*  — |rGt        |t        «      r| j                  j                  |«       n| j                  j	                  |«       |rHt        |t        «      r| j
                  j                  |«       y| j
                  j	                  |«       yy)aì  Mark entries of :attr:`chat_data` and :attr:`user_data` to be updated on the next
        run of :meth:`update_persistence`.

        Tip:
            Use this method sparingly. If you have to use this method, it likely means that you
            access and modify ``context.application.chat/user_data[some_id]`` within a callback.
            Note that for data which should be available globally in all handler callbacks
            independent of the chat/user, it is recommended to use :attr:`bot_data` instead.

        .. versionadded:: 20.3

        Args:
            chat_ids (:obj:`int` | Collection[:obj:`int`], optional): Chat IDs to mark.
            user_ids (:obj:`int` | Collection[:obj:`int`], optional): User IDs to mark.

        N)r„   r`  r`   r0  r¿   rh   )rL   rƒ  r„  s      rN   Ú mark_data_for_update_persistencez,Application.mark_data_for_update_persistenceJ  ss   € ñ& Ü˜(¤CÔ(Ø×;Ñ;×?Ñ?ÀÕIà×;Ñ;×BÑBÀ8ÔLÙÜ˜(¤CÔ(Ø×;Ñ;×?Ñ?ÀÕIà×;Ñ;×BÑBÀ8ÕLð	 rO   c              ƒ   ó–  K  — | j                   j                  «       s[| j                  sy 	 t        j                  | j                   j                  «       | j                  j                  ¬«      ƒ d {  –—†  y y y 7 Œ# t        j                  $ r Y nw xY w| j                  «       ƒ d {  –—†7   | j                   j                  «       sŒ«ŒR­w)N)rî   )	r‹   r#  ro   r‰   Úwait_forrÜ   Úupdate_intervalÚTimeoutErrorrÁ   r”   s    rN   rÔ   z Application._persistence_updaterh  s´   è ø€ à×1Ñ1×8Ñ8Ô:Ø×#Ò#ØðÜ×&Ñ&Ø×3Ñ3×8Ñ8Ó:Ø ×,Ñ,×<Ñ<ô÷ ð ð øð ;ðùô ×'Ñ'ò Ùðúð ×)Ñ)Ó+×+Ñ+ð% ×1Ñ1×8Ñ8Õ:úsG   ‚(C	«AA; Á1A9Á2A; Á6C	Á9A; Á;BÂC	ÂBÂC	Â'B*Â(C	c              ƒ   ó¼   K  — | j                   4 ƒd{  –—†  | j                  «       ƒ d{  –—†  ddd«      ƒd{  –—†  y7 Œ-7 Œ7 Œ	# 1 ƒd{  –—†7  sw Y   yxY w­w)aõ  Updates :attr:`user_data`, :attr:`chat_data`, :attr:`bot_data` in :attr:`persistence`
        along with :attr:`~telegram.ext.ExtBot.callback_data_cache` and the conversation states of
        any persistent :class:`~telegram.ext.ConversationHandler` registered for this application.

        For :attr:`user_data` and :attr:`chat_data`, only those entries are updated which either
        were used or have been manually marked via :meth:`mark_data_for_update_persistence` since
        the last run of this method.

        Tip:
            This method will be called in regular intervals by the application. There is usually
            no need to call it manually.

        Note:
            Any data is deep copied with :func:`copy.deepcopy` before handing it over to the
            persistence in order to avoid race conditions, so all persisted data must be copyable.

        .. seealso:: :attr:`telegram.ext.BasePersistence.update_interval`,
            :meth:`mark_data_for_update_persistence`
        N)r�   Ú _Application__update_persistencer”   s    rN   rÁ   zApplication.update_persistence~  sV   è ø€ ð( ×1Ñ1÷ 	.ñ 	.Ø×+Ñ+Ó-×-Ð-÷	.÷ 	.ñ 	.øØ-øð	.ø÷ 	.÷ 	.ñ 	.üsQ   ‚A“A”A—A«A¬A°A»A¼AÁAÁAÁAÁAÁAÁAc           
   ƒ   óv  ‡ K  — ‰ j                   sy t        j                  d«       t        «       }‰ j                   j                  j
                  rg‰ j                  j                  �Q|j                  ‰ j                   j                  t        ‰ j                  j                  j                  «      «      «       ‰ j                   j                  j                  r=|j                  ‰ j                   j                  t        ‰ j                  «      «      «       ‰ j                   j                  j                  r´‰ j                  }t        «       ‰ _        ‰ j                   }t        «       ‰ _        ||z  }|D ]C  }|j                  ‰ j                   j#                  |t        ‰ j                  |   «      «      «       ŒE |D ],  }|j                  ‰ j                   j%                  |«      «       Œ. ‰ j                   j                  j&                  r´‰ j(                  }t        «       ‰ _        ‰ j*                  }t        «       ‰ _        ||z  }|D ]C  }|j                  ‰ j                   j-                  |t        ‰ j&                  |   «      «      «       ŒE |D ],  }|j                  ‰ j                   j/                  |«      «       Œ. ddlm} t4        j6                  j9                  d„ ‰ j:                  j=                  «       D «       «      D ]Ü  \  }\  }}	t?        |	|«      rƒ|	jA                  «       sb‰ jB                  rt        j                  d«       nt        jE                  d«       |	jF                  }
‰ j:                  |   jI                  |«       n|	jK                  «       }
n|	}
|
tL        jN                  u rd n|
}|j                  ‰ j                   jQ                  |||¬«      «       ŒÞ tS        jT                  |dd	iŽƒ d {  –—† }t        j                  d
«       tS        jT                  ˆ fd„|D «       Ž ƒ d {  –—†  y 7 Œ=7 Œ­w)Nz.Starting next run of updating the persistence.r   )ÚPendingStatec              3   ó|   K  — | ]4  \  }}t        t        j                  |«      |j                  «       «      –— Œ6 y ­wrI   )Úziprµ   ÚrepeatÚpop_accessed_write_items)Ú.0rº   Ústates_dicts      rN   ú	<genexpr>z3Application.__update_persistence.<locals>.<genexpr>Ñ  s9   è ø€ ò D
á!��kô ”	× Ñ  Ó&¨×(LÑ(LÓ(N×OñD
ùs   ‚:<z£A ConversationHandlers state was not yet resolved. Updating the persistence with the current state. Will check again on next run of Application.update_persistence.zcA ConversationHandlers state was not yet resolved. Updating the persistence with the current state.)rº   r  Ú	new_staterÝ   TzFinished updating persistence.c              3   ód   •K  — | ]'  }t        |t        «      r‰j                  |d ¬«      –— Œ) y ­wrö   )r„   r’   rø   )r“  rß   rL   s     €rN   r•  z3Application.__update_persistence.<locals>.<genexpr>û  s3   øè ø€ ò àÜ˜f¤iÔ0ð ×"Ñ"¨¸Ð"×=ñùs   ƒ-0)+ro   r±   r²   r†   rÄ   rÉ   ri   rÊ   r0  Úupdate_callback_datar
   Úpersistence_datarj   Úupdate_bot_datark   r`   r_   Úupdate_chat_datarq  ru   rh   rg   Úupdate_user_dataru  r´   rŽ  rµ   r¶   r·   ra   rc  r„   rÞ   rž   ÚwarningÚ	old_stateÚmark_as_accessedrƒ   r)   ÚDELETEDÚupdate_conversationr‰   ræ   )rL   Ú
coroutinesÚ
update_idsÚ
delete_idsrn  rs  rŽ  rº   r  r–  rß   Úeffective_new_stateÚresultss   `            rN   Ú__update_persistencez Application.__update_persistence•  s¡  øè ø€ Ø×ÒØä�‰ÐFÔGä%(£Uˆ
ð ×Ñ×&Ñ&×4Ò4Ø�H‰H×(Ñ(Ð4à�N‰NØ× Ñ ×5Ñ5ÜØŸ™×4Ñ4×EÑEóóôð ×Ñ×&Ñ&×/Ò/Ø�N‰N˜4×+Ñ+×;Ñ;¼HÀTÇ]Á]Ó<SÓTÔUà×Ñ×&Ñ&×0Ò0Ø×DÑDˆJÜ:=»%ˆDÔ7Ø×DÑDˆJÜ:=»%ˆDÔ7ð ˜*Ñ$ˆJà%ò �Ø—‘Ø×$Ñ$×5Ñ5°g¼xÈÏÉÐW^ÑH_Ó?`Óaõðð &ò I�Ø—‘˜t×/Ñ/×>Ñ>¸wÓGÕHðIð ×Ñ×&Ñ&×0Ò0Ø×DÑDˆJÜ:=»%ˆDÔ7Ø×DÑDˆJÜ:=»%ˆDÔ7ð ˜*Ñ$ˆJà%ò �Ø—‘Ø×$Ñ$×5Ñ5°g¼xÈÏÉÐW^ÑH_Ó?`Óaõðð &ò I�Ø—‘˜t×/Ñ/×>Ñ>¸wÓGÕHðIõ
 	Lä&/§o¡o×&CÑ&Cñ D
à%)×%MÑ%M×%SÑ%SÓ%UôD
ó '
ò #	Ñ"ˆDÑ"�3˜	ô ˜) \Ô2ð !—~‘~Ô'Ø—|’|ÜŸ™ð>õô  Ÿ™ðBôð '×0Ñ0�Fà×<Ñ<¸TÑB×SÑSÐTWÕXà&×.Ñ.Ó0‘Fà"�à*0´L×4HÑ4HÑ*H¡$ÈfÐØ�N‰NØ× Ñ ×4Ñ4Ø 3Ð2Eð 5ó õð?#	ôJ  Ÿ™¨
ÐKÀdÑK×KˆÜ�‰Ð6Ô7ô �n‰nóà%ôð
÷ 	
ñ 	
ð	 Løð	
ús$   ƒO4P9Ï7P5Ï87P9Ð/P7Ð0P9Ð7P9ÚcallbackrY  c                 ój   — || j                   v rt        j                  d«       y|| j                   |<   y)a–  Registers an error handler in the Application. This handler will receive every error
        which happens in your bot. See the docs of :meth:`process_error` for more details on how
        errors are handled.

        Note:
            Attempts to add the same callback multiple times will be ignored.

        Examples:
            :any:`Errorhandler Bot <examples.errorhandlerbot>`

        Hint:
            This method currently has no influence on calls to :meth:`process_error` that are
            already in progress.

            .. warning::
                This behavior should currently be considered an implementation detail and not as
                guaranteed behavior.

        .. seealso:: :wiki:`Exceptions, Warnings and Logging <Exceptions%2C-Warnings-and-Logging>`

        Args:
            callback (:term:`coroutine function`): The callback function for this error handler.
                Will be called when an error is raised. Callback signature::

                    async def callback(update: object | None, context: CallbackContext)

                The error that happened will be present in
                :attr:`telegram.ext.CallbackContext.error`.
            block (:obj:`bool`, optional): Determines whether the return value of the callback
                should be awaited before processing the next error handler in
                :meth:`process_error`. Defaults to :obj:`True`.
        zAThe callback is already registered as an error handler. Ignoring.N)rm   r±   r�  )rL   r¨  rY  s      rN   Úadd_error_handlerzApplication.add_error_handler  s3   € ðJ �t×*Ñ*Ñ*Ü�O‰OÐ_Ô`Øà(-ˆ×Ñ˜HÒ%rO   c                 ó<   — | j                   j                  |d«       y)a°  Removes an error handler.

        Hint:
            This method currently has no influence on calls to :meth:`process_error` that are
            already in progress.

            .. warning::
                This behavior should currently be considered an implementation detail and not as
                guaranteed behavior.

        Args:
            callback (:term:`coroutine function`): The error handler to remove.

        N)rm   rp  )rL   r¨  s     rN   Úremove_error_handlerz Application.remove_error_handler-  s   € ð 	×Ñ×Ñ ¨$Õ/rO   r÷   zJob[CCT] | Nonec           	   ƒ   ó  K  — | j                   rút        | j                   j                  «       «      }|D ]Ñ  \  }}	 | j                  j                  j                  ||| ||¬«      }|rX|t        u r…t        | j                  t        «      rk| j                  j                  rU| j                  j                  j                  s5| j                   |||«      |dd| j                  j                   › d�¬	«       ŒÀ	  |||«      ƒ d{  –—†  ŒÓ yt        j%                  d|¬«       y# t        $ r#}	t        j                  d||	¬«       Y d}	~	 yd}	~	ww xY w7 ŒN# t"        $ r Y  yt        $ r"}	t        j%                  d
|	¬«       Y d}	~	�ŒOd}	~	ww xY w­w)a¹  Processes an error by passing it to all error handlers registered with
        :meth:`add_error_handler`. If one of the error handlers raises
        :class:`telegram.ext.ApplicationHandlerStop`, the error will not be handled by other error
        handlers. Raising :class:`telegram.ext.ApplicationHandlerStop` also stops processing of
        the update when this method is called by :meth:`process_update`, i.e. no further handlers
        (even in other groups) will handle the update. All other exceptions raised by an error
        handler will just be logged.

        .. versionchanged:: 20.0

            * ``dispatch_error`` was renamed to :meth:`process_error`.
            * Exceptions raised by error handlers are now properly logged.
            * :class:`telegram.ext.ApplicationHandlerStop` is no longer reraised but converted into
              the return value.

        Args:
            update (:obj:`object` | :class:`telegram.Update`): The update that caused the error.
            error (:obj:`Exception`): The error that was raised.
            job (:class:`telegram.ext.Job`, optional): The job that caused the error.

                .. versionadded:: 20.0
            coroutine (:term:`coroutine function`, optional): The coroutine that caused the error.

        Returns:
            :obj:`bool`: :obj:`True`, if one of the error handlers raised
            :class:`telegram.ext.ApplicationHandlerStop`. :obj:`False`, otherwise.
        )r¿   r÷   Úapplicationr  r*  ziError while building CallbackContext for exception %s. Exception will not be processed by error handlers.rÚ   NFTrÑ   z:process_error:non_blocking)r¿   r-  rº   r?  z4No error handlers are registered, logging exception.)rm   Úlistrc  rl   rU  Ú
from_errorr’   r±   rá   r   r„   ri   r$   rZ  rY  r,  rÕ   rE   r;  )
rL   r¿   r÷   r  r*  Úerror_handler_itemsr¨  rY  rU  rç   s
             rN   rø   zApplication.process_error>  s—  è ø€ ðD ×Òô
 #' t×':Ñ':×'@Ñ'@Ó'BÓ"CÐØ#6ò *‘�˜%ð!Ø"×0Ñ0×8Ñ8×CÑCØ%Ø#Ø$(ØØ"+ð Dó �Gñ$ Øœ\Ñ)Ü" 4§8¡8¬VÔ4ØŸ™×)Ò)Ø ŸH™H×-Ñ-×3Ò3à×&Ñ&Ù  ¨Ó1Ø%Ø)-Ø+¨D¯H©H¯K©K¨=Ð8SÐTð	 'õ ð	Ù& v¨wÓ7×7Ñ7ðE*ðV ä×ÑÐPÐ[`ÐÔaØøôK !ò 	!Ü×$Ñ$ðQð Ø!$ð %ô õ !ûð	!úð2 8ùÜ1ò $Ú#Ü$ò Ü×)Ñ)ðHà%(ð *÷ ò ûðüsw   ‚8F»*D!Á%BFÃ5EÄEÄEÄFÄ!	EÄ*EÅFÅEÅFÅEÅ	FÅFÅFÅ&FÅ=FÆFÆF)rG   zJobQueue[CCT] | None)rG   r9   )rG   r8   )rG   N)r½   r6   rG   N)TrI   )NFN)NF)NNN)NN)crP   rQ   rR   rS   r@  rA  rT   r+   r&   r.   r"   r0   r-   r*   r#   r,   r   r   r   rK   r<   r•   Útyperà   r   rš   Ústrrœ   ÚpropertyÚboolrž   r`  r¡   ry   rz   Ústaticmethodr   r¦   r«   r®   r‘   r»   r“   r³   rÖ   rå   rê   ÚdtmÚ	timedeltar   Úfloatr   r	   r   rþ   r   r   r   r   r  r  rü   rB   r/   rU   rÓ   r,  r‰   ÚTaskr2  r/  rL  r×   rH  rP  r;   r%   re  Ú
_DEFAULT_0ra  r   rj  rm  rq  ru  r~  rB  r   r†  rÔ   rÁ   rŒ  r   r2   rª  r¬  r’   rC   rø   rx   rO   rN   r=   r=   v   sÐ  „ ñsðl	
ðF  #×/Ñ/°7Ò:ÑÀñG#	Dð ðNO5Ø4ðO5ð ðO5ð .ð	O5ð
 ˜4‘ðO5ð ðO5ð 0ðO5ð % R¨¨R ZÑ0°4Ñ7ðO5ð $ C¨¨R° OÑ4ðO5ð Ð<Ð=¸yÈÈcÐSWÈÑ?XÐXÑYÐ\`Ñ`ðO5ð Ð<Ð=¸yÈÈcÐSWÈÑ?XÐXÑYÐ\`Ñ`ðO5ð" Ð<Ð=¸yÈÈcÐSWÈÑ?XÐXÑYÐ\`Ñ`ó#O5ðb˜xð ¨Hó ð"	à�}Ñ%¨Ñ,ð	ð  Ñ%ð	ð  Ñ$ð		ð
 
ó	ð	B˜#ó 	Bð ð˜ò ó ðð ð
= Cò 
=ó ð
=ð òó ðð ò&ó ð&ð ð ò ó ðð ò
$ó ð
$óó)+óV
ó
%"óNó:3ój@4óD#ðN  #Ø+˜cŸm™m°BÔ7Ø!"Ø04Ø,0ØØ0<ñm
àðm
ð ðm
ð ð	m
ð
 " #™¨Ñ-ðm
ð # T™kðm
ð ðm
ð ˜x¨™}Ñ-ðm
ð 
óm
ðb )Ø&ØØ"&Ø!%Ø!"Ø"&Ø04Ø,0Ø!%Ø!ØØ0<Ø#'Ø-1ñ!^
à�s‘ð^
ð �S‰kð^
ð ð	^
ð
 �D‰j˜4Ñð^
ð �4‰Z˜$Ñð^
ð ð^
ð ˜4‘Zð^
ð " #™¨Ñ-ð^
ð # T™kð^
ð ˜$‘Jð^
ð ð^
ð ð^
ð ˜x¨™}Ñ-ð^
ð ˜D‘jð^
ð  +ð!^
ð" 
ó#^
ð@
°sð 
¸tó 
ð  ñ?!à$ð?!ð ˜x¨™}Ñ-ð?!ð ð	?!ð
 ð?!ð 
ó?!ðH !%ð&Qð
  ò&Qà˜R‘=ð&Qð ˜‘ð&Qð
 �D‰jð&Qð 
ó&QðV !%Ø!&Øñà˜R‘=ðð ˜‘ðð ð	ð
 �D‰jðð 
óð<°·±ð Àó ð !%Ø!&ñ	,=à˜R‘=ð,=ð ˜‘ð,=ð ð	,=ð
 
ó,=ó\<ó,	2ð*°Vð *Àó *ðU=¨6ð U=°dó U=ðn MZñ G- ;¨s°C¸¨}Ñ#=ð G-Àcð G-Ð^bó G-ð\ *4ñ8ð �[  c¨3 Ñ/Ñ0°4¸¸XÀkÐRUÐWZÐ\_ÐR_ÑF`Ñ=aÐ8aÑ3bÑbð8ð
 �\ #Ñ&Ñ&ð8ð 
ó8ðv ANñ)Ø" 3¨¨S =Ñ1ð)Ø:=ð)à	ó)ð0A cð A¨dó Að&A cð A¨dó Að* %)Ø"&Ø"&ñ	@Eà!ð@Eð ˜4‘Zð@Eð ˜4‘Zð	@Eð
 
ó@EðH *.À4òMØ $™ðMØ4@ðMà	óMð  MQñMØ˜C™ 4™ðMØ:=¸c¹(ÀT¹/ðMà	óMó<,ó,.ó.k
ð` +ñ).à! &¨#¨tÐ"3Ñ4ð).ð �d‰|ð).ð 
ó	).ðV0¨_¸VÀSÈ$Ð=NÑ-Oð 0ÐTXó 0ð* "&Ø/3ñVà˜‘ðVð ðVð ð	Vð
 " "Ñ%¨Ñ,ðVð 
ôVrO   )nrS   r‰   r7  Údatetimer·  r   rµ   r  r  r@  Úcollectionsr   Úcollections.abcr   r   r   r   r   r	   rS  r
   Úpathlibr   Útypesr   r   Útypingr   r   r   r   r   r   Útelegram._updater   Útelegram._utils.defaultvaluer   r   r   r   r   Útelegram._utils.loggingr   Útelegram._utils.reprr   Útelegram._utils.typesr   r   r   r   Útelegram._utils.warningsr    Útelegram.errorr!   Útelegram.ext._basepersistencer"   Útelegram.ext._contexttypesr#   Útelegram.ext._extbotr$   Ú"telegram.ext._handlers.basehandlerr%   Útelegram.ext._updaterr&   Útelegram.ext._utils.networkloopr'   Útelegram.ext._utils.stackr(   Ú telegram.ext._utils.trackingdictr)   Útelegram.ext._utils.typesr*   r+   r,   r-   r.   r/   r0   r1   r2   Útelegram.warningsr3   r4   Útelegramr5   rª   r6   r7   Ú telegram.ext._applicationbuilderr8   Ú!telegram.ext._baseupdateprocessorr9   Útelegram.ext._jobqueuer:   r;   r`  Ú__annotations__r<   rU   rã   r»  rA  rB   rC   rP   r±   r’   rE   ÚAbstractAsyncContextManagerr=   rx   rO   rN   ú<module>rÙ     sL  ðò& 2ã Û Û Û Û Û Û Û 
Ý #ß X× XÝ Ý ß 1ß L× Lå #÷õ õ /Ý ?ß CÓ CÝ )Ý (Ý 9Ý 3Ý 'Ý :Ý )Ý >Ý 3Ý 9ß c× cÕ cÝ 3áÝå ß:ÝGÝEÝ*à€ˆsÓ á�: ]Ô3€Ù‹x€Ù˜!‹_€
ð ×Ñ�wÒØ˜"‘�Ià$Ð%=¸tÀRÐ%GÑHÈ9ÐUWÉ=ÑX€IˆyÓXà% b™M¨DÑ0€�	Ó 0á
�XÓ
€ô*˜Yô *ô>^Ø×*Ñ*¨=Ñ9ØˆB��R˜˜R Ð#Ñ$õ^rO   