Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var NewChatMessageAction = func(jsonAction *json.RawMessage) (common.Action, error) { // Create an Action object from JSON. var action Action err := json.Unmarshal(*jsonAction, &action) if err != nil { return nil, err } client := &http.Client{ Timeout: chatMessageActionTimeout * time.Second, } action.SetHTTPClient(client) return action, nil }
NewChatMessageAction implements the ActionFactory function type. It creates a Chat Message Action based on the given JSON-object, and initializes it by injecting the required HTTP client.
Functions ¶
This section is empty.
Types ¶
type Action ¶
type Action struct { // Common fields and functions for all Actions. common.ActionBase // Webhook where the message will be posted. Provided by the chat application. URL string `json:"url"` // The message that will be posted. Message Message `json:"message"` // contains filtered or unexported fields }
Action implements the common.Action interface. It provides an Action that posts a message to a chat application such as Rocket.Chat, Mattermost, Slack or HipChat. Rocket.Chat-style message payload via a webhook is supported at the moment.
func NewAction ¶
NewAction is a constructor function that makes it easy to create new Chat Message Actions. Note that it does not set the HTTP client - this has to be done with the corresponding setter function.
func (Action) Do ¶
Do Implements common.Action.Do(). It executes the Chat Action by posting the message to the chat application.
func (*Action) SetHTTPClient ¶
func (action *Action) SetHTTPClient(client HTTPClient)
SetHTTPClient allows to inject an HTTP client into the corresponding field.
type Attachment ¶
type Attachment struct { Color *string `json:"color,omitempty"` Text *string `json:"text,omitempty"` Ts *string `json:"ts,omitempty"` ThumbURL *string `json:"thumb_url,omitempty"` MessageLink *string `json:"message_link,omitempty"` Collapsed *bool `json:"collapsed,omitempty"` AuthorName *string `json:"author_name,omitempty"` AuthorLink *string `json:"author_link,omitempty"` AuthorIcon *string `json:"author_icon,omitempty"` Title *string `json:"title,omitempty"` TitleLink *string `json:"title_link,omitempty"` TitleLinkDownload *string `json:"title_link_download,omitempty"` ImageURL *string `json:"image_url,omitempty"` AudioURL *string `json:"audio_url,omitempty"` Fields *[]Field `json:"fields,omitempty"` }
Attachment holds chat message attachments. Implements the structure required by Rocket.Chat. @see https://rocket.chat/docs/developer-guides/rest-api/chat/postmessage
type Field ¶
type Field struct { Short *bool `json:"short,omitempty"` Title *string `json:"title,omitempty"` Value *string `json:"value,omitempty"` }
Field holds chat message attachment fields. Implements the structure required by Rocket.Chat. @see https://rocket.chat/docs/developer-guides/rest-api/chat/postmessage
type HTTPClient ¶
HTTPClient is an interface that is used to allow dependency injection of the HTTP client that makes the request to the Action's URL. Dependency injection is necessary for testing purposes.
type Message ¶
type Message struct { Text *string `json:"text,omitempty"` Alias *string `json:"alias,omitempty"` Emoji *string `json:"emoji,omitempty"` Avatar *string `json:"avatar,omitempty"` Attachments *[]Attachment `json:"attachments,omitempty"` }
Message holds a chat message. Implements the structure required by Rocket.Chat. @see https://rocket.chat/docs/developer-guides/rest-api/chat/postmessage