o
    aq×e <  ã                   @   s˜   d dl Z d dlmZmZmZ ddlmZmZmZm	Z	 ddl
mZ ddlmZ h 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dS )é    N)ÚListÚOptionalÚSeté   )ÚEnumValidatorÚ
JsonObjectÚJsonValidatorÚextract_json)ÚAction)ÚBlock>   ÚgoodÚdangerÚwarningc                   @   s<   e Zd Zh d£Zddddœdee dee defdd	„ZdS )
ÚAttachmentField>   ÚshortÚtitleÚvalueNT©r   r   r   r   r   r   c                C   s   || _ || _|| _d S ©Nr   )Úselfr   r   r   © r   ú^/var/www/html/humari/django-venv/lib/python3.10/site-packages/slack/web/classes/attachments.pyÚ__init__   s   
zAttachmentField.__init__)Ú__name__Ú
__module__Ú__qualname__Ú
attributesr   ÚstrÚboolr   r   r   r   r   r      s    ûýüûr   c                "       sz  e Zd ZU h d£Zee ed< ee ed< h d£ZdZ	ddddddddddddddddœde
d	ee
 deee  d
ee
 deee
  dee
 dee
 dee
 dee
 dee
 dee
 dee
 dee
 dee
 dee
 dee f dd„Zede	› dƒdd„ ƒZedƒdd„ ƒZedeƒd d!„ ƒZed"ƒd#d$„ ƒZed%ƒd&d'„ ƒZed(ƒd)d*„ ƒZed+ƒd,d-„ ƒZd.ef‡ fd/d0„Z‡  ZS )1Ú
Attachment>   ÚtsÚtextÚcolorr   ÚfieldsÚfooterÚpretextÚfallbackÚ	image_urlÚ	thumb_urlÚ
title_linkÚauthor_iconÚauthor_linkÚauthor_nameÚfooter_iconr#   Úactions>   r!   r#   r%   i,  N©r&   r#   r"   Úmarkdown_inr   r)   r%   r,   r+   r*   r'   r(   r$   r-   r    r!   r&   r"   r0   r   r)   r%   r,   r+   r*   r'   r(   r$   r-   r    c                C   sl   || _ || _|| _|| _|| _|| _|	| _|
| _|| _|| _	|| _
|| _|| _|| _|p-g | _|p2g | _dS )aë  
        A supplemental object that will display after the rest of the message.
        Considered legacy - recommended replacement is to use message blocks instead.

        https://api.slack.com/reference/messaging/attachments#fields

        Args:
            text: The main body text of the attachment. It can be formatted as
                plain text, or with markdown by including it in the markdown_in
                parameter. The content will automatically collapse if it contains 700+
                characters or 5+ linebreaks, and will display a "Show more..." link to
                expand the content.
            fallback: A plain text summary of the attachment used in clients that
                don't show formatted text (eg. IRC, mobile notifications).
            fields: An array of AttachmentField objects that get displayed in a
                table-like way. For best results, include no more than 2-3 field
                objects.
            color: Changes the color of the border on the left side of this attachment
                from the default gray. Can either be one of "good" (green), "warning"
                (yellow), "danger" (red), or any hex color code (eg. #439FE0)
            markdown_in: An array of field names that should be formatted by
                markdown syntax - allowed values: "pretext", "text", "fields"
            title: Large title text near the top of the attachment.
            title_link: A valid URL that turns the title text into a hyperlink.
            pretext: Text that appears above the message attachment block. It can
                be formatted as plain text, or with markdown by including it in the
                markdown_in parameter.
            author_name: Small text used to display the author's name.
            author_link: A valid URL that will hyperlink the author_name text.
                Will only work if author_name is present.
            author_icon: A valid URL that displays a small 16px by 16px image to
                the left of the author_name text. Will only work if author_name is
                present.
            image_url: A valid URL to an image file that will be displayed at the
                bottom of the attachment. We support GIF, JPEG, PNG, and BMP formats.
                Large images will be resized to a maximum width of 360px or a maximum
                height of 500px, while still maintaining the original aspect ratio.
                Cannot be used with thumb_url.
            thumb_url: A valid URL to an image file that will be displayed as a
                thumbnail on the right side of a message attachment. We currently
                support the following formats: GIF, JPEG, PNG, and BMP. The thumbnail's
                longest dimension will be scaled down to 75px while maintaining the
                aspect ratio of the image. The filesize of the image must also be less
                than 500 KB. For best results, please use images that are already 75px
                by 75px.
            footer: Some brief text to help contextualize and identify an
                attachment. Limited to 300 characters, and may be truncated further when
                displayed to users in environments with limited screen real estate.
            footer_icon: A valid URL to an image file that will be displayed
                beside the footer text. Will only work if footer is present. We'll
                render what you provide at 16px by 16px. It's best to use an image that
                is similarly sized.
            ts: An integer Unix timestamp that is used to related your attachment
                to a specific time. The attachment will display the additional timestamp
                value as part of the attachment's footer. Your message's timestamp will
                be displayed in varying ways, depending on how far in the past or future
                 it is, relative to the present. Form factors, like mobile versus
                 desktop may also transform its rendered appearance.
        N)r!   r   r&   r%   r)   r"   r,   r+   r*   r'   r(   r$   r-   r    r#   r0   )r   r!   r&   r#   r"   r0   r   r)   r%   r,   r+   r*   r'   r(   r$   r-   r    r   r   r   r   4   s    O
zAttachment.__init__zfooter attribute cannot exceed z charactersc                 C   s   | j d u pt| j ƒ| jkS r   )r$   ÚlenÚfooter_max_length©r   r   r   r   Úfooter_length”   s   zAttachment.footer_lengthz<ts attribute cannot be present if footer attribute is absentc                 C   ó   | j d u p	| jd uS r   )r    r$   r3   r   r   r   Úts_without_footer˜   ó   zAttachment.ts_without_footerc                    s    ˆ j  pt‡ fdd„ˆ j D ƒƒS )Nc                 3   s    | ]}|ˆ j v V  qd S r   )ÚMarkdownFields)Ú.0Úer3   r   r   Ú	<genexpr>ž   s   € 

ÿz/Attachment.markdown_in_valid.<locals>.<genexpr>)r0   Úallr3   r   r3   r   Úmarkdown_in_validœ   s   ÿzAttachment.markdown_in_validzHcolor attribute must be 'good', 'warning', 'danger', or a hex color codec                 C   s&   | j d u p| j tv pt d| j tj¡S )Nz^#(?:[0-9A-F]{2}){3}$)r"   ÚSeededColorsÚreÚmatchÚ
IGNORECASEr3   r   r   r   Úcolor_valid¢   s
   
ÿýzAttachment.color_validz?image_url attribute cannot be present if thumb_url is populatedc                 C   s   | j d u p	| jd u S r   )r'   r(   r3   r   r   r   Ú!image_url_and_thumb_url_populated¬   r7   z,Attachment.image_url_and_thumb_url_populatedz'name must be present if link is presentc                 C   r5   r   )r+   r,   r3   r   r   r   Úauthor_link_without_author_name°   r7   z*Attachment.author_link_without_author_namez'icon must be present if link is presentc                 C   r5   r   )r+   r*   r3   r   r   r   Úauthor_link_without_author_icon´   r7   z*Attachment.author_link_without_author_iconÚreturnc                    s6   t ƒ  ¡ }| jd urt| jƒ|d< | jr| j|d< |S )Nr#   Ú	mrkdwn_in)ÚsuperÚto_dictr#   r	   r0   ©r   Újson©Ú	__class__r   r   rI   ¸   s   


zAttachment.to_dict)r   r   r   r   r   r   Ú__annotations__r
   r8   r2   r   r   Úintr   r   r4   r6   r   r=   rB   rC   rD   rE   ÚdictrI   Ú__classcell__r   r   rL   r   r      sŽ   
 îýü
ûú
ùø	÷
öõôóòñðï
î`


ÿ



r   c                       sj   e Zd ZU dhZee ed< ddœdee dee f‡ fdd„Z	e
dƒdd	„ ƒZd
ef‡ fdd„Z‡  ZS )ÚBlockAttachmentr"   ÚblocksN)r"   c                   s   t ƒ jd|d t|ƒ| _dS )a  
        A bridge between legacy attachments and blockkit formatting - pass a list of
        Block objects directly to this attachment.

        https://api.slack.com/reference/messaging/attachments#fields

        Args:
            blocks: a sequence of Block objects

            color: Changes the color of the border on the left side of this
                attachment from the default gray. Can either be one of "good" (green),
                "warning" (yellow), "danger" (red), or any hex color code (eg. #439FE0)
        Ú )r!   r"   N)rH   r   ÚlistrS   )r   rS   r"   rL   r   r   r   Å   s   zBlockAttachment.__init__z7fields attribute cannot be populated on BlockAttachmentc                 C   s   | j  S r   )r#   r3   r   r   r   Úfields_attribute_absentÖ   s   z'BlockAttachment.fields_attribute_absentrF   c                    s(   t ƒ  ¡ }| dt| jƒi¡ |d= |S )NrS   r#   )rH   rI   Úupdater	   rS   rJ   rL   r   r   rI   Ú   s   
zBlockAttachment.to_dict)r   r   r   r   r   r   rN   r   r   r   r   rV   rP   rI   rQ   r   r   rL   r   rR   Á   s   
 $
rR   c                &       s  e Zd Zedee f‡ fdd„ƒZdZddddddddddddddddœdee	 ded	ed
e
e de
ee  de
e de
ee  de
e de
e de
e de
e de
e de
e de
e de
e de
e de
e de
e f$‡ fdd„Zede› dƒdd„ ƒZdef‡ fdd „Z‡  ZS )!ÚInteractiveAttachmentrF   c                    s   t ƒ j dh¡S )NÚcallback_id)rH   r   Úunionr3   rL   r   r   r   â   ó   z InteractiveAttachment.attributesé   Nr/   r.   rY   r!   r&   r#   r"   r0   r   r)   r%   r,   r+   r*   r'   r(   r$   r-   r    c                   s‚   t ƒ jdi d|“d|“d|“d|“d|
“d|	“d|“d|“d	|“d
|“d|“d|“d|“d|“d|“d|“Ž || _|p=g | _dS )a>  
        An Attachment, but designed to contain interactive Actions
        Considered legacy - recommended replacement is to use message blocks instead.

        https://api.slack.com/docs/interactive-message-field-guide#attachment_fields

        https://api.slack.com/reference/messaging/attachments#fields

        Args:
            actions: A collection of Action objects to include in the attachment.
                Cannot exceed 5 elements.
            callback_id: The ID used to identify this attachment. Will be part of the
                payload sent back to your application.
            text: The main body text of the attachment. It can be formatted as
                plain text, or with markdown by including it in the markdown_in
                parameter. The content will automatically collapse if it contains 700+
                characters or 5+ linebreaks, and will display a "Show more..." link to
                expand the content.
            fallback: A plain text summary of the attachment used in clients that
                don't show formatted text (eg. IRC, mobile notifications).
            fields: An array of AttachmentField objects that get displayed in a
                table-like way. For best results, include no more than 2-3 field
                objects.
            color: Changes the color of the border on the left side of this attachment
                from the default gray. Can either be one of "good" (green), "warning"
                (yellow), "danger" (red), or any hex color code (eg. #439FE0)
            markdown_in: An array of field names that should be formatted by
                markdown syntax - allowed values: "pretext", "text", "fields"
            title: Large title text near the top of the attachment.
            title_link: A valid URL that turns the title text into a hyperlink.
            pretext: Text that appears above the message attachment block. It can
                be formatted as plain text, or with markdown by including it in the
                markdown_in parameter.
            author_name: Small text used to display the author's name.
            author_link: A valid URL that will hyperlink the author_name text.
                Will only work if author_name is present.
            author_icon: A valid URL that displays a small 16px by 16px image to
                the left of the author_name text. Will only work if author_name is
                present.
            image_url: A valid URL to an image file that will be displayed at the
                bottom of the attachment. We support GIF, JPEG, PNG, and BMP formats.
                Large images will be resized to a maximum width of 360px or a maximum
                height of 500px, while still maintaining the original aspect ratio.
                Cannot be used with thumb_url.
            thumb_url: A valid URL to an image file that will be displayed as a
                thumbnail on the right side of a message attachment. We currently
                support the following formats: GIF, JPEG, PNG, and BMP. The thumbnail's
                longest dimension will be scaled down to 75px while maintaining the
                aspect ratio of the image. The filesize of the image must also be less
                than 500 KB. For best results, please use images that are already 75px
                by 75px.
            footer: Some brief text to help contextualize and identify an
                attachment. Limited to 300 characters, and may be truncated further when
                displayed to users in environments with limited screen real estate.
            footer_icon: A valid URL to an image file that will be displayed
                beside the footer text. Will only work if footer is present. We'll
                render what you provide at 16px by 16px. It's best to use an image that
                is similarly sized.
            ts: An integer Unix timestamp that is used to related your attachment
                to a specific time. The attachment will display the additional timestamp
                value as part of the attachment's footer. Your message's timestamp will
                be displayed in varying ways, depending on how far in the past or future
                 it is, relative to the present. Form factors, like mobile versus
                 desktop may also transform its rendered appearance.
        r!   r   r&   r#   r%   r)   r"   r,   r+   r*   r'   r(   r$   r-   r    r0   Nr   )rH   r   rY   r.   )r   r.   rY   r!   r&   r#   r"   r0   r   r)   r%   r,   r+   r*   r'   r(   r$   r-   r    rL   r   r   r   è   sF   Wÿþýüûúùø	÷
öõôóòñðzInteractiveAttachment.__init__z actions attribute cannot exceed z	 elementsc                 C   s   t | jƒ| jkS r   )r1   r.   Úactions_max_lengthr3   r   r   r   Úactions_lengthT  r[   z$InteractiveAttachment.actions_lengthc                    s   t ƒ  ¡ }t| jƒ|d< |S )Nr.   )rH   rI   r	   r.   rJ   rL   r   r   rI   X  s   
zInteractiveAttachment.to_dict)r   r   r   Úpropertyr   r   r   r]   r   r
   r   r   rO   r   r   r^   rP   rI   rQ   r   r   rL   r   rX   á   sv    ìýüûú
ùø
	÷
öõôóòñðïîíìl
rX   )r?   Útypingr   r   r   rT   r   r   r   r	   r.   r
   rS   r   r>   r   r   rR   rX   r   r   r   r   Ú<module>   s     ( 