matterbridge/vendor/github.com/slack-go/slack/attachments.go

94 lines
4.3 KiB
Go
Raw Normal View History

2016-09-05 16:34:37 +02:00
package slack
2016-11-06 00:07:24 +01:00
import "encoding/json"
2016-09-05 16:34:37 +02:00
// AttachmentField contains information for an attachment field
// An Attachment can contain multiple of these
type AttachmentField struct {
Title string `json:"title"`
Value string `json:"value"`
Short bool `json:"short"`
}
2017-07-16 14:29:46 +02:00
// AttachmentAction is a button or menu to be included in the attachment. Required when
// using message buttons or menus and otherwise not useful. A maximum of 5 actions may be
2016-09-05 16:34:37 +02:00
// provided per attachment.
type AttachmentAction struct {
2017-07-16 14:29:46 +02:00
Name string `json:"name"` // Required.
Text string `json:"text"` // Required.
Style string `json:"style,omitempty"` // Optional. Allowed values: "default", "primary", "danger".
2019-09-07 22:46:58 +02:00
Type actionType `json:"type"` // Required. Must be set to "button" or "select".
2017-07-16 14:29:46 +02:00
Value string `json:"value,omitempty"` // Optional.
DataSource string `json:"data_source,omitempty"` // Optional.
MinQueryLength int `json:"min_query_length,omitempty"` // Optional. Default value is 1.
Options []AttachmentActionOption `json:"options,omitempty"` // Optional. Maximum of 100 options can be provided in each menu.
SelectedOptions []AttachmentActionOption `json:"selected_options,omitempty"` // Optional. The first element of this array will be set as the pre-selected option for this menu.
OptionGroups []AttachmentActionOptionGroup `json:"option_groups,omitempty"` // Optional.
Confirm *ConfirmationField `json:"confirm,omitempty"` // Optional.
2018-01-08 22:41:38 +01:00
URL string `json:"url,omitempty"` // Optional.
2017-07-16 14:29:46 +02:00
}
2019-09-07 22:46:58 +02:00
// actionType returns the type of the action
func (a AttachmentAction) actionType() actionType {
return a.Type
}
2017-07-16 14:29:46 +02:00
// AttachmentActionOption the individual option to appear in action menu.
type AttachmentActionOption struct {
Text string `json:"text"` // Required.
Value string `json:"value"` // Required.
Description string `json:"description,omitempty"` // Optional. Up to 30 characters.
}
// AttachmentActionOptionGroup is a semi-hierarchal way to list available options to appear in action menu.
type AttachmentActionOptionGroup struct {
Text string `json:"text"` // Required.
Options []AttachmentActionOption `json:"options"` // Required.
2016-09-05 16:34:37 +02:00
}
// AttachmentActionCallback is sent from Slack when a user clicks a button in an interactive message (aka AttachmentAction)
2018-12-01 19:55:35 +01:00
// DEPRECATED: use InteractionCallback
type AttachmentActionCallback InteractionCallback
2016-09-05 16:34:37 +02:00
// ConfirmationField are used to ask users to confirm actions
type ConfirmationField struct {
Title string `json:"title,omitempty"` // Optional.
Text string `json:"text"` // Required.
OkText string `json:"ok_text,omitempty"` // Optional. Defaults to "Okay"
DismissText string `json:"dismiss_text,omitempty"` // Optional. Defaults to "Cancel"
}
// Attachment contains all the information for an attachment
type Attachment struct {
Color string `json:"color,omitempty"`
Fallback string `json:"fallback,omitempty"`
2016-09-05 16:34:37 +02:00
CallbackID string `json:"callback_id,omitempty"`
2018-08-10 00:38:19 +02:00
ID int `json:"id,omitempty"`
2016-09-05 16:34:37 +02:00
2018-08-10 00:38:19 +02:00
AuthorID string `json:"author_id,omitempty"`
2016-09-05 16:34:37 +02:00
AuthorName string `json:"author_name,omitempty"`
AuthorSubname string `json:"author_subname,omitempty"`
AuthorLink string `json:"author_link,omitempty"`
AuthorIcon string `json:"author_icon,omitempty"`
Title string `json:"title,omitempty"`
TitleLink string `json:"title_link,omitempty"`
Pretext string `json:"pretext,omitempty"`
2020-12-31 14:48:12 +01:00
Text string `json:"text,omitempty"`
2016-09-05 16:34:37 +02:00
ImageURL string `json:"image_url,omitempty"`
ThumbURL string `json:"thumb_url,omitempty"`
Fields []AttachmentField `json:"fields,omitempty"`
Actions []AttachmentAction `json:"actions,omitempty"`
MarkdownIn []string `json:"mrkdwn_in,omitempty"`
Blocks Blocks `json:"blocks,omitempty"`
2019-12-07 22:54:36 +01:00
2016-09-05 16:34:37 +02:00
Footer string `json:"footer,omitempty"`
FooterIcon string `json:"footer_icon,omitempty"`
2016-11-06 00:07:24 +01:00
Ts json.Number `json:"ts,omitempty"`
2016-09-05 16:34:37 +02:00
}