o
    aqe                     @   sx   d dl Z d dlmZmZ ddl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Z	G dd deZ
dS )    N)List
NamedTuple   )
BaseObjectc                   @   s"   e Zd ZU dZeed< eed< dS )
IDNamePairz2Simple type used to help with unpacking event dataidnameN)__name__
__module____qualname____doc__str__annotations__ r   r   _/var/www/html/humari/django-venv/lib/python3.10/site-packages/slack/web/classes/interactions.pyr      s   
 r   c                   @   sD   e Zd ZU eed< eed< eed< eed< eed< defddZd	S )
InteractiveEventresponse_urluserteamchannel	raw_eventeventc                 C   s   || _ |d | _d S )Nr   )r   r   selfr   r   r   r   __init__   s   zInteractiveEvent.__init__N)r	   r
   r   r   r   r   dictr   r   r   r   r   r      s   
 r   c                       sT   e Zd ZU eed< eed< eed< eed< eed< eed< def fdd	Z  ZS )
MessageInteractiveEvent
event_type
message_ts
trigger_id	action_idblock_idmessager   c                    s   t  | t|d d |d d | _t|d d |d d | _t|d d |d d | _|d | _|d	 d
 | _|d | _|d d }|d | _	|d | _
|dr^|d d | _n|d | _|d	 | _dS )z
        Convenience class to parse an interactive message payload from the events API

        Args:
            event: the raw event dictionary
        r   r   usernamer   domainr   r   typer"   tsr   actionsr   r    r!   selected_optionvalueN)superr   r   r   r   r   r   r   r   r    r!   getr)   r"   )r   r   action	__class__r   r   r   #   s    





z MessageInteractiveEvent.__init__)r	   r
   r   r   r   r   r   __classcell__r   r   r-   r   r      s   
 r   c                       sR   e Zd ZU eed< eed< eed< def fddZdee defd	d
Z  Z	S )DialogInteractiveEventr   
submissionstater   c                    s   t  | t|d d |d d | _t|d d |d d | _t|d d |d d | _|d | _|d | _|d	 | _|d
 rMt	
|d
 | _dS i | _dS )z
        Convenience class to parse a dialog interaction payload from the events API

        Args:
            event: the raw event dictionary
        r   r   r   r   r$   r   callback_idr%   r1   r2   N)r*   r   r   r   r   r   r3   r   r1   jsonloadsr2   r   r-   r   r   r   D   s   



zDialogInteractiveEvent.__init__requirementsreturnc                    sF   t  fdd|D ri S g } jD ]}d}|||d qd|iS )z
        Convenience method to construct the 'errors' response to send directly back to
        the invoking HTTP request

        Args:
          requirements: List of required dialog components, by name
        c                 3   s    | ]
} j |d V  qdS ) N)r1   r+   ).0requirementr   r   r   	<genexpr>_   s    
z5DialogInteractiveEvent.require_any.<locals>.<genexpr>zAt least one value is required)r   errorerrors)anyr1   append)r   r6   r>   key
error_textr   r;   r   require_anyW   s   
z"DialogInteractiveEvent.require_any)
r	   r
   r   r   r   r   r   r   rC   r/   r   r   r-   r   r0   ?   s   
 r0   c                       sP   e Zd ZU eed< eed< eed< def fddZeddefd	d
Z  Z	S )SlashCommandInteractiveEventr   commandtextr   c                    sj   t  | t|d |d | _t|d |d | _t|d |d | _|d | _|d | _|d	 | _d
S )z
        Convenience class to parse a slash command payload from the events API

        Args:
            event: the raw event dictionary
        user_id	user_name
channel_idchannel_nameteam_idteam_domainr   rE   rF   N)	r*   r   r   r   r   r   r   rE   rF   r   r-   r   r   r   p   s   

z%SlashCommandInteractiveEvent.__init__Fr7   c                 C   s   |r| ddS | ddS )aR  
        Create a reply suitable to send directly back to the invoking HTTP request

        Args:
          message: Text to send
          ephemeral: Whether the response should be limited to a single user, or to
                broadcast the reply (_and_ the user's original invocation) to the
                channel publicly
        	ephemeral)rF   response_type
in_channelr   )r"   rM   r   r   r   create_reply   s   

z)SlashCommandInteractiveEvent.create_reply)F)
r	   r
   r   r   r   r   r   staticmethodrP   r/   r   r   r-   r   rD   k   s   
 rD   )r4   typingr   r   r8   r   r   r   r   r0   rD   r   r   r   r   <module>   s    $,