+
    ÁFñjC  ã                   óx   € R t ^ RIHtHt ^ RIHtHt ^ RIHtH	t	 ^ RI
Ht ^ RIHt  ! R R]]	],          4      tR# )	zOThis module contains a class that allows to rate limit requests to the Bot API.)ÚABCÚabstractmethod)ÚCallableÚ	Coroutine)ÚAnyÚGeneric)ÚJSONDict)ÚRLARGSc                   ó|   a € ] tR t^t o RtRt]V 3R lR l4       t]V 3R lR l4       t]V 3R lR l4       t	Rt
V tR	# )
ÚBaseRateLimiteraœ  
Abstract interface class that allows to rate limit the requests that python-telegram-bot
sends to the Telegram Bot API. An implementation of this class
must implement all abstract methods and properties.

This class is a :class:`~typing.Generic` class and accepts one type variable that specifies
the type of the argument :paramref:`~process_request.rate_limit_args` of
:meth:`process_request` and the methods of :class:`~telegram.ext.ExtBot`.

Hint:
    Requests to :meth:`~telegram.Bot.get_updates` are never rate limited.

.. seealso:: :wiki:`Architecture Overview <Architecture>`,
    :wiki:`Avoiding Flood Limits <Avoiding-flood-limits>`

.. versionadded:: 20.0
c                ó   <€ V ^8„  d   QhRR/# ©é   ÚreturnN© )ÚformatÚ__classdict__s   "€ÚS/opt/hermes-site/venv/lib/python3.14/site-packages/telegram/ext/_baseratelimiter.pyÚ__annotate__ÚBaseRateLimiter.__annotate__3   s   ø€ ÷ Zñ Z $ñ Zó    c              ƒ  ó   "  € R# 5i)zKInitialize resources used by this class. Must be implemented by a subclass.Nr   ©Úselfs   &r   Ú
initializeÚBaseRateLimiter.initialize2   ó   é ‚ ùó   ‚c                ó   <€ V ^8„  d   QhRR/# r   r   )r   r   s   "€r   r   r   7   s   ø€ ÷ \ñ \ ñ \r   c              ƒ  ó   "  € R# 5i)zMStop & clear resources used by this class. Must be implemented by a subclass.Nr   r   s   &r   ÚshutdownÚBaseRateLimiter.shutdown6   r   r   c                ó  <€ V ^8„  d   QhRS[ RS[S[S[S[S[,          S[S[,          ,          3,          3,          RS[RS[S[S[3,          RS[RS[S[S[3,          RS[R,          R	S[S[,          S[S[,          ,          /# )
r   Úcallback.ÚargsÚkwargsÚendpointÚdataÚrate_limit_argsNr   )	r   r   r   Úboolr   ÚlistÚdictÚstrr	   )r   r   s   "€r   r   r   ;   sž   ø€ ÷ Tñ Tá˜3¡	©#©s±D¹8µOÁdÉ8ÅnÕ4TÐ*TÕ UÐUÕVðTñ ðTñ ‘S™#�X•ð	Tñ
 ðTñ ‘3™�8�nðTñ   $�ðTñ 
‘�™4¡�>Õ	)ñTr   c              ƒ  ó   "  € R# 5i)ak  
Process a request. Must be implemented by a subclass.

This method must call :paramref:`callback` and return the result of the call.
`When` the callback is called is up to the implementation.

Important:
    This method must only return once the result of :paramref:`callback` is known!

If a :exc:`~telegram.error.RetryAfter` error is raised, this method may try to make
a new request by calling the callback again.

Warning:
    This method *should not* handle any other exception raised by :paramref:`callback`!

There are basically two different approaches how a rate limiter can be implemented:

1. React only if necessary. In this case, the :paramref:`callback` is called without any
   precautions. If a :exc:`~telegram.error.RetryAfter` error is raised, processing requests
   is halted for the :attr:`~telegram.error.RetryAfter.retry_after` and finally the
   :paramref:`callback` is called again. This approach is often amendable for bots that
   don't have a large user base and/or don't send more messages than they get updates.
2. Throttle all outgoing requests. In this case the implementation makes sure that the
   requests are spread out over a longer time interval in order to stay below the rate
   limits. This approach is often amendable for bots that have a large user base and/or
   send more messages than they get updates.

An implementation can use the information provided by :paramref:`data`,
:paramref:`endpoint` and :paramref:`rate_limit_args` to handle each request differently.

Examples:
    * It is usually desirable to call :meth:`telegram.Bot.answer_inline_query`
      as quickly as possible, while delaying :meth:`telegram.Bot.send_message`
      is acceptable.
    * There are `different <https://core.telegram.org/bots/faq              #my-bot-is-hitting-limits-how-do-i-avoid-this>`_ rate limits for group chats and
      private chats.
    * When sending broadcast messages to a large number of users, these requests can
      typically be delayed for a longer time than messages that are direct replies to a
      user input.

Args:
    callback (Callable[..., :term:`coroutine`]): The coroutine function that must be called
        to make the request.
    args (tuple[:obj:`object`]): The positional arguments for the :paramref:`callback`
        function.
    kwargs (dict[:obj:`str`, :obj:`object`]): The keyword arguments for the
        :paramref:`callback` function.
    endpoint (:obj:`str`): The endpoint that the request is made for, e.g.
        ``"sendMessage"``.
    data (dict[:obj:`str`, :obj:`object`]): The parameters that were passed to the method
        of :class:`~telegram.ext.ExtBot`. Any ``api_kwargs`` are included in this and
        any :paramref:`~telegram.ext.ExtBot.defaults` are already applied.

        Example:

            When calling::

                await ext_bot.send_message(
                    chat_id=1,
                    text="Hello world!",
                    api_kwargs={"custom": "arg"}
                )

            then :paramref:`data` will be::

                {"chat_id": 1, "text": "Hello world!", "custom": "arg"}

    rate_limit_args (:obj:`None` | :class:`object`): Custom arguments passed to the methods
        of :class:`~telegram.ext.ExtBot`. Can e.g. be used to specify the priority of
        the request.

Returns:
    :obj:`bool` | dict[:obj:`str`, :obj:`object`] | :obj:`None`: The result of the
    callback function.
Nr   )r   r#   r$   r%   r&   r'   r(   s   &&&&&&&r   Úprocess_requestÚBaseRateLimiter.process_request:   r   r   r   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú	__slots__r   r   r    r.   Ú__static_attributes__Ú__classdictcell__)r   s   @r   r   r      sQ   ø‡ € ñð$ €Ià÷Zó ðZð ÷\ó ð\ð ÷Tó öTr   r   N)r4   Úabcr   r   Úcollections.abcr   r   Útypingr   r   Útelegram._utils.typesr   Útelegram.ext._utils.typesr	   r   r   r   r   Ú<module>r=      s.   ðñ& Vç #ß /ß å *Ý ,ôr�c˜7 6�?ö rr   