
    ՟f                         d 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 ddlmZ ddlmZ erddlmZ  G d	 d
e
      Z G d de      Z G d de      Z G d de      Zy)z>This module contains objects related to Telegram menu buttons.    )TYPE_CHECKINGDictFinalOptionalType)	constants)TelegramObject)enum)JSONDict)
WebAppInfo)Botc            	       .    e Zd ZU dZdZdddedee   f fdZe		 ddee   d	ed
   ded    f fd       Z
ej                  j                  Zee   ed<   	 ej                  j                   Zee   ed<   	 ej                  j"                  Zee   ed<    xZS )
MenuButtona  This object describes the bot's menu button in a private chat. It should be one of

    * :class:`telegram.MenuButtonCommands`
    * :class:`telegram.MenuButtonWebApp`
    * :class:`telegram.MenuButtonDefault`

    If a menu button other than :class:`telegram.MenuButtonDefault` is set for a private chat,
    then it is applied in the chat. Otherwise the default menu button is applied. By default, the
    menu button opens the list of bot commands.

    Objects of this class are comparable in terms of equality. Two objects of this class are
    considered equal, if their :attr:`type` is equal. For subclasses with additional attributes,
    the notion of equality is overridden.

    .. versionadded:: 20.0

    Args:
        type (:obj:`str`): Type of menu button that the instance represents.

    Attributes:
        type (:obj:`str`): Type of menu button that the instance represents.
    )typeN
api_kwargsr   r   c                    t         |   |       t        j                  t        j
                  ||      | _        | j                  f| _        | j                          y )Nr   )	super__init__r
   
get_memberr   MenuButtonTyper   	_id_attrs_freeze)selfr   r   	__class__s      O/var/www/cvtools/html/venv/lib/python3.12/site-packages/telegram/_menubutton.pyr   zMenuButton.__init__:   sE     	J/)A)A4N	))    databotr   returnc                 H   | j                  |      }|y|s	| t        u ry| j                  t        | j                  t
        | j                  t        i}| t        u r8|j                  d      |v r%||j                  d         j                  ||      S t        | )  ||      S )a1  Converts JSON data to the appropriate :class:`MenuButton` object, i.e. takes
        care of selecting the correct subclass.

        Args:
            data (Dict[:obj:`str`, ...]): The JSON data.
            bot (:class:`telegram.Bot`, optional): The bot associated with this object. Defaults to
                :obj:`None`, in which case shortcut methods will not be available.

                .. versionchanged:: 21.4
                   :paramref:`bot` is now optional and defaults to :obj:`None`

        Returns:
            The Telegram object.

        Nr   )r   r   r   )_parse_datar   COMMANDSMenuButtonCommandsWEB_APPMenuButtonWebAppDEFAULTMenuButtonDefaultgetpopde_jsonr   )clsr   r   _class_mappingr   s       r   r,   zMenuButton.de_jsonG   s    & t$<z) LL,KK)KK*7
 *&!1^!C!$((6"23;;Dc;JJwDc22r   r$   r&   r(   N)__name__
__module____qualname____doc__	__slots__strr   r   r   classmethodr,   r   r   r$   r   __annotations__r&   r(   __classcell__r   s   @r   r   r       s    . I *.	 X&	 >B"3H%"3,4UO"3	,	"3 "3H %33<<HeCj<=#22::GU3Z:<#22::GU3Z:<r   r   c                   8     e Zd ZdZdZdddee   f fdZ xZS )r%   a   Represents a menu button, which opens the bot's list of commands.

    .. include:: inclusions/menu_button_command_video.rst

    .. versionadded:: 20.0
    Attributes:
        type (:obj:`str`): :tg-const:`telegram.constants.MenuButtonType.COMMANDS`.
     Nr   r   c                x    t         |   t        j                  j                  |       | j                          y N)r   r   )r   r   r   r   r$   r   r   r   r   s     r   r   zMenuButtonCommands.__init__   s*    i66??JWr   	r0   r1   r2   r3   r4   r   r   r   r8   r9   s   @r   r%   r%   t   s(     I;? hx&8  r   r%   c            	       x     e Zd ZdZdZdddededee   f fdZ	e
	 dd	ee   d
ed   ded    f fd       Z xZS )r'   aF  Represents a menu button, which launches a
    `Web App <https://core.telegram.org/bots/webapps>`_.

    Objects of this class are comparable in terms of equality. Two objects of this class are
    considered equal, if their :attr:`type`, :attr:`text` and :attr:`web_app`
    are equal.

    .. versionadded:: 20.0

    Args:
        text (:obj:`str`): Text of the button.
        web_app (:class:`telegram.WebAppInfo`): Description of the Web App that will be launched
            when the user presses the button. The Web App will be able to send an arbitrary
            message on behalf of the user using the method :meth:`~telegram.Bot.answerWebAppQuery`
            of :class:`~telegram.Bot`. Alternatively, a ``t.me`` link to a Web App of the bot can
            be specified in the object instead of the Web App's URL, in which case the Web App
            will be opened as if the user pressed the link.


    Attributes:
        type (:obj:`str`): :tg-const:`telegram.constants.MenuButtonType.WEB_APP`.
        text (:obj:`str`): Text of the button.
        web_app (:class:`telegram.WebAppInfo`): Description of the Web App that will be launched
            when the user presses the button. The Web App will be able to send an arbitrary
            message on behalf of the user using the method :meth:`~telegram.Bot.answerWebAppQuery`
            of :class:`~telegram.Bot`. Alternatively, a ``t.me`` link to a Web App of the bot can
            be specified in the object instead of the Web App's URL, in which case the Web App
            will be opened as if the user pressed the link.
    )textweb_appNr   rA   rB   r   c                   t         |   t        j                  j                  |       | j                         5  || _        || _        | j                  | j                  | j                  f| _	        d d d        y # 1 sw Y   y xY wr=   )
r   r   r   r   r&   	_unfrozenrA   rB   r   r   )r   rA   rB   r   r   s       r   r   zMenuButtonWebApp.__init__   sl    i66>>:V^^ 	B!DI'.DL"iiDLLADN		B 	B 	Bs   7A;;Br   r   r   r    c                     | j                  |      }|syt        j                  |j                  d      |      |d<   t        | 	  ||      S )z,See :meth:`telegram.TelegramObject.de_json`.NrB   r"   )r#   r   r,   r*   r   )r-   r   r   r   s      r   r,   zMenuButtonWebApp.de_json   sK    
 t$$,,TXXi-@#FYwDc22r   r/   )r0   r1   r2   r3   r4   r5   r   r   r   r   r6   r,   r8   r9   s   @r   r'   r'      ss    < $I[_ BS B: BhxFX B >B3H%3,4UO3	$	%3 3r   r'   c                   8     e Zd ZdZdZdddee   f fdZ xZS )r)   zDescribes that no specific value for the menu button was set.

    .. versionadded:: 20.0
    Attributes:
        type (:obj:`str`): :tg-const:`telegram.constants.MenuButtonType.DEFAULT`.
    r;   Nr   r   c                x    t         |   t        j                  j                  |       | j                          y r=   )r   r   r   r   r(   r   r>   s     r   r   zMenuButtonDefault.__init__   s*    i66>>:Vr   r?   r9   s   @r   r)   r)      s(     I;? hx&8  r   r)   N)r3   typingr   r   r   r   r   telegramr   telegram._telegramobjectr	   telegram._utilsr
   telegram._utils.typesr   telegram._webappinfor   r   r   r%   r'   r)   r;   r   r   <module>rN      sZ   & E = =  3   * +Q= Q=h "53z 53p
 r   