
    > /iN                     0   d Z ddlZddlZddlZddlmZ ddlmZ ddlm	Z	m
Z
mZmZ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 dd	lmZ dd
lmZmZmZmZ 	 ddl m!Z!m"Z" dZ#e	rddl%m&Z&  edd      Z' ee(      Z) G d ded         Z*y# e$$ r dZ#Y 2w xY w)z]This module contains the class Updater, which tries to make creating Telegram bots intuitive.    N)Path)TracebackType)
TYPE_CHECKINGAnyAsyncContextManagerCallable	CoroutineListOptionalTypeTypeVarUnion)DEFAULT_NONE)
get_logger)build_repr_with_selected_attrs)ODVInput)InvalidToken
RetryAfterTelegramErrorTimedOut)WebhookAppClassWebhookServerTF)Bot_UpdaterTypeUpdater)boundc                      e Zd ZdZdZ	 	 	 	 d:dZdedefdZdee	e
      d	ee
   d
ee   ddfdZdefdZedefd       Zd;dZd;dZdddeeeedddf
dedededee   dee   dee   dee   deee      dee   deeegdf      ddfdZdededee   dee   dee   dee   dedee   deee      dej:                  deeegdf      ddfd Z	 	 	 	 	 	 	 	 	 	 	 	 d<d!ed"ed#ed$eeee f      d%eeee f      ded&ee   deee      dee   d'ee   d(ed)ee   ddfd*Z!	 	 	 	 	 	 	 	 d=d!ed"ed#ededeee      d$eeee f      d%eeee f      dee   d&ee   deej:                     d'ee   d(ed)ee   ddfd+Z"e#d,ed!ed"ed#edef
d-       Z$d.ed/e%f   d0eegdf   d1ed2eddf
d3Z&	 	 	 	 	 	 d>d4ed&ee   deee      dee   d$ee'   d5ed'ee   d(ed)ee   ddfd6Z(d;d7Z)d;d8Z*d;d9Z+y)?r   a]  This class fetches updates for the bot either via long polling or by starting a webhook
    server. Received updates are enqueued into the :attr:`update_queue` and may be fetched from
    there to handle them appropriately.

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

    .. code:: python

        async with updater:
            # code

    is roughly equivalent to

    .. code:: python

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

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

    .. seealso:: :wiki:`Architecture Overview <Architecture>`,
        :wiki:`Builder Pattern <Builder-Pattern>`

    .. versionchanged:: 20.0

        * Removed argument and attribute ``user_sig_handler``
        * The only arguments and attributes are now :attr:`bot` and :attr:`update_queue` as now
          the sole purpose of this class is to fetch updates. The entry point to a PTB application
          is now :class:`telegram.ext.Application`.

    Args:
        bot (:class:`telegram.Bot`): The bot used with this Updater.
        update_queue (:class:`asyncio.Queue`): Queue for the updates.

    Attributes:
        bot (:class:`telegram.Bot`): The bot used with this Updater.
        update_queue (:class:`asyncio.Queue`): Queue for the updates.

    )botupdate_queue_last_update_id_running_initialized_httpd__lock__polling_taskasyncio.Queue[object]c                     || _         || _        d| _        d| _        d| _        d | _        t        j                         | _        d | _	        d | _
        y )Nr   F)r   r   r    r!   r"   r#   asyncioLock_Updater__lock_Updater__polling_task_Updater__polling_cleanup_cb)selfr   r   s      K/srv/sistema/bot/venv/lib/python3.12/site-packages/telegram/ext/_updater.py__init__zUpdater.__init__r   sN    
 3? !/3lln6:W[!    r-   returnc                    K   	 | j                          d{    | S 7 # t        $ r }| j                          d{  7   |d}~ww xY ww)a0  
        |async_context_manager| :meth:`initializes <initialize>` the Updater.

        Returns:
            The initialized Updater instance.

        Raises:
            :exc:`Exception`: If an exception is raised during initialization, :meth:`shutdown`
                is called in this case.
        N)
initialize	Exceptionshutdown)r-   excs     r.   
__aenter__zUpdater.__aenter__   sH     	//###K $ 	--/!!I	s9   A    A  	A	A?AA		Aexc_typeexc_valexc_tbNc                 @   K   | j                          d{    y7 w)zB|async_context_manager| :meth:`shuts down <shutdown>` the Updater.N)r5   )r-   r8   r9   r:   s       r.   	__aexit__zUpdater.__aexit__   s      mmos   c                 0    t        | | j                        S )a  Give a string representation of the updater in the form ``Updater[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`
        )r   )r   r   r-   s    r.   __repr__zUpdater.__repr__   s     .dAAr0   c                     | j                   S )N)r!   r>   s    r.   runningzUpdater.running   s    }}r0   c                    K   | j                   rt        j                  d       y| j                  j	                          d{    d| _         y7 w)zInitializes the Updater & the associated :attr:`bot` by calling
        :meth:`telegram.Bot.initialize`.

        .. seealso::
            :meth:`shutdown`
        z$This Updater is already initialized.NT)r"   _LOGGERdebugr   r3   r>   s    r.   r3   zUpdater.initialize   sD      MM@Ahh!!###  	$s   A AAAc                    K   | j                   rt        d      | j                  st        j	                  d       y| j
                  j                          d{    d| _        t        j	                  d       y7 !w)z
        Shutdown the Updater & the associated :attr:`bot` by calling :meth:`telegram.Bot.shutdown`.

        .. seealso::
            :meth:`initialize`

        Raises:
            :exc:`RuntimeError`: If the updater is still running.
        zThis Updater is still running!z-This Updater is already shut down. Returning.NFzShut down of Updater complete)rA   RuntimeErrorr"   rC   rD   r   r5   r>   s    r.   r5   zUpdater.shutdown   sd      <<?@@  MMIJhh!!!!56 	"s   AA=A;"A=g        
   poll_intervaltimeoutbootstrap_retriesread_timeoutwrite_timeoutconnect_timeoutpool_timeoutallowed_updatesdrop_pending_updateserror_callbackc                   K   |
r t        j                  |
      rt        d      | j                  4 d{    | j                  rt        d      | j                  st        d      d| _        	 t        j                         }| j                  ||||||||	|||
       d{    t        j                  d       |j                          d{    t        j                  d       | j                  cddd      d{    S 7 7 e7 :7 # t        $ r}d	| _        |d}~ww xY w# 1 d{  7  sw Y   yxY ww)
aM  Starts polling updates from Telegram.

        .. versionchanged:: 20.0
            Removed the ``clean`` argument in favor of :paramref:`drop_pending_updates`.

        Args:
            poll_interval (:obj:`float`, optional): Time to wait between polling updates from
                Telegram in seconds. Default is ``0.0``.
            timeout (:obj:`int`, optional): Passed to
                :paramref:`telegram.Bot.get_updates.timeout`. Defaults to ``10`` seconds.
            bootstrap_retries (:obj:`int`, optional): Whether the bootstrapping phase of the
                :class:`telegram.ext.Updater` will retry on failures on the Telegram server.

                * < 0 - retry indefinitely (default)
                *   0 - no retries
                * > 0 - retry up to X times
            read_timeout (:obj:`float`, optional): Value to pass to
                :paramref:`telegram.Bot.get_updates.read_timeout`. Defaults to
                :attr:`~telegram.request.BaseRequest.DEFAULT_NONE`.

                .. versionchanged:: 20.7
                    Defaults to :attr:`~telegram.request.BaseRequest.DEFAULT_NONE` instead of
                    ``2``.
                .. deprecated:: 20.7
                    Deprecated in favor of setting the timeout via
                    :meth:`telegram.ext.ApplicationBuilder.get_updates_read_timeout` or
                    :paramref:`telegram.Bot.get_updates_request`.
            write_timeout (:obj:`float` | :obj:`None`, optional): Value to pass to
                :paramref:`telegram.Bot.get_updates.write_timeout`. Defaults to
                :attr:`~telegram.request.BaseRequest.DEFAULT_NONE`.

                .. deprecated:: 20.7
                    Deprecated in favor of setting the timeout via
                    :meth:`telegram.ext.ApplicationBuilder.get_updates_write_timeout` or
                    :paramref:`telegram.Bot.get_updates_request`.
            connect_timeout (:obj:`float` | :obj:`None`, optional): Value to pass to
                :paramref:`telegram.Bot.get_updates.connect_timeout`. Defaults to
                :attr:`~telegram.request.BaseRequest.DEFAULT_NONE`.

                .. deprecated:: 20.7
                    Deprecated in favor of setting the timeout via
                    :meth:`telegram.ext.ApplicationBuilder.get_updates_connect_timeout` or
                    :paramref:`telegram.Bot.get_updates_request`.
            pool_timeout (:obj:`float` | :obj:`None`, optional): Value to pass to
                :paramref:`telegram.Bot.get_updates.pool_timeout`. Defaults to
                :attr:`~telegram.request.BaseRequest.DEFAULT_NONE`.

                .. deprecated:: 20.7
                    Deprecated in favor of setting the timeout via
                    :meth:`telegram.ext.ApplicationBuilder.get_updates_pool_timeout` or
                    :paramref:`telegram.Bot.get_updates_request`.
            allowed_updates (List[:obj:`str`], optional): Passed to
                :meth:`telegram.Bot.get_updates`.
            drop_pending_updates (:obj:`bool`, optional): Whether to clean any pending updates on
                Telegram servers before actually starting to poll. Default is :obj:`False`.

                .. versionadded :: 13.4
            error_callback (Callable[[:exc:`telegram.error.TelegramError`], :obj:`None`],                 optional): Callback to handle :exc:`telegram.error.TelegramError` s that occur
                while calling :meth:`telegram.Bot.get_updates` during polling. Defaults to
                :obj:`None`, in which case errors will be logged. Callback signature::

                    def callback(error: telegram.error.TelegramError)

                Note:
                    The :paramref:`error_callback` must *not* be a :term:`coroutine function`! If
                    asynchronous behavior of the callback is wanted, please schedule a task from
                    within the callback.

        Returns:
            :class:`asyncio.Queue`: The update queue that can be filled from the main thread.

        Raises:
            :exc:`RuntimeError`: If the updater is already running or was not initialized.

        zYThe `error_callback` must not be a coroutine function! Use an ordinary function instead. N This Updater is already running!:This Updater was not initialized via `Updater.initialize`!T)rI   rJ   rL   rM   rN   rO   rK   rQ   rP   readyrR   zWaiting for polling to startz%Polling updates from Telegram startedF)r(   iscoroutinefunction	TypeErrorr*   rA   rF   r"   r!   Event_start_pollingrC   rD   waitr   r4   )r-   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   polling_readyr6   s                r.   start_pollingzUpdater.start_polling   s@    z g99.I 
 ;; !	 !	||"#EFF$$"#_`` DM '))"/#!-"/$3!-&7)=$3'#1 *    <=#((***EF((=!	 !	 !	 +7!	>   %	?!	 !	 !	s   3D>DD>6D)03D#D	$,DD$D5D>DD>	DDD>	D&	D!!D&&D))D;/D20D;7D>rV   c                    	K   t         j                  d        j                  ||dd        d {    t         j                  d       dt        f	 fd}dt        dd fd}t        j                   j                  ||xs |d	|
      d       _        d	 fd}| _	        |
|
j                          y y 7 w)NzUpdater started (polling) )rQ   webhook_urlrP   zBootstrap doner1   c            	        K   	 j                   j                  j                  	       d {   } | rcj                  st
        j                  d       y| D ]%  }j                  j                  |       d {    ' | d   j                  dz   _        y7 j# t        $ r}|d }~wt        $ r!}t
        j                  d|       Y d }~yd }~ww xY w7 [w)NoffsetrJ   rL   rN   rM   rO   rP   zcSomething went wrong processing the data received from Telegram. Received data was *not* processed!exc_infoTzYUpdater stopped unexpectedly. Pulled updates will be ignored and pulled again on restart.rH      )r   get_updatesr    r   r4   rC   criticalrA   r   put	update_id)
updatesr6   updaterP   rN   rO   rL   r-   rJ   rM   s
      r.   polling_action_cbz1Updater._start_polling.<locals>.polling_action_cbs  s      $ 4 4//#!-$3"/!-$3 !5 ! * ||$$, 	 #* <"//33F;;;<+22;+@+@1+DD(A ! 	   9  ! 
 " <sV   C/B! BB! AC CCB! !	C*B,,C8CCCCr6   c                 2    t         j                  d|        y )Nz-Exception happened while polling for updates.rd   )rC   	exception)r6   s    r.   default_error_callbackz6Updater._start_polling.<locals>.default_error_callback  s    MX[\r0   zgetting Updates)	action_cb	on_err_cbdescriptionintervalz"Updater:start_polling:polling_task)namec            	         K   t         j                  d       	 j                  j                  j                  d       d {    y 7 # t
        $ r!} t         j                  d|        Y d } ~ y d } ~ ww xY ww)NzHCalling `get_updates` one more time to mark all fetched updates as read.r   rb   a-  Error while calling `get_updates` one more time to mark all fetched updates as read: %s. Suppressing error to ensure graceful shutdown. When polling for updates is restarted, updates may be fetched again. Please adjust timeouts via `ApplicationBuilder` or the parameter `get_updates_request` of `Bot`.rd   )rC   rD   r   rg   r    r   error)r6   rP   rN   rO   rL   r-   rM   s    r.   _get_updates_cleanupz4Updater._start_polling.<locals>._get_updates_cleanup  s     MMZhh**//!-$3"/!-$3 + 	 	 	 ! ` !   s@   A>/A 	A
A A>A 	A;A61A>6A;;A>r1   N)rC   rD   
_bootstrapboolr   r(   create_task_network_loop_retryr+   r,   set)r-   rI   rJ   rL   rM   rN   rO   rK   rQ   rP   rV   rR   rm   rp   rx   s   ` `````  `     r.   rZ   zUpdater._start_pollingW  s      	12
 oo!5 	  
 	
 	
 	&'"	 "	 "	H	] 	]$ 	] &11$$+(B,B-&	 %  6
	 	0 %9!IIK y	
s   .C
CBC
listenporturl_pathcertkeyr`   
ip_addressmax_connectionssecret_tokenc                 b  K   t         st        d      | j                  4 d{    | j                  rt        d      | j                  st        d      d| _        	 t        j                         }| j                  |||||||	||||
||       d{    t        j                  d       |j                          d{    t        j                  d       | j                  cddd      d{    S 7 7 e7 :# t        $ r}d	| _        |d}~ww xY w7 %# 1 d{  7  sw Y   yxY ww)
aD  
        Starts a small http server to listen for updates via webhook. 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.

        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]"

        .. seealso:: :wiki:`Webhooks`

        .. versionchanged:: 13.4
            :meth:`start_webhook` now *always* calls :meth:`telegram.Bot.set_webhook`, so pass
            ``webhook_url`` instead of calling ``updater.bot.set_webhook(webhook_url)`` manually.
        .. versionchanged:: 20.0

            * Removed the ``clean`` argument in favor of :paramref:`drop_pending_updates` and
              removed the deprecated argument ``force_event_loop``.

        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 (http(s)://listen:port/<url_path>).
                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.
            drop_pending_updates (:obj:`bool`, optional): Whether to clean any pending updates on
                Telegram servers before actually starting to poll. Default is :obj:`False`.

                .. versionadded :: 13.4
            bootstrap_retries (:obj:`int`, optional): Whether the bootstrapping phase of the
                :class:`telegram.ext.Updater` 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`.
            ip_address (:obj:`str`, optional): Passed to :meth:`telegram.Bot.set_webhook`.
                Defaults to :obj:`None`.

                .. versionadded :: 13.4
            allowed_updates (List[:obj:`str`], optional): Passed to
                :meth:`telegram.Bot.set_webhook`. Defaults to :obj:`None`.
            max_connections (:obj:`int`, optional): Passed to
                :meth:`telegram.Bot.set_webhook`. Defaults to ``40``.

                .. versionadded:: 13.6
            secret_token (:obj:`str`, optional): Passed to :meth:`telegram.Bot.set_webhook`.
                Defaults to :obj:`None`.

                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
        Returns:
            :class:`queue.Queue`: The update queue that can be filled from the main thread.

        Raises:
            :exc:`RuntimeError`: If the updater is already running or was not initialized.
        z`To use `start_webhook`, PTB must be installed via `pip install "python-telegram-bot[webhooks]"`.NrT   rU   T)r   r   r   r   r   rK   rQ   r`   rP   rV   r   r   r   z#Waiting for webhook server to startzWebhook server startedF)WEBHOOKS_AVAILABLErF   r*   rA   r"   r!   r(   rY   _start_webhookrC   rD   r[   r4   r   )r-   r   r   r   r   r   rK   r`   rP   rQ   r   r   r   webhook_readyr6   s                  r.   start_webhookzUpdater.start_webhook  s:    p "4 
 ;; $	% $	%||"#EFF$$"#_`` DM '))!%&7)= +$3')$3!- *     CD#((***67 $$I$	% $	% $	%" +  %	?$	% $	% $	% $	%s   "D/C8D/6D5C>C:,C>C<C>D&D/2D3D/:C><C>>	D	DDDD/D, D#!D,(D/c           
        K   t         j                  d       |j                  d      sd| }t        || j                  | j
                  |      }|C|A	 t        j                  t        j                  j                        }|j                  ||       nd }t        ||||      | _        |	s| j                  |rdnd|||      }	| j!                  |rt#        |      j%                         nd |||	||||       d {    | j                  j'                  |
       d {    y # t        j                  $ r}t        d      |d }~ww xY w7 P7 .w)	Nz Updater thread started (webhook)/zInvalid SSL Certificatehttpshttpprotocolr   r   r   )r   max_retriesrQ   r`   rP   r   r   r   )rV   )rC   rD   
startswithr   r   r   sslcreate_default_contextPurposeCLIENT_AUTHload_cert_chainSSLErrorr   r   r#   _gen_webhook_urlrz   r   
read_bytesserve_forever)r-   r   r   r   rK   rP   r   r   rQ   r`   rV   r   r   r   appssl_ctxr6   s                    r.   r   zUpdater._start_webhookM  sd      	89""3'8*~H h$2C2C\R H474N4NKK++5 ''c2 G $FD#w?//$+!	 0 K oo -1d&&(d)!5#+!+%  
 	
 	
 kk''e'444= << H#$=>CGH"	
 	5sI   AE?D& A(E<E=#E E!E&E
9EE

EEr   c                     |  d| d| | S )Nz://: r   s       r.   r   zUpdater._gen_webhook_url  s     3vhavhZ88r0   rq   .rr   rs   rt   c                   K   t         j                  d|       |}	 | j                  rA	  |        d{   sy	 |}|rt        j                  |       d{    | j                  r@yy7 6# t        $ r/}t         j	                  d|       d|j
                  z   }Y d}~cd}~wt        $ r#}t         j                  d||       d}Y d}~d}~wt        $ r}t         j                  d       |d}~wt        $ r?}	t         j                  d||	        ||	       |dk(  rd	nt        d
d|z        }Y d}	~	d}	~	ww xY w7 # t        j                  $ r t         j                  d|       Y yw xY ww)a  Perform a loop calling `action_cb`, retrying after network errors.

        Stop condition for loop: `self.running` evaluates :obj:`False` or return value of
        `action_cb` evaluates :obj:`False`.

        Args:
            action_cb (:term:`coroutine function`): Network oriented callback function to call.
            on_err_cb (:obj:`callable`): Callback to call when TelegramError is caught. Receives
                the exception object as a parameter.
            description (:obj:`str`): Description text to use for logs and exception raised.
            interval (:obj:`float` | :obj:`int`): Interval to sleep between each call to
                `action_cb`.

        zStart network loop retry %sNz%sg      ?zTimed out %s: %sr   zInvalid token; abortingzError while %s: %srf      g      ?z#Network loop retry %s was cancelled)rC   rD   rA   r   inforetry_afterr   r   rw   r   minr(   sleepCancelledError)
r-   rq   rr   rs   rt   cur_intervalr6   toepextelegram_excs
             r.   r}   zUpdater._network_loop_retry  s9    * 	3[A	N,,,!*,, -& $,L!--5551 ,,,! 9LLs+#&#8L %MM"4k3G#$L# MM";<I$ [MM"6\Rl+ )5(91s2s\GY?ZL[ 6%% 	NMM?M	Ns   E+D< 
A, A*A, E+D< D:D< (E+*A, ,	D75%BD< D7+C	D< 	D7C,,D785D2-D< 2D77D< <)E(%E+'E((E+r   bootstrap_intervalc
           	         	K   ddt         f fd}
dt         f	 fd}dt        ddffd}ss j                  |
|d|       d{    dr j                  ||d	|       d{    yy7 &7 w)
zPrepares the setup for fetching updates: delete or set the webhook and drop pending
        updates if appropriate. If there are unsuccessful attempts, this will retry as specified by
        :paramref:`max_retries`.
        r   r1   c                     K   t         j                  d        rt         j                  d       j                  j                          d {    y7 w)NzDeleting webhook-Dropping pending updates from Telegram server)rQ   F)rC   rD   r   delete_webhook)rQ   r-   s   r.   bootstrap_del_webhookz1Updater._bootstrap.<locals>.bootstrap_del_webhook  sI     MM,-#MN(())?S)TTT Us   AAAAc            	         K   t         j                  d       rt         j                  d       j                  j                          d {    y7 w)NzSetting webhookr   )urlcertificaterP   r   rQ   r   r   F)rC   rD   r   set_webhook)rP   r   rQ   r   r   r   r-   r`   s   r.   bootstrap_set_webhookz1Updater._bootstrap.<locals>.bootstrap_set_webhook  sd     MM+,#MN((&&  /%%9 /) '    s   AAAAr6   Nc                     t        | t              s'dk  sk  rdz  t        j                  d       y t        j	                  d|        | )Nr   rf   z-Failed bootstrap phase; try=%s max_retries=%sz,Failed bootstrap phase after %s retries (%s))
isinstancer   rC   warningrw   )r6   r   retriess    r.   bootstrap_on_err_cbz/Updater._bootstrap.<locals>.bootstrap_on_err_cb  sR    
 c<0kAoS^I^1CWk LgWZ[	r0   zbootstrap del webhookzbootstrap set webhook)r{   r4   r}   )r-   r   r`   rP   rQ   r   r   r   r   r   r   r   r   r   s   `````` ```   @r.   rz   zUpdater._bootstrap  s       	T 		T 	 		Y 	4 	$  {**%#'"	   G **%#'"	   s$   ABB B9B:BBc                   K   | j                   4 d{    | j                  st        d      t        j	                  d       d| _        | j                          d{    | j                          d{    t        j	                  d       ddd      d{    y7 7 D7 .7 # 1 d{  7  sw Y   yxY ww)zStops the polling/webhook.

        .. seealso::
            :meth:`start_polling`, :meth:`start_webhook`

        Raises:
            :exc:`RuntimeError`: If the updater is not running.
        NzThis Updater is not running!zStopping UpdaterFzUpdater.stop() is complete)r*   rA   rF   rC   rD   r!   _stop_httpd_stop_pollingr>   s    r.   stopzUpdater.stop  s      ;; 	8 	8<<"#ABBMM,-!DM""$$$$$&&&MM67	8 	8 	8 %&	8 	8 	8 	8si   B>B!B>AB)B#B)6B%7B)B>B'B>#B)%B)'B>)B;/B20B;7B>c                    K   | j                   r?t        j                  d       | j                   j                          d{    d| _         yy7 w)z@Stops the Webhook server by calling ``WebhookServer.shutdown()``z4Waiting for current webhook connection to be closed.N)r#   rC   rD   r5   r>   s    r.   r   zUpdater._stop_httpd0  s?     ;;MMPQ++&&(((DK (s   ?AAAc                   K   | j                   rt        j                  d       | j                   j                          t	        j
                  t        j                        5  | j                    d{    ddd       d| _         | j                  r | j                          d{    d| _        yt        j                  d       yy7 V# 1 sw Y   UxY w7 1w)z&Stops the polling task by awaiting it.z-Waiting background polling task to finish up.NzmNo polling cleanup callback defined. The last fetched updates may be fetched again on the next polling start.)
r+   rC   rD   cancel
contextlibsuppressr(   r   r,   r   r>   s    r.   r   zUpdater._stop_polling7  s     MMIJ&&($$W%;%;< *))))*
 #'D((//111,0)? 
 ** * 2s<   AC!C
1C2C
6.C$C%#CC

CC)r   r   r   r&   ry   )z	127.0.0.1P   r_   NNr   NNNN(   N)NNNNNNr   N)NNrf   Nr   N),__name__
__module____qualname____doc__	__slots__r/   r   r7   r   r   BaseExceptionr   r<   strr?   propertyr{   rA   r3   r5   r   floatintr   r
   r   r   r]   r(   rY   rZ   r   r   r   r   staticmethodr   r	   r}   bytesrz   r   r   r   r   r0   r.   r   r   ;   sW   )V	I\\ .\ |  $	4./	 -(	 '		
 
		B# 	B   !7.  #!#(4)5+7(4/3/3DHDD D 	D
 uoD  D "%D uoD "$s),D 'tnD !=/4*?!@AD 
!DLpp p uo	p
  p "%p uop p 'tnp "$s),p }}p !=/4*?!@Ap 
ph "+/*.!"%)/3/3$(!&*B%B% B% 	B%
 uS$Y'(B% eCI&'B% B% c]B% "$s),B% 'tnB% SMB% B% smB% 
!B%V ,0*./3%))-$(!&*A5A5 A5 	A5
 A5 "$s),A5 uS$Y'(A5 eCI&'A5 'tnA5 c]A5 &A5 SMA5 A5 smA5 
A5F 93 9 93 9# 9RU 9 9
3NCN+3N ]OT123N 	3N
 3N 
3Nt 04 $$%$(!&*MM c]M "$s),	M
 'tnM uoM "M SMM M smM 
M^8,r0   )+r   r(   r   r   pathlibr   typesr   typingr   r   r   r   r	   r
   r   r   r   r   telegram._utils.defaultvaluer   telegram._utils.loggingr   telegram._utils.reprr   telegram._utils.typesr   telegram.errorr   r   r   r   "telegram.ext._utils.webhookhandlerr   r   r   ImportErrortelegramr   r   r   rC   r   r   r0   r.   <module>r      s   & d   
     6 . ? * L LQ  ~Y7
X
P!), P  s   
B BB