slack: github.com/rickt/slack Index | Files | Directories

package slack

import "github.com/rickt/slack"

Index

Package Files

api.go attachments.go auth.go channels.go chat.go commons.go endpoints.go files.go groups.go ims.go slack.go team.go usergroups.go users.go webhook.go

type Attachment Uses

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"`

    Fields     []*AttachmentField `json:"fields,omitempty"`
    MarkdownIn []string           `json:"mrkdwn_in,omitempty"`
}

type AttachmentField Uses

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 Uses

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 Uses

type BaseAPIResponse struct {
    Ok    bool   `json:"ok"`
    Error string `json:"error"`
}

type Channel Uses

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

func (*Channel) Purpose Uses

func (ch *Channel) Purpose() (*Purpose, error)

func (*Channel) Topic Uses

func (ch *Channel) Topic() (*Topic, error)

type ChannelsHistoryOpt Uses

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

func (*ChannelsHistoryOpt) Bind Uses

func (opt *ChannelsHistoryOpt) Bind(uv *url.Values) error

type ChannelsHistoryResponse Uses

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 Uses

type ChannelsListAPIResponse struct {
    BaseAPIResponse
    RawChannels json.RawMessage `json:"channels"`
}

response type for `channels.list` api

func (*ChannelsListAPIResponse) Channels Uses

func (res *ChannelsListAPIResponse) Channels() ([]*Channel, error)

Channels returns a slice of channel object from a response of `channels.list` api.

type ChatPostMessageAPIResponse Uses

type ChatPostMessageAPIResponse struct {
    BaseAPIResponse
    Channel string `json:"channel"`
    Ts      string `json:"ts"`
}

response type for `chat.postMessage` api

type ChatPostMessageOpt Uses

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 Uses

type FilesUploadAPIResponse struct {
    Ok    bool   `json:"ok"`
    Error string `json:"error"`
}

response of `files.upload` api

type FilesUploadOpt Uses

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 Uses

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 Uses

type GroupsCreateAPIResponse struct {
    BaseAPIResponse
    RawGroup json.RawMessage `json:"group"`
}

response type for `groups.create` api

func (*GroupsCreateAPIResponse) Group Uses

func (res *GroupsCreateAPIResponse) Group() (*Group, error)

type GroupsListAPIResponse Uses

type GroupsListAPIResponse struct {
    BaseAPIResponse
    RawGroups json.RawMessage `json:"groups"`
}

response type for `groups.list` api

func (*GroupsListAPIResponse) Groups Uses

func (res *GroupsListAPIResponse) Groups() ([]*Group, error)

Groups returns a slice of group object from `groups.list` api.

type Icon Uses

type Icon struct {
    Image34      string `json:"image_34"`
    Image44      string `json:"image_44"`
    Image68      string `json:"image_68"`
    Image88      string `json:"image_88"`
    Image102     string `json:"image_102"`
    Image132     string `json:"image_132"`
    ImageDefault bool   `json:"image_default"`
}

type Im Uses

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 Uses

type ImListAPIResponse struct {
    BaseAPIResponse
    RawIms json.RawMessage `json:"ims"`
}

response type for `im.list` api

func (*ImListAPIResponse) Ims Uses

func (res *ImListAPIResponse) Ims() ([]*Im, error)

Ims returns a slice of im object from `im.list` api.

type Message Uses

type Message struct {
    Type   string `json:"type"`
    Ts     string `json:"ts"`
    UserId string `json:"user"`
    Text   string `json:"text"`
}

func (*Message) Timestamp Uses

func (msg *Message) Timestamp() *time.Time

type ProfileInfo Uses

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 Purpose Uses

type Purpose struct {
    Value   string `json:"value"`
    Creator string `json:"creator"`
    LastSet int    `json:"last_set"`
}

type Slack Uses

type Slack struct {
    // contains filtered or unexported fields
}

func New Uses

func New(token string, ctx context.Context) *Slack

Create a slack client with an API token & an app engine context

func (*Slack) AuthTest Uses

func (sl *Slack) AuthTest() (*AuthTestApiResponse, error)

API auth.test: Checks authentication and tells you who you are.

func (*Slack) ChannelsHistory Uses

func (sl *Slack) ChannelsHistory(opt *ChannelsHistoryOpt) (*ChannelsHistoryResponse, error)

API channels.history: Fetches history of messages and events from a channel.

func (*Slack) ChannelsHistoryMessages Uses

func (sl *Slack) ChannelsHistoryMessages(opt *ChannelsHistoryOpt) ([]*Message, error)

func (*Slack) ChannelsList Uses

func (sl *Slack) ChannelsList() ([]*Channel, error)

API channels.list: Lists all channels in a Slack team.

func (*Slack) ChatPostMessage Uses

func (sl *Slack) ChatPostMessage(channelId string, text string, opt *ChatPostMessageOpt) error

API chat.postMessage: Sends a message to a channel.

func (*Slack) CreateGroup Uses

func (sl *Slack) CreateGroup(name string) error

API groups.create: Creates a private group.

func (*Slack) DoRequest Uses

func (sl *Slack) DoRequest(req *http.Request) ([]byte, error)

func (*Slack) FilesUpload Uses

func (sl *Slack) FilesUpload(opt *FilesUploadOpt) error

API files.upload: Uploads or creates a file.

func (*Slack) FindChannel Uses

func (sl *Slack) FindChannel(cb func(*Channel) bool) (*Channel, error)

FindChannel returns a channel object that satisfy conditions specified.

func (*Slack) FindChannelByName Uses

func (sl *Slack) FindChannelByName(name string) (*Channel, error)

FindChannelByName returns a channel object that matches name specified.

func (*Slack) FindGroup Uses

func (sl *Slack) FindGroup(cb func(*Group) bool) (*Group, error)

FindGroup returns a group object that satisfy conditions specified.

func (*Slack) FindGroupByName Uses

func (sl *Slack) FindGroupByName(name string) (*Group, error)

FindGroupByName returns a group object that matches name specified.

func (*Slack) FindIm Uses

func (sl *Slack) FindIm(cb func(*Im) bool) (*Im, error)

FindIm returns a im object that satisfy conditions specified.

func (*Slack) FindImByName Uses

func (sl *Slack) FindImByName(name string) (*Im, error)

FindImByName returns a im object that matches name specified.

func (*Slack) FindUser Uses

func (sl *Slack) FindUser(cb func(*User) bool) (*User, error)

FindUser returns a user object that satisfy conditions specified.

func (*Slack) FindUserByName Uses

func (sl *Slack) FindUserByName(name string) (*User, error)

FindUserByName returns a user object that matches name specified.

func (*Slack) GetRequest Uses

func (sl *Slack) GetRequest(endpoint string, uv *url.Values) ([]byte, error)

func (*Slack) GetUserPresence Uses

func (sl *Slack) GetUserPresence(name string) (*UserPresence, error)

get user's presence

func (*Slack) GroupsList Uses

func (sl *Slack) GroupsList() ([]*Group, error)

API groups.list: Lists private groups that the calling user has access to.

func (*Slack) ImList Uses

func (sl *Slack) ImList() ([]*Im, error)

API im.list: Lists direct message channels for the calling user.

func (*Slack) InviteGroup Uses

func (sl *Slack) InviteGroup(channelId, userId string) error

API groups.invite: Invites a user to a private group.

func (*Slack) JoinChannel Uses

func (sl *Slack) JoinChannel(name string) error

API channels.join: Joins a channel, creating it if needed.

func (*Slack) PostRequest Uses

func (sl *Slack) PostRequest(endpoint string, uv *url.Values, body *bytes.Buffer) ([]byte, error)

func (*Slack) TeamInfo Uses

func (sl *Slack) TeamInfo() (*TeamInfo, error)

func (*Slack) UserGroupsList Uses

func (sl *Slack) UserGroupsList() (UserGroupData, error)

API usergroups.list: Lists all user groups in a Slack team.

func (*Slack) UsersInfo Uses

func (sl *Slack) UsersInfo(userId string) (*User, error)

API users.info: Gets information about a user.

func (*Slack) UsersList Uses

func (sl *Slack) UsersList() (UserData, error)

API users.list: Lists all users in a Slack team.

type TeamInfo Uses

type TeamInfo struct {
    Id          string `json:"id"`
    Name        string `json:"name"`
    Domain      string `json:"domain"`
    EmailDomain string `json:"email_domain"`
    Icon        *Icon  `json:"icon"`
}

type TeamInfoResponse Uses

type TeamInfoResponse struct {
    BaseAPIResponse
    *TeamInfo `json:"team"`
}

type Topic Uses

type Topic struct {
    Value   string `json:"value"`
    Creator string `json:"creator"`
    LastSet int    `json:"last_set"`
}

type User Uses

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 UserData Uses

type UserData []*User

func (UserData) Len Uses

func (u UserData) Len() int

implement the sort interface

func (UserData) Less Uses

func (u UserData) Less(i, j int) bool

func (UserData) Swap Uses

func (u UserData) Swap(i, j int)

type UserGroup Uses

type UserGroup struct {
    ID          string `json:"id"`
    TeamID      string `json:"team_id"`
    IsUsergroup bool   `json:"is_usergroup"`
    Name        string `json:"name"`
    Description string `json:"description"`
    Handle      string `json:"handle"`
    IsExternal  bool   `json:"is_external"`
    DateCreate  int    `json:"date_create"`
    DateUpdate  int    `json:"date_update"`
    DateDelete  int    `json:"date_delete"`
    AutoType    string `json:"auto_type"`
    CreatedBy   string `json:"created_by"`
    UpdatedBy   string `json:"updated_by"`
    DeletedBy   string `json:"deleted_by"`
    Prefs       struct {
        Channels []string `json:"channels"`
        Groups   []string `json:"groups"`
    }   `json:"prefs,omitempty"`
    Users     []string `json:"users,omitempty"`
    UserCount int      `json:"user_count,omitempty"`
}

type UserGroupData Uses

type UserGroupData []*UserGroup

func (UserGroupData) Len Uses

func (u UserGroupData) Len() int

implement the sort interface

func (UserGroupData) Less Uses

func (u UserGroupData) Less(i, j int) bool

func (UserGroupData) Swap Uses

func (u UserGroupData) Swap(i, j int)

type UserGroupsListAPIResponse Uses

type UserGroupsListAPIResponse struct {
    BaseAPIResponse
    RawGroups json.RawMessage `json:"usergroups"`
}

response type of `usergroups.list` api

func (*UserGroupsListAPIResponse) UserGroups Uses

func (res *UserGroupsListAPIResponse) UserGroups() (UserGroupData, error)

matching func

type UserPresence Uses

type UserPresence struct {
    Ok              string `json:"ok,omitempty"`
    Presence        string `json:"presence,omitempty"`
    Online          bool   `json:"online,omitempty"`
    AutoAway        bool   `json:"auto_away,omitempty"`
    ManualAway      bool   `json:"manual_away,omitempty"`
    ConnectionCount int    `json:"connection_count,omitempty"`
    LastActivity    int64  `json:"last_activity,omitempty"`
}

presence data

type UserPresenceAPIResponse Uses

type UserPresenceAPIResponse struct {
    BaseAPIResponse
    Presence *UserPresence
}

user presence response type of `users.getpresence` api

type UsersInfoAPIResponse Uses

type UsersInfoAPIResponse struct {
    BaseAPIResponse
    User *User `json:"user"`
}

response type of `users.info` api

type UsersListAPIResponse Uses

type UsersListAPIResponse struct {
    BaseAPIResponse
    RawMembers json.RawMessage `json:"members"`
}

response type of `users.list` api

func (*UsersListAPIResponse) Members Uses

func (res *UsersListAPIResponse) Members() (UserData, error)

type WebHook Uses

type WebHook struct {
    // contains filtered or unexported fields
}

func NewWebHook Uses

func NewWebHook(hookURL string) *WebHook

func (*WebHook) PostMessage Uses

func (hk *WebHook) PostMessage(payload *WebHookPostPayload) error

type WebHookPostPayload Uses

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"`
    Attachments []*Attachment `json:"attachments,omitempty"`
}

Directories

PathSynopsis
examples

Package slack imports 15 packages (graph). Updated 2018-03-05. Refresh now. Tools for package owners. This is an inactive package (no imports and no commits in at least two years).