slackim

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2017 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Code

func Code(text interface{}) string

Code returns the text enclosed with the code marker (```)

```
text
```
func Hyperlink(text, url string) string

Hyperlink returns the string for encoding the text with the given url hyperlink

func Monospace

func Monospace(text interface{}) string

Monospace returns text enclosed with the monospace marker('):

`text`

Types

type Attachment

type Attachment struct {
	BasicMessage

	MarkdownIn []string `json:"mrkdwn_in,omitemptys"`
	Fallback   string   `json:"fallback"`          // Required plain-text summary of the attachment
	Color      string   `json:"color,omitempty"`   // Sidebar colour
	Pretext    string   `json:"pretext,omitempty"` // Optional text that appears above the attachment block
	Fields     []*Field `json:"fields,omitempty"`
	Timestamp  int64    `json:"ts"`
	// contains filtered or unexported fields
}

Attachment is the attachment type for AttachmentMessage

func NewAttachment

func NewAttachment(fallbackText string) *Attachment

NewAttachment begins a new attachment

func (*Attachment) AddField

func (a *Attachment) AddField(title, value string, short bool, containsMarkdown bool) *Attachment

AddField adds a new field to the struct

func (*Attachment) SetAllFieldsShort

func (a *Attachment) SetAllFieldsShort() *Attachment

SetAllFieldsShort sets all Fields' "short" value to true, making the Fields display horizontally

func (*Attachment) SetAuthor

func (a *Attachment) SetAuthor(name, link, icon string, containsMarkdown bool) *Attachment

SetAuthor displays a small section at the top of a message attachment with author information.

name : Small text used to display the author's name.
link : A valid URL that will hyperlink the author_name text mentioned above. Will only work if author_name is present.
icon : A valid URL that displays a small 16x16px image to the left of the author_name text. Will only work if author_name is present.

func (*Attachment) SetColor

func (a *Attachment) SetColor(color string) *Attachment

SetColor sets the Color of the border along the left side of the message attachment. The input can either be one of "good", "warning", "danger", or any hex color code (eg. #439FE0).

func (*Attachment) SetFooter

func (a *Attachment) SetFooter(text, iconURL string) *Attachment

SetFooter sets the smaller, light text near the bottom of a message attachment. By passing a valid icon URL in the iconURL parameter, an icon will be displayed beside the text.

func (*Attachment) SetImage

func (a *Attachment) SetImage(imageURL string) *Attachment

SetImage sets an image to be displayed inside a message attachment.

func (*Attachment) SetPretext

func (a *Attachment) SetPretext(text string, containsMarkdown bool) *Attachment

SetPretext sets the optional text that appears above the message attachment block.

func (*Attachment) SetThumbnail

func (a *Attachment) SetThumbnail(thumbnailURL string) *Attachment

SetThumbnail sets an thumbnail image to be displayed on the right side, within a message attachment.

func (*Attachment) SetTitle

func (a *Attachment) SetTitle(title, link string, containsMarkdown bool) *Attachment

SetTitle sets the larger, bold text near the top of a message attachment. By passing a valid URL in the link parameter, the title text will be hyperlinked.

type AttachmentMessage

type AttachmentMessage struct {
	Attachments []*Attachment `json:"attachments"`
	Channel     string        `json:"channel"`
}

AttachmentMessage is the top-level message type for attachments

func NewAttachmentMessage

func NewAttachmentMessage() *AttachmentMessage

NewAttachmentMessage returns a new AttachmentMessage

func (*AttachmentMessage) Add

func (a *AttachmentMessage) Add(attachment ...*Attachment) *AttachmentMessage

Add adds attachments to the AttachmentMessage

func (*AttachmentMessage) Send

func (a *AttachmentMessage) Send(url string) (*http.Response, error)

Send performs the HTTP POST request for the given message

func (*AttachmentMessage) SendToChannel added in v0.5.0

func (a *AttachmentMessage) SendToChannel(url, channel string) (*http.Response, error)

SendToChannel performs the HTTP POST request for the given message

type BasicMessage

type BasicMessage struct {
	Text    string `json:"text"`
	Channel string `json:"channel,omitempty"`
}

BasicMessage is the top-level message type for attachments

func NewBasicMessage

func NewBasicMessage(text string) *BasicMessage

NewBasicMessage returns a new BasicMessage

func (*BasicMessage) Send

func (b *BasicMessage) Send(url string) (*http.Response, error)

Send performs the HTTP POST request for the given message

func (*BasicMessage) SendToChannel added in v0.5.0

func (b *BasicMessage) SendToChannel(url, channel string) (*http.Response, error)

SendToChannel performs the HTTP POST request for the given message

type Field

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

Field is the field type contained in an attachment

type Message

type Message interface {
	Send(url string) (*http.Response, error)
}

Message is the standard message interface

Jump to

Keyboard shortcuts

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