Documentation ¶
Overview ¶
Example ¶
package main import ( "github.com/kwmt/slack" ) func main() { c := slack.NewClient() c.SetToken("YOUR TOKEN").SetChannel("#general").SetText("こんにちは").PostMessage() }
Output:
Index ¶
- Constants
- func JSON(attachments []Attachment) (string, error)
- type Attachment
- func (attachment *Attachment) SetAuthorIcon(authorIcon string) *Attachment
- func (attachment *Attachment) SetAuthorLink(authorLink string) *Attachment
- func (attachment *Attachment) SetAuthorName(authorName string) *Attachment
- func (attachment *Attachment) SetColor(color string) *Attachment
- func (attachment *Attachment) SetFallback(fallback string) *Attachment
- func (attachment *Attachment) SetFields(fields []Field) *Attachment
- func (attachment *Attachment) SetFooterIcon(icon string) *Attachment
- func (attachment *Attachment) SetFooterText(text string) *Attachment
- func (attachment *Attachment) SetFooterTs(ts int64) *Attachment
- func (attachment *Attachment) SetImageURL(imageUrl string) *Attachment
- func (attachment *Attachment) SetPretext(pretext string) *Attachment
- func (attachment *Attachment) SetText(text string) *Attachment
- func (attachment *Attachment) SetThumbURL(thumbUrl string) *Attachment
- func (attachment *Attachment) SetTitle(title string) *Attachment
- func (attachment *Attachment) SetTitleLink(titleLink string) *Attachment
- type Author
- type Client
- func (c *Client) PostMessage() (*Response, error)
- func (c *Client) SetAsUser(asUser bool) *Client
- func (c *Client) SetAttachments(attachmentsJSON string) *Client
- func (c *Client) SetChannel(channel string) *Client
- func (c *Client) SetIconEmoji(iconEmoji string) *Client
- func (c *Client) SetIconURL(iconURL string) *Client
- func (c *Client) SetLinkNames(linkNames int) *Client
- func (c *Client) SetParse(parse string) *Client
- func (c *Client) SetText(text string) *Client
- func (c *Client) SetToken(token string) *Client
- func (c *Client) SetUnfurlLinks(unfurlLinks bool) *Client
- func (c *Client) SetUnfurlMedia(unfurlMedia bool) *Client
- func (c *Client) SetUserName(name string) *Client
- type Field
- type Footer
- type Message
- type Response
- type Title
Examples ¶
Constants ¶
View Source
const ( COLOR_GOOD = "good" COLOR_WARNING = "warning" COLOR_DANGER = "danger" )
Variables ¶
This section is empty.
Functions ¶
func JSON ¶
func JSON(attachments []Attachment) (string, error)
Types ¶
type Attachment ¶
type Attachment struct { Fallback string `json:"fallback"` Color string `json:"color,omitempty"` Pretext string `json:"pretext,omitempty"` Author Title Text string `json:"text,omitempty"` Fields []Field `json:"fields,omitempty"` ImageUrl string `json:"image_url,omitempty"` ThumbUrl string `json:"thumb_url,omitempty"` }
Example ¶
package main import ( "log" "github.com/kwmt/slack" ) func main() { // https://api.slack.com/docs/message-attachments // [ // { // "fallback": "Required plain-text summary of the attachment.", // "color": "good", // "pretext": "Optional text that appears above the attachment block", // "author_name": "Bobby Tables", // "author_link": "http://flickr.com/bobby/", // "author_icon": "http://flickr.com/icons/bobby.jpg", // "title": "Slack API Documentation", // "title_link": "https://api.slack.com/", // "text": "Optional text that appears within the attachment", // "fields": [ // { // "title": "Priority", // "value": "High", // "short": false // } // ], // "image_url": "http://my-website.com/path/to/image.jpg", // "thumb_url": "http://example.com/path/to/thumb.png", // "footer": "Slack API", // "footer_icon": "https://platform.slack-edge.com/img/default_application_icon.png", // "ts": 123456789 // } // ] fields := slack.NewFields(1) fields[0].SetTitle("Priority").SetValue("High").SetShort(false) attachments := slack.NewAttachments(1) attachments[0].SetFallback("Required plain-text summary of the attachment.").SetColor(slack.COLOR_GOOD).SetPretext( "Optional text that appears above the attachment block", ).SetAuthorName("Bobby Tables").SetAuthorLink("http://flickr.com/bobby/").SetAuthorIcon("http://flickr.com/icons/bobby.jpg").SetTitle( "Slack API Documentatio", ).SetTitleLink("https://api.slack.com/").SetText("Optional text that appears within the attachment").SetFields(fields).SetImageURL( "http://my-website.com/path/to/image.jpg", ).SetThumbURL("http://example.com/path/to/thumb.png").SetFooterText("Slack API").SetFooterIcon( "https://platform.slack-edge.com/img/default_application_icon.png", ).SetFooterTs(123456789) json, err := slack.JSON(attachments) if err != nil { log.Println(err) } c := slack.NewClient() c.SetToken("YOUR TOKEN").SetChannel("#general").SetText("こんにちは").SetAttachments(json).PostMessage() }
Output:
func NewAttachments ¶
func NewAttachments(count int) []Attachment
func (*Attachment) SetAuthorIcon ¶
func (attachment *Attachment) SetAuthorIcon(authorIcon string) *Attachment
func (*Attachment) SetAuthorLink ¶
func (attachment *Attachment) SetAuthorLink(authorLink string) *Attachment
func (*Attachment) SetAuthorName ¶
func (attachment *Attachment) SetAuthorName(authorName string) *Attachment
func (*Attachment) SetColor ¶
func (attachment *Attachment) SetColor(color string) *Attachment
This is able to set value either be one of good, warning, danger, or any hex color code (eg. #439FE0).
func (*Attachment) SetFallback ¶
func (attachment *Attachment) SetFallback(fallback string) *Attachment
func (*Attachment) SetFields ¶
func (attachment *Attachment) SetFields(fields []Field) *Attachment
func (*Attachment) SetFooterIcon ¶
func (attachment *Attachment) SetFooterIcon(icon string) *Attachment
func (*Attachment) SetFooterText ¶
func (attachment *Attachment) SetFooterText(text string) *Attachment
func (*Attachment) SetFooterTs ¶
func (attachment *Attachment) SetFooterTs(ts int64) *Attachment
timestamp
func (*Attachment) SetImageURL ¶
func (attachment *Attachment) SetImageURL(imageUrl string) *Attachment
func (*Attachment) SetPretext ¶
func (attachment *Attachment) SetPretext(pretext string) *Attachment
func (*Attachment) SetText ¶
func (attachment *Attachment) SetText(text string) *Attachment
func (*Attachment) SetThumbURL ¶
func (attachment *Attachment) SetThumbURL(thumbUrl string) *Attachment
func (*Attachment) SetTitle ¶
func (attachment *Attachment) SetTitle(title string) *Attachment
func (*Attachment) SetTitleLink ¶
func (attachment *Attachment) SetTitleLink(titleLink string) *Attachment
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) PostMessage ¶
func (*Client) SetAttachments ¶
func (*Client) SetChannel ¶
func (*Client) SetIconEmoji ¶
func (*Client) SetIconURL ¶
func (*Client) SetLinkNames ¶
func (*Client) SetUnfurlLinks ¶
func (*Client) SetUnfurlMedia ¶
func (*Client) SetUserName ¶
type Field ¶
Click to show internal directories.
Click to hide internal directories.