Documentation ¶
Index ¶
- type Attachment
- type AttachmentField
- type AuthTestApiResponse
- type BaseAPIResponse
- type Channel
- type ChannelsHistoryOpt
- type ChannelsHistoryResponse
- type ChannelsListAPIResponse
- type ChatPostMessageAPIResponse
- type ChatPostMessageOpt
- type FilesUploadAPIResponse
- type FilesUploadOpt
- type Group
- type GroupsCreateAPIResponse
- type GroupsListAPIResponse
- type Icon
- type Im
- type ImListAPIResponse
- type Message
- type MpIm
- type MpImListAPIResponse
- type ProfileInfo
- type Purpose
- type Slack
- func (sl *Slack) AuthTest() (*AuthTestApiResponse, error)
- func (sl *Slack) ChannelsHistory(opt *ChannelsHistoryOpt) (*ChannelsHistoryResponse, error)
- func (sl *Slack) ChannelsHistoryMessages(opt *ChannelsHistoryOpt) ([]*Message, error)
- func (sl *Slack) ChannelsList() ([]*Channel, error)
- func (sl *Slack) ChatPostMessage(channelId string, text string, opt *ChatPostMessageOpt) error
- func (sl *Slack) CreateGroup(name string) error
- func (sl *Slack) DoRequest(req *http.Request) ([]byte, error)
- func (sl *Slack) FilesUpload(opt *FilesUploadOpt) (file *UploadedFile, err error)
- func (sl *Slack) FindChannel(cb func(*Channel) bool) (*Channel, error)
- func (sl *Slack) FindChannelByName(name string) (*Channel, error)
- func (sl *Slack) FindFile(id string) (file *UploadedFile, err error)
- func (sl *Slack) FindGroup(cb func(*Group) bool) (*Group, error)
- func (sl *Slack) FindGroupByName(name string) (*Group, error)
- func (sl *Slack) FindIm(cb func(*Im) bool) (*Im, error)
- func (sl *Slack) FindImByName(name string) (*Im, error)
- func (sl *Slack) FindMpIm(cb func(*MpIm) bool) (*MpIm, error)
- func (sl *Slack) FindUser(cb func(*User) bool) (*User, error)
- func (sl *Slack) FindUserByName(name string) (*User, error)
- func (sl *Slack) GetRequest(endpoint string, uv *url.Values) ([]byte, error)
- func (sl *Slack) GroupsList() ([]*Group, error)
- func (sl *Slack) ImList() ([]*Im, error)
- func (sl *Slack) InviteGroup(channelId, userId string) error
- func (sl *Slack) JoinChannel(name string) error
- func (sl *Slack) MpImList() ([]*MpIm, error)
- func (sl *Slack) PostRequest(endpoint string, uv *url.Values, body *bytes.Buffer) ([]byte, error)
- func (sl *Slack) TeamInfo() (*TeamInfo, error)
- func (sl *Slack) UsersInfo(userId string) (*User, error)
- func (sl *Slack) UsersList() ([]*User, error)
- type TeamInfo
- type TeamInfoResponse
- type Topic
- type UploadedFile
- type User
- type UsersInfoAPIResponse
- type UsersListAPIResponse
- type WebHook
- type WebHookPostPayload
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Attachment ¶
type Attachment struct { Color string `json:"color,omitempty"` Fallback string `json:"fallback"` 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"` Text string `json:"text"` ImageURL string `json:"image_url,omitempty"` ThumbURL string `json:"thumb_url,omitempty"` TimeStamp int64 `json:"ts,omitempty"` Fields []*AttachmentField `json:"fields,omitempty"` MarkdownIn []string `json:"mrkdwn_in,omitempty"` }
type AttachmentField ¶
type AttachmentField struct { Title string `json:"title"` Value string `json:"value"` Short bool `json:"short"` }
https://api.slack.com/docs/attachments It is possible to create more richly-formatted messages using Attachments.
type AuthTestApiResponse ¶
type AuthTestApiResponse struct { BaseAPIResponse Url string `json:"url"` Team string `json:"team"` User string `json:"user"` TeamId string `json:"team_id"` UserId string `json:"user_id"` }
response type for `auth.test` api
type BaseAPIResponse ¶
type Channel ¶
type Channel struct { Id string `json:"id"` Name string `json:"name"` IsChannel bool `json:"is_channel"` Created int `json:"created"` Creator string `json:"creator"` IsArchived bool `json:"is_archived"` IsGeneral bool `json:"is_general"` IsMember bool `json:"is_member"` Members []string `json:"members"` RawTopic json.RawMessage `json:"topic"` RawPurpose json.RawMessage `json:"purpose"` NumMembers int `json:"num_members"` }
slack channel type
type ChannelsHistoryOpt ¶
type ChannelsHistoryOpt struct { Channel string `json:"channel"` Latest float64 `json:"latest"` Oldest float64 `json:"oldest"` Inclusive int `json:"inclusive"` Count int `json:"count"` UnReads int `json:"unreads,omitempty"` }
option type for `channels.history` api
type ChannelsHistoryResponse ¶
type ChannelsHistoryResponse struct { BaseAPIResponse Latest float64 `json:"latest"` Messages []*Message `json:"messages"` HasMore bool `json:"has_more"` UnReadCountDisplay int `json:"unread_count_display"` }
response type for `channels.history` api
type ChannelsListAPIResponse ¶
type ChannelsListAPIResponse struct { BaseAPIResponse RawChannels json.RawMessage `json:"channels"` }
response type for `channels.list` api
func (*ChannelsListAPIResponse) Channels ¶
func (res *ChannelsListAPIResponse) Channels() ([]*Channel, error)
Channels returns a slice of channel object from a response of `channels.list` api.
type ChatPostMessageAPIResponse ¶
type ChatPostMessageAPIResponse struct { BaseAPIResponse Channel string `json:"channel"` Ts string `json:"ts"` }
response type for `chat.postMessage` api
type ChatPostMessageOpt ¶
type ChatPostMessageOpt struct { AsUser bool Username string Parse string LinkNames string Attachments []*Attachment UnfurlLinks string UnfurlMedia string IconUrl string IconEmoji string }
option type for `chat.postMessage` api
type FilesUploadAPIResponse ¶
type FilesUploadAPIResponse struct { Ok bool `json:"ok"` Error string `json:"error"` File UploadedFile `json:"file"` }
response of `files.upload` api
type FilesUploadOpt ¶
type FilesUploadOpt struct { Content string Filepath string Filetype string Filename string Title string InitialComment string Channels []string }
option type for `files.upload` api
type Group ¶
type Group struct { Id string `json:"id"` Name string `json:"name"` Created int `json:"created"` Creator string `json:"creator"` IsArchived bool `json:"is_archived"` Members []string `json:"members"` RawTopic json.RawMessage `json:"topic"` RawPurpose json.RawMessage `json:"purpose"` }
slack group type
type GroupsCreateAPIResponse ¶
type GroupsCreateAPIResponse struct { BaseAPIResponse RawGroup json.RawMessage `json:"group"` }
response type for `groups.create` api
func (*GroupsCreateAPIResponse) Group ¶
func (res *GroupsCreateAPIResponse) Group() (*Group, error)
type GroupsListAPIResponse ¶
type GroupsListAPIResponse struct { BaseAPIResponse RawGroups json.RawMessage `json:"groups"` }
response type for `groups.list` api
func (*GroupsListAPIResponse) Groups ¶
func (res *GroupsListAPIResponse) Groups() ([]*Group, error)
Groups returns a slice of group object from `groups.list` api.
type Im ¶
type Im struct { Id string `json:"id"` Isim bool `json:"is_im"` User string `json:"user"` Created int `json:"created"` IsUserDeleted bool `json:"is_user_deleted"` }
slack im type
type ImListAPIResponse ¶
type ImListAPIResponse struct { BaseAPIResponse RawIms json.RawMessage `json:"ims"` }
response type for `im.list` api
func (*ImListAPIResponse) Ims ¶
func (res *ImListAPIResponse) Ims() ([]*Im, error)
Ims returns a slice of im object from `im.list` api.
type Message ¶
type MpIm ¶
type MpIm struct { Id string `json:"id"` Name string `json:"name"` Created int64 `json:"created"` Creator string `json:"creator"` IsArchived bool `json:"is_archived"` IsMpim bool `json:"is_mpim"` Members []string `json:"members"` RawTopic json.RawMessage `json:"topic"` RawPurpose json.RawMessage `json:"purpose"` }
slack mpim type
type MpImListAPIResponse ¶
type MpImListAPIResponse struct { BaseAPIResponse RawMpIms json.RawMessage `json:"groups"` }
response type for `im.list` api
func (*MpImListAPIResponse) MpIms ¶
func (res *MpImListAPIResponse) MpIms() ([]*MpIm, error)
MpIms returns a slice of mpim object from `mpim.list` api.
type ProfileInfo ¶
type ProfileInfo struct { FirstName string `json:"first_name"` LastName string `json:"last_name"` RealName string `json:"real_name"` Email string `json:"email"` Skype string `json:"skype"` Phone string `json:"phone"` Image24 string `json:"image_24"` Image32 string `json:"image_32"` Image48 string `json:"image_48"` Image72 string `json:"image_72"` Image192 string `json:"image_192"` }
slack user profile type
type Slack ¶
type Slack struct {
// contains filtered or unexported fields
}
func (*Slack) AuthTest ¶
func (sl *Slack) AuthTest() (*AuthTestApiResponse, error)
API auth.test: Checks authentication and tells you who you are.
func (*Slack) ChannelsHistory ¶
func (sl *Slack) ChannelsHistory(opt *ChannelsHistoryOpt) (*ChannelsHistoryResponse, error)
API channels.history: Fetches history of messages and events from a channel.
func (*Slack) ChannelsHistoryMessages ¶
func (sl *Slack) ChannelsHistoryMessages(opt *ChannelsHistoryOpt) ([]*Message, error)
func (*Slack) ChannelsList ¶
API channels.list: Lists all channels in a Slack team.
func (*Slack) ChatPostMessage ¶
func (sl *Slack) ChatPostMessage(channelId string, text string, opt *ChatPostMessageOpt) error
API chat.postMessage: Sends a message to a channel.
func (*Slack) CreateGroup ¶
API groups.create: Creates a private group.
func (*Slack) FilesUpload ¶
func (sl *Slack) FilesUpload(opt *FilesUploadOpt) (file *UploadedFile, err error)
API files.upload: Uploads or creates a file.
func (*Slack) FindChannel ¶
FindChannel returns a channel object that satisfy conditions specified.
func (*Slack) FindChannelByName ¶
FindChannelByName returns a channel object that matches name specified.
func (*Slack) FindFile ¶
func (sl *Slack) FindFile(id string) (file *UploadedFile, err error)
API files.info: Retrieves information about a specified uploaded file.
func (*Slack) FindGroupByName ¶
FindGroupByName returns a group object that matches name specified.
func (*Slack) FindImByName ¶
FindImByName returns a im object that matches name specified.
func (*Slack) FindUserByName ¶
FindUserByName returns a user object that matches name specified.
func (*Slack) GetRequest ¶
func (*Slack) GroupsList ¶
API groups.list: Lists private groups that the calling user has access to.
func (*Slack) InviteGroup ¶
API groups.invite: Invites a user to a private group.
func (*Slack) JoinChannel ¶
API channels.join: Joins a channel, creating it if needed.
func (*Slack) MpImList ¶
API mpim.list: Lists multiparty direct message channels for the calling user.
func (*Slack) PostRequest ¶
type TeamInfoResponse ¶
type TeamInfoResponse struct { BaseAPIResponse *TeamInfo `json:"team"` }
type UploadedFile ¶
type UploadedFile struct { ID string `json:"id"` Title string `json:"title"` Name string `json:"name"` MimeType string `json:"mimetype"` FileType string `json:"filetype"` User string `json:"user"` PrivateUrl string `json:"url_private"` PrivateDownloadUrl string `json:"url_private_download"` Permalink string `json:"permalink"` PublicPermalink string `json:"permalink_public"` }
type User ¶
type User struct { Id string `json:"id"` Name string `json:"name"` Deleted bool `json:"deleted"` Color string `json:"color"` Profile *ProfileInfo IsAdmin bool `json:"is_admin"` IsOwner bool `json:"is_owner"` Has2fa bool `json:"has_2fa"` HasFiles bool `json:"has_files"` }
slack user type
type UsersInfoAPIResponse ¶
type UsersInfoAPIResponse struct { BaseAPIResponse User *User `json:"user"` }
response type of `users.info` api
type UsersListAPIResponse ¶
type UsersListAPIResponse struct { BaseAPIResponse RawMembers json.RawMessage `json:"members"` }
response type of `users.list` api
func (*UsersListAPIResponse) Members ¶
func (res *UsersListAPIResponse) Members() ([]*User, error)
type WebHook ¶
type WebHook struct {
// contains filtered or unexported fields
}
func NewWebHook ¶
func (*WebHook) PostMessage ¶
func (hk *WebHook) PostMessage(payload *WebHookPostPayload) error
type WebHookPostPayload ¶
type WebHookPostPayload struct { Text string `json:"text,omitempty"` Channel string `json:"channel,omitempty"` Username string `json:"username,omitempty"` IconUrl string `json:"icon_url,omitempty"` IconEmoji string `json:"icon_emoji,omitempty"` UnfurlLinks bool `json:"unfurl_links,omitempty"` LinkNames string `json:"link_names,omitempty"` Attachments []*Attachment `json:"attachments,omitempty"` }