o
    aqe*                     @   s   d dl mZmZ d dlmZmZmZmZ ddlm	Z	m
Z
mZmZ ddlmZmZmZmZmZ G dd de
ZG dd	 d	eZG d
d deZG dd deedZG dd deZG dd deZG dd deZG dd deZG dd deZdS )    )ABCMetaabstractmethod)ListOptionalSetUnion   )EnumValidator
JsonObjectJsonValidatorextract_json)ButtonStylesConfirmObjectDynamicSelectElementTypesOptionOptionGroupc                
       sh   e Zd ZdZh dZddddededee dee fd	d
Zeddd Z	de
f fddZ  ZS )Actionz
    https://api.slack.com/docs/message-attachments#action_fields

    https://api.slack.com/docs/interactive-message-field-guide#message_action_fields
    >   urlnametextNr   r   r   subtyper   r   c                C   s   || _ || _|| _|| _d S N)r   r   r   r   )selfr   r   r   r    r   Z/var/www/html/humari/django-venv/lib/python3.10/site-packages/slack/web/classes/actions.py__init__   s   
zAction.__init__z!name or url attribute is requiredc                 C   s   | j d up	| jd uS r   r   r   r   r   r   name_or_url_present$      zAction.name_or_url_presentreturnc                    s   t   }| j|d< |S )Ntype)superto_dictr   r   json	__class__r   r   r#   (   s   

zAction.to_dict)__name__
__module____qualname____doc__
attributesstrr   r   r   r   dictr#   __classcell__r   r   r&   r   r      s"    

r   c                       s   e Zd Ze fddZdZddddededed	ee d
ee f
 fddZ	e
de ddd Zed
edd Zdef fddZ  ZS )ActionButtonc                    s   t  jddhS )Nstylevaluer"   r,   unionr   r&   r   r   r,   /   s   zActionButton.attributesi  N)confirmr1   r   r   r2   r5   r1   c                   s(   t  j||dd || _|| _|| _dS )aV  
        Simple button for use inside attachments

        https://api.slack.com/docs/message-buttons

        Args:
            name: Name this specific action. The name will be returned to your
                Action URL along with the message's callback_id when this action is
                invoked. Use it to identify this particular response path.
            text: The user-facing label for the message button or menu
                representing this action. Cannot contain markup.
            value: Provide a string identifying this specific action. It will be
                sent to your Action URL along with the name and attachment's
                callback_id . If providing multiple actions with the same name, value
                can be strategically used to differentiate intent. Cannot exceed 2000
                characters.
            confirm: a ConfirmObject that will appear in a dialog to confirm
                user's choice.
            style: Leave blank to indicate that this is an ordinary button. Use
                "primary" or "danger" to mark important buttons.
        button)r   r   r   N)r"   r   r2   r5   r1   )r   r   r   r2   r5   r1   r&   r   r   r   5   s   
zActionButton.__init__zvalue attribute cannot exceed z charactersc                 C   s   t | j| jkS r   )lenr2   value_max_lengthr   r   r   r   value_lengthX      zActionButton.value_lengthc                 C   s   | j d u p	| j tv S r   )r1   r   r   r   r   r   style_valid\   r   zActionButton.style_validr    c                    s(   t   }| jd urt| jd|d< |S )Nactionr5   )r"   r#   r5   r   r$   r&   r   r   r#   `   s   

zActionButton.to_dict)r(   r)   r*   propertyr,   r8   r-   r   r   r   r   r9   r	   r   r;   r.   r#   r/   r   r   r&   r   r0   .   s,    #

r0   c                       s&   e Zd Zdedef fddZ  ZS )ActionLinkButtonr   r   c                   s   t  j||dd dS )z
        A simple interactive button that just opens a URL

        https://api.slack.com/docs/message-attachments#link_buttons

        Args:
          text: text to display on the button, eg 'Click Me!"
          url: the URL to open
        r6   )r   r   r   Nr"   r   )r   r   r   r&   r   r   r   h   s   
zActionLinkButton.__init__)r(   r)   r*   r-   r   r/   r   r   r&   r   r>   g   s    r>   c                       s   e Zd ZeddhZh dZeede	fddZ
ddd	e	d
e	dee f fddZededd Zdef fddZ  ZS )AbstractActionSelectorexternalstatic>   r   r   r!   data_sourcer    c                 C   s   d S r   r   r   r   r   r   rC   z   s   z"AbstractActionSelector.data_sourceNselected_optionr   r   rE   c                   s   t  j||dd || _d S )Nselect)r   r   r   )r"   r   rE   )r   r   r   rE   r&   r   r   r      s   
zAbstractActionSelector.__init__rC   c                 C   s   | j | jv S r   )rC   DataSourceTypesr   r   r   r   data_source_valid   s   z(AbstractActionSelector.data_source_validc                    s*   t   }| jd urt| jgd|d< |S )Nr<   selected_options)r"   r#   rE   r   r$   r&   r   r   r#      s   

zAbstractActionSelector.to_dict)r(   r)   r*   r   r4   rG   r,   r=   r   r-   rC   r   r   r   r	   rH   r.   r#   r/   r   r   r&   r   r@   u   s"    
r@   )	metaclassc                
       sz   e Zd ZdZdZdZdddededeee	e
f  d	ee	 f fd
dZede ddd Zdef fddZ  ZS )ActionStaticSelectorz
    Use the select element for multiple choice selections allowing users to pick a
    single item from a list. True to web roots, this selection is displayed as a
    dropdown menu.

    https://api.slack.com/dialogs#select_elements
    rB   d   NrD   r   r   optionsrE   c                   s   t  j|||d || _dS )a  
        Help users make clear, concise decisions by providing a menu of options
        within messages.

        https://api.slack.com/docs/message-menus

        Args:
            name: Name this specific action. The name will be returned to your
                Action URL along with the message's callback_id when this action is
                invoked. Use it to identify this particular response path.
            text: The user-facing label for the message button or menu
                representing this action. Cannot contain markup.
            options: A list of no mre than 100 Option or OptionGroup objects
            selected_option: An Option object to pre-select as the default
                value.
        r   r   rE   N)r"   r   rM   )r   r   r   rM   rE   r&   r   r   r         
zActionStaticSelector.__init__z options attribute cannot exceed z itemsc                 C   s   t | j| jk S r   )r7   rM   options_max_lengthr   r   r   r   options_length   r:   z#ActionStaticSelector.options_lengthr    c                    sB   t   }t| jd trt| jd|d< |S t| jd|d< |S )Nr   r<   option_groupsrM   )r"   r#   
isinstancerM   r   r   r$   r&   r   r   r#      s   
zActionStaticSelector.to_dict)r(   r)   r*   r+   rC   rP   r-   r   r   r   r   r   r   r   rQ   r.   r#   r/   r   r   r&   r   rK      s"    
rK   c                       4   e Zd ZdZddededee f fddZ  ZS )	ActionUserSelectorusersNr   r   selected_userc                       t  j|||d dS )a  
        Automatically populate the selector with a list of users in the workspace.

        https://api.slack.com/docs/message-menus#allow_users_to_select_from_a_list_of_members

        Args:
            name: Name this specific action. The name will be returned to your
                Action URL along with the message's callback_id when this action is
                invoked. Use it to identify this particular response path.
            text: The user-facing label for the message button or menu
                representing this action. Cannot contain markup.
            selected_user: An Option object to pre-select as the default
                value.
        rN   Nr?   )r   r   r   rW   r&   r   r   r      s   zActionUserSelector.__init__r   	r(   r)   r*   rC   r-   r   r   r   r/   r   r   r&   r   rU          (rU   c                       rT   )	ActionChannelSelectorchannelsNr   r   selected_channelc                    rX   )a  
        Automatically populate the selector with a list of public channels in the
        workspace.

        https://api.slack.com/docs/message-menus#let_users_choose_one_of_their_workspace_s_channels

        Args:
            name: Name this specific action. The name will be returned to your
                Action URL along with the message's callback_id when this action is
                invoked. Use it to identify this particular response path.
            text: The user-facing label for the message button or menu
                representing this action. Cannot contain markup.
            selected_channel: An Option object to pre-select as the default
                value.
        rN   Nr?   )r   r   r   r]   r&   r   r   r      s   zActionChannelSelector.__init__r   rY   r   r   r&   r   r[      rZ   r[   c                       s6   e Zd ZdZ	ddededee f fddZ  ZS )	ActionConversationSelectorconversationsNr   r   selected_conversationc                    rX   )a  
        Automatically populate the selector with a list of conversations they have in
        the workspace.

        https://api.slack.com/docs/message-menus#let_users_choose_one_of_their_conversations

        Args:
            name: Name this specific action. The name will be returned to your
                Action URL along with the message's callback_id when this action is
                invoked. Use it to identify this particular response path.
            text: The user-facing label for the message button or menu
                representing this action. Cannot contain markup.
            selected_conversation: An Option object to pre-select as the default
                value.
        rN   Nr?   )r   r   r   r`   r&   r   r   r      s   z#ActionConversationSelector.__init__r   rY   r   r   r&   r   r^      s    r^   c                
       s\   e Zd ZdZedee f fddZddddeded	ee	 d
ee
 f fddZ  ZS )ActionExternalSelectorrA   r    c                    s   t  jdhS )Nmin_query_lengthr3   r   r&   r   r   r,     r:   z!ActionExternalSelector.attributesN)rE   rb   r   r   rE   rb   c                   s   t  j|||d || _dS )a9  
        Populate a message select menu from your own application dynamically.

        https://api.slack.com/docs/message-menus#populate_message_menus_dynamically

        Args:
            name: Name this specific action. The name will be returned to your
                Action URL along with the message's callback_id when this action is
                invoked. Use it to identify this particular response path.
            text: The user-facing label for the message button or menu
                representing this action. Cannot contain markup.
            selected_option: An Option object to pre-select as the default
                value.
            min_query_length: Specify the number of characters that must be typed
                by a user into a dynamic select menu before dispatching to the app.
        rN   N)r"   r   rb   )r   r   r   rE   rb   r&   r   r   r     rO   zActionExternalSelector.__init__)r(   r)   r*   rC   r=   r   r-   r,   r   r   intr   r/   r   r   r&   r   ra   
  s    ra   N)abcr   r   typingr   r   r   r    r	   r
   r   r   objectsr   r   r   r   r   r   r0   r>   r@   rK   rU   r[   r^   ra   r   r   r   r   <module>   s    	 95