o
    aqe	                     @   sb   d dl Z d dlmZmZ ddlmZmZmZ ddlm	Z	 ddl
mZ e eZG dd deZdS )	    N)ListOptional   )
JsonObjectJsonValidatorextract_json)
Attachment)Blockc                	       sx   e Zd ZdhZdZdddddedeee  deee	  de
fd	d
Zede ddd Zdef fddZ  ZS )Messagetextd   NT)attachmentsblocksmarkdownr   r   r   c                C   s$   || _ |pg | _|pg | _|| _dS )a  
        Create a message.

        https://api.slack.com/messaging/composing#message-structure

        Args:
            text: Plain or Slack Markdown-like text to display in the message.
            attachments: A list of Attachment objects to display after the rest of
                the message's content. More than 20 is not recommended, but the actual
                limit is 100
            blocks: A list of Block objects to attach to this message. If
                specified, the 'text' property is ignored (more specifically, it's used
                as a fallback on clients that can't render blocks)
            markdown: Whether to parse markdown into formatting such as
                bold/italics, or leave text completely unmodified.
        N)r   r   r   r   )selfr   r   r   r    r   [/var/www/html/humari/django-venv/lib/python3.10/site-packages/slack/web/classes/messages.py__init__   s   


zMessage.__init__z$attachments attribute cannot exceed z itemsc                 C   s   | j d u pt| j | jkS )N)r   lenattachments_max_length)r   r   r   r   attachments_length-   s   
zMessage.attachments_lengthreturnc                    sb   t   }t| jdkrtd | jr| jrtd t| j	|d< t| j|d< | j
|d< |S )Ni@  zDMessages over 40,000 characters are automatically truncated by Slackztext attribute is treated as fallback text if blocks are attached to a message - insert text as a new SectionBlock if you want it to be displayed r   r   mrkdwn)superto_dictr   r   LOGGERerrorr   infor   r   r   )r   json	__class__r   r   r   6   s   

zMessage.to_dict)__name__
__module____qualname__
attributesr   strr   r   r   r	   boolr   r   r   dictr   __classcell__r   r   r   r   r
      s(    




r
   )loggingtypingr   r    r   r   r   r   r   r   r	   	getLoggerr!   r   r
   r   r   r   r   <module>   s    
