slack

package
v0.0.0-...-1fdd0bd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 25, 2018 License: MIT Imports: 3 Imported by: 2

Documentation

Overview

Package slack provides all the Slack specific code for Igor

Package slack provides all the Slack specific code for Igor

Index

Constants

View Source
const ResponseBad = "danger"

ResponseBad returns the color code for negative responses

View Source
const ResponseGood = "good"

ResponseGood returns the color code for positive responses

View Source
const ResponseWarning = "warning"

ResponseWarning returns the color code for warning responses

Variables

This section is empty.

Functions

func EscapeString

func EscapeString(toEscape string) string

EscapeString escapes any values as demanded by Slack This means it HTML escapes '&', '<', and '>' It doesn't double escape. If a string is already escaped it won't do it again. Meaning, if you supply "&amp;" it will return "&amp;"

Types

type Attachment

type Attachment struct {
	Title      string   `json:"title,omitempty"`
	TitleLink  string   `json:"title_link,omitempty"`
	Text       string   `json:"text,omitempty"`
	PreText    string   `json:"pretext,omitempty"`
	Color      string   `json:"color,omitempty"`
	Markdown   []string `json:"mrkdwn_in,omitempty"`
	Fallback   string   `json:"fallback,omitempty"`
	AuthorName string   `json:"author_name,omitempty"`
	AuthorLink string   `json:"author_link,omitempty"`
	AuthorIcon string   `json:"author_icon,omitempty"`
	ImageURL   string   `json:"image_url,omitempty"`
	ThumbURL   string   `json:"thumb_url,omitempty"`
	Fields     []Field  `json:"fields,omitempty"`
}

Attachment contains the fields for a slack attachment

func (*Attachment) AddField

func (a *Attachment) AddField(f Field)

AddField adds a field to the attachment

func (*Attachment) EnableMarkdownFor

func (a *Attachment) EnableMarkdownFor(value string)

EnableMarkdownFor enables Markdown for a part of the attachment

type Field

type Field struct {
	Title string `json:"title"`
	Value string `json:"value"`
	Short bool   `json:"short,omitempty"`
}

Field contains the fields for a field within a slack attachment

type Request

type Request struct {
	Token       string
	TeamID      string
	TeamDomain  string
	ChannelID   string
	ChannelName string
	UserID      string
	UserName    string
	Command     string
	Text        string
	ResponseURL string
}

Request contains the information sent through the request from Slack

func LoadRequestFromQuery

func LoadRequestFromQuery(query string) Request

LoadRequestFromQuery translates the query string sent by Slack into a Request struct

func (*Request) UserInList

func (request *Request) UserInList(list []string) bool

UserInList checks if the request's user is in the provided list

func (*Request) Validate

func (request *Request) Validate(config config.Config) bool

Validate ensures the request comes from the configured Slack team

type Response

type Response struct {
	Text         string       `json:"text"`
	ResponseType string       `json:"response_type,omitempty"`
	Attachments  []Attachment `json:"attachments,omitempty"`
	UnfurlLinks  bool         `json:"unfurl_links,omitempty"`
	UnfurlMedia  bool         `json:"unfurl_media,omitempty"`
	Markdown     bool         `json:"mrkdwn,omitempty"`
	Username     string       `json:"username,omitempty"`
	IconEmoji    string       `json:"icon_emoji,omitempty"`
}

Response contains the fields for returning a response message to Slack

func NothingFoundResponse

func NothingFoundResponse(request Request) Response

NothingFoundResponse is a specific response for when no matching trigger is found

func SomethingWrongResponse

func SomethingWrongResponse(request Request) Response

SomethingWrongResponse is a specific response for when an error occurred

func ValidationErrorResponse

func ValidationErrorResponse() Response

ValidationErrorResponse is a specific response for when validation failed

func (*Response) AddAttachment

func (response *Response) AddAttachment(a Attachment)

AddAttachment adds an attachment to the response

func (*Response) Escape

func (response *Response) Escape()

Escape escapes all values in the Response that need to be escaped

func (*Response) IsPublic

func (response *Response) IsPublic() bool

IsPublic returns whether the response is configured to show up publicly

func (*Response) SetPublic

func (response *Response) SetPublic()

SetPublic configures the response to show up publicly

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL