github.com/blend/go-sdk@v1.20220411.3/slack/message.go (about)

     1  /*
     2  
     3  Copyright (c) 2022 - Present. Blend Labs, Inc. All rights reserved
     4  Use of this source code is governed by a MIT license that can be found in the LICENSE file.
     5  
     6  */
     7  
     8  package slack
     9  
    10  // NewMessage creates a new message with a given set of options.
    11  func NewMessage(options ...MessageOption) *Message {
    12  	var m Message
    13  	for _, option := range options {
    14  		option(&m)
    15  	}
    16  	return &m
    17  }
    18  
    19  // Message is a message sent to slack.
    20  type Message struct {
    21  	Username        string              `json:"username,omitempty"`
    22  	Channel         string              `json:"channel,omitempty"`
    23  	Parse           string              `json:"parse,omitempty"`
    24  	ResponseType    string              `json:"response_type,omitempty"`
    25  	Text            string              `json:"text"`
    26  	IconEmoji       string              `json:"icon_emoji,omitempty"`
    27  	IconURL         string              `json:"icon_url,omitempty"`
    28  	ThreadTimestamp string              `json:"thread_ts,omitempty"`
    29  	AsUser          bool                `json:"as_user,omitempty"`
    30  	LinkNames       bool                `json:"link_names"`
    31  	Attachments     []MessageAttachment `json:"attachments"`
    32  
    33  	// Response-specific fields
    34  	BotID     string `json:"bot_id,omitempty"`
    35  	Type      string `json:"type,omitempty"`
    36  	SubType   string `json:"subtype,omitempty"`
    37  	Timestamp string `json:"ts,omitempty"`
    38  }
    39  
    40  // MessageAttachment is an attachment for a message.
    41  type MessageAttachment struct {
    42  	Title      string                   `json:"title,omitempty"`
    43  	Color      string                   `json:"color,omitempty"`
    44  	Pretext    string                   `json:"pretext,omitempty"`
    45  	Text       string                   `json:"text,omitempty"`
    46  	MarkdownIn []string                 `json:"mrkdwn_in,omitempty"`
    47  	Fields     []MessageAttachmentField `json:"fields,omitempty"`
    48  }
    49  
    50  // MessageAttachmentField is a field on an attachment.
    51  type MessageAttachmentField struct {
    52  	Title string `json:"title,omitempty"`
    53  	Value string `json:"value,omitempty"`
    54  	Short bool   `json:"short"`
    55  }