
    > /i                         d Z ddlmZmZ ddlmZ ddlmZ ddlm	Z	m
Z
mZ ddlmZ ddlmZmZ  G d d	eeef         Zy
)z6This module contains the ChatJoinRequestHandler class.    )	FrozenSetOptional)Update)DEFAULT_TRUE)RTSCTDVType)BaseHandler)CCTHandlerCallbackc            
            e Zd ZdZdZddefdeeee	f   de
ee      de
ee      dee   f fdZede
ee      d	ee   fd
       Zede
ee      d	ee   fd       Zded	efdZ xZS )ChatJoinRequestHandlera  Handler class to handle Telegram updates that contain
    :attr:`telegram.Update.chat_join_request`.

    Note:
        If neither of :paramref:`username` and the :paramref:`chat_id` are passed, this handler
        accepts *any* join request. Otherwise, this handler accepts all requests to join chats
        for which the chat ID is listed in :paramref:`chat_id` or the username is listed in
        :paramref:`username`, or both.

        .. versionadded:: 20.0

    Warning:
        When setting :paramref:`block` to :obj:`False`, you cannot rely on adding custom
        attributes to :class:`telegram.ext.CallbackContext`. See its docs for more info.

    .. versionadded:: 13.8

    Args:
        callback (:term:`coroutine function`): The callback function for this handler. Will be
            called when :meth:`check_update` has determined that an update should be processed by
            this handler. Callback signature::

                async def callback(update: Update, context: CallbackContext)

            The return value of the callback is usually ignored except for the special case of
            :class:`telegram.ext.ConversationHandler`.
        chat_id (:obj:`int` | Collection[:obj:`int`], optional): Filters requests to allow only
            those which are asking to join the specified chat ID(s).

            .. versionadded:: 20.0
        username (:obj:`str` | Collection[:obj:`str`], optional): Filters requests to allow only
            those which are asking to join the specified username(s).

            .. versionadded:: 20.0
        block (:obj:`bool`, optional): Determines whether the return value of the callback should
            be awaited before processing the next handler in
            :meth:`telegram.ext.Application.process_update`. Defaults to :obj:`True`.

            .. seealso:: :wiki:`Concurrency`

    Attributes:
        callback (:term:`coroutine function`): The callback function for this handler.
        block (:obj:`bool`): Determines whether the callback will run in a blocking way..

    )	_chat_ids
_usernamesNcallbackchat_idusernameblockc                     t         |   ||       | j                  |      | _        | j	                  |      | _        y )N)r   )super__init___parse_chat_idr   _parse_usernamer   )selfr   r   r   r   	__class__s        Z/srv/sistema/bot/venv/lib/python3.12/site-packages/telegram/ext/_chatjoinrequesthandler.pyr   zChatJoinRequestHandler.__init__R   s;     	/,,W5..x8    returnc                 h    | 
t               S t        | t              rt        | h      S t        |       S )N)	frozenset
isinstanceint)r   s    r   r   z%ChatJoinRequestHandler._parse_chat_id^   s1    ?;gs#gY''!!r   c                     | 
t               S t        | t              r't        | j                  d      r
| dd  h      S | h      S t        | D ch c]  }|j                  d      r|dd  n| c}      S c c}w )N@   )r    r!   str
startswith)r   usrs     r   r   z&ChatJoinRequestHandler._parse_usernamef   su    ;h$h.A.A#.FhqrlUVVHUVVXVcS^^C%8#ab'cAVWWVs   A3updatec                 $   t        |t              r|j                  rt| j                  s| j                  sy|j                  j
                  j                  | j                  v ry|j                  j                  j                  | j                  v ryyy)zDetermines whether an update should be passed to this handler's :attr:`callback`.

        Args:
            update (:class:`telegram.Update` | :obj:`object`): Incoming update.

        Returns:
            :obj:`bool`

        TF)	r!   r   chat_join_requestr   r   chatid	from_userr   )r   r)   s     r   check_updatez#ChatJoinRequestHandler.check_updaten   sn     ff%&*B*B>>$//'',,//4>>A''11::dooMr   )__name__
__module____qualname____doc__	__slots__r   r   r   r   r   r   r   r"   r&   r	   boolr   staticmethodr   r   r   objectr/   __classcell__)r   s   @r   r   r      s    ,\I '+'+*
9!&#r/2
9 #c(#
9 3s8$	
9
 d|
9 "S 2 "y~ " " X(3s8"4 X3 X X6 d r   r   N)r3   typingr   r   telegramr   telegram._utils.defaultvaluer   telegram._utils.typesr   r   r	   telegram.ext._basehandlerr
   telegram.ext._utils.typesr   r   r    r   r   <module>r@      s6   & = &  5 1 1 1 :b[5 br   