slack

package
v0.0.0-...-eee6093 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2019 License: BSD-2-Clause, MIT Imports: 23 Imported by: 0

README

Slack API in Go GoDoc Build Status

This library supports most if not all of the api.slack.com REST calls, as well as the Real-Time Messaging protocol over websocket, in a fully managed way.

Note: If you just updated from master and it broke your implementation, please check 0.0.1

Installing

go get
$ go get github.com/nlopes/slack

Example

Getting all groups
import (
	"fmt"

	"github.com/nlopes/slack"
)

func main() {
	api := slack.New("YOUR_TOKEN_HERE")
	// If you set debugging, it will log all requests to the console
	// Useful when encountering issues
	// api.SetDebug(true)
	groups, err := api.GetGroups(false)
	if err != nil {
		fmt.Printf("%s\n", err)
		return
	}
	for _, group := range groups {
		fmt.Printf("ID: %s, Name: %s\n", group.ID, group.Name)
	}
}
Getting User Information
import (
    "fmt"

    "github.com/nlopes/slack"
)

func main() {
    api := slack.New("YOUR_TOKEN_HERE")
    user, err := api.GetUserInfo("U023BECGF")
    if err != nil {
	    fmt.Printf("%s\n", err)
	    return
    }
    fmt.Printf("ID: %s, Fullname: %s, Email: %s\n", user.ID, user.Profile.RealName, user.Profile.Email)
}

Minimal RTM usage:

See https://github.com/nlopes/slack/blob/master/examples/websocket/websocket.go

Contributing

You are more than welcome to contribute to this project. Fork and make a Pull Request, or create an Issue if you see any problem.

License

BSD 2 Clause license

Documentation

Index

Constants

View Source
const (
	DEFAULT_MESSAGE_USERNAME     = ""
	DEFAULT_MESSAGE_ASUSER       = false
	DEFAULT_MESSAGE_PARSE        = ""
	DEFAULT_MESSAGE_LINK_NAMES   = 0
	DEFAULT_MESSAGE_UNFURL_LINKS = false
	DEFAULT_MESSAGE_UNFURL_MEDIA = true
	DEFAULT_MESSAGE_ICON_URL     = ""
	DEFAULT_MESSAGE_ICON_EMOJI   = ""
	DEFAULT_MESSAGE_MARKDOWN     = true
	DEFAULT_MESSAGE_ESCAPE_TEXT  = true
)
View Source
const (
	// Add here the defaults in the siten
	DEFAULT_FILES_USER    = ""
	DEFAULT_FILES_TS_FROM = 0
	DEFAULT_FILES_TS_TO   = -1
	DEFAULT_FILES_TYPES   = "all"
	DEFAULT_FILES_COUNT   = 100
	DEFAULT_FILES_PAGE    = 1
)
View Source
const (
	DEFAULT_HISTORY_LATEST    = ""
	DEFAULT_HISTORY_OLDEST    = "0"
	DEFAULT_HISTORY_COUNT     = 100
	DEFAULT_HISTORY_INCLUSIVE = false
)
View Source
const (
	TYPE_MESSAGE      = "message"
	TYPE_FILE         = "file"
	TYPE_FILE_COMMENT = "file_comment"
	TYPE_CHANNEL      = "channel"
	TYPE_IM           = "im"
	TYPE_GROUP        = "group"
)
View Source
const (
	DEFAULT_REACTIONS_USER  = ""
	DEFAULT_REACTIONS_COUNT = 100
	DEFAULT_REACTIONS_PAGE  = 1
	DEFAULT_REACTIONS_FULL  = false
)
View Source
const (
	DEFAULT_SEARCH_SORT      = "score"
	DEFAULT_SEARCH_SORT_DIR  = "desc"
	DEFAULT_SEARCH_HIGHLIGHT = false
	DEFAULT_SEARCH_COUNT     = 100
	DEFAULT_SEARCH_PAGE      = 1
)
View Source
const (
	DEFAULT_STARS_USER  = ""
	DEFAULT_STARS_COUNT = 100
	DEFAULT_STARS_PAGE  = 1
)
View Source
const (
	// MaxMessageTextLength is the current maximum message length in number of characters as defined here
	// https://api.slack.com/rtm#limits
	MaxMessageTextLength = 4000
)

Variables

View Source
var SLACK_API string = "https://slack.com/api/"

Added as a var so that we can change this for testing purposes

View Source
var SLACK_WEB_API_FORMAT string = "https://%s.slack.com/api/users.admin.%s?t=%s"

Functions

func GetOAuthToken

func GetOAuthToken(clientID, clientSecret, code, redirectURI string, debug bool) (accessToken string, scope string, err error)

GetOAuthToken retrieves an AccessToken

Types

type AccountsChangedEvent

type AccountsChangedEvent struct {
	Type string `json:"type"`
}

AccountsChangedEvent represents the accounts changed event

type AckErrorEvent

type AckErrorEvent struct {
	ErrorObj error
}

AckErrorEvent i

func (*AckErrorEvent) Error

func (a *AckErrorEvent) Error() string

type AckMessage

type AckMessage struct {
	ReplyTo   int    `json:"reply_to"`
	Timestamp string `json:"ts"`
	Text      string `json:"text"`
	RTMResponse
}

AckMessage is used for messages received in reply to other messages

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

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

Attachment contains all the information for an attachment

type AttachmentField

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

AttachmentField contains information for an attachment field An Attachment can contain multiple of these

type AuthTestResponse

type AuthTestResponse struct {
	URL    string `json:"url"`
	Team   string `json:"team"`
	User   string `json:"user"`
	TeamID string `json:"team_id"`
	UserID string `json:"user_id"`
}

type Bot

type Bot struct {
	ID      string `json:"id"`
	Name    string `json:"name"`
	Deleted bool   `json:"deleted"`
	Icons   Icons  `json:"icons"`
}

Bot contains information about a bot

type BotAddedEvent

type BotAddedEvent struct {
	Type string `json:"type"`
	Bot  Bot    `json:"bot"`
}

BotAddedEvent represents the bot added event

type BotChangedEvent

type BotChangedEvent struct {
	Type string `json:"type"`
	Bot  Bot    `json:"bot"`
}

BotChangedEvent represents the bot changed event

type Channel

type Channel struct {
	IsChannel bool `json:"is_channel"`
	IsGeneral bool `json:"is_general"`
	IsMember  bool `json:"is_member"`
	// contains filtered or unexported fields
}

Channel contains information about the channel

type ChannelArchiveEvent

type ChannelArchiveEvent ChannelInfoEvent

ChannelArchiveEvent represents the Channel archive event

type ChannelCreatedEvent

type ChannelCreatedEvent struct {
	Type           string             `json:"type"`
	Channel        ChannelCreatedInfo `json:"channel"`
	EventTimestamp JSONTimeString     `json:"event_ts"`
}

ChannelCreatedEvent represents the Channel created event

type ChannelCreatedInfo

type ChannelCreatedInfo struct {
	ID        string `json:"id"`
	IsChannel bool   `json:"is_channel"`
	Name      string `json:"name"`
	Created   int    `json:"created"`
	Creator   string `json:"creator"`
}

ChannelCreatedInfo represents the information associated with the Channel created event

type ChannelDeletedEvent

type ChannelDeletedEvent ChannelInfoEvent

ChannelDeletedEvent represents the Channel deleted event

type ChannelHistoryChangedEvent

type ChannelHistoryChangedEvent struct {
	Type           string         `json:"type"`
	Latest         JSONTimeString `json:"latest"`
	Timestamp      JSONTimeString `json:"ts"`
	EventTimestamp JSONTimeString `json:"event_ts"`
}

ChannelHistoryChangedEvent represents the Channel history changed event

type ChannelInfoEvent

type ChannelInfoEvent struct {
	// channel_left
	// channel_deleted
	// channel_archive
	// channel_unarchive
	Type      string          `json:"type"`
	Channel   string          `json:"channel"`
	User      string          `json:"user,omitempty"`
	Timestamp *JSONTimeString `json:"ts,omitempty"`
}

ChannelInfoEvent represents the Channel info event

type ChannelJoinedEvent

type ChannelJoinedEvent struct {
	Type    string  `json:"type"`
	Channel Channel `json:"channel"`
}

ChannelJoinedEvent represents the Channel joined event

type ChannelLeftEvent

type ChannelLeftEvent ChannelInfoEvent

ChannelLeftEvent represents the Channel left event

type ChannelMarkedEvent

type ChannelMarkedEvent ChannelInfoEvent

ChannelMarkedEvent represents the Channel marked event

type ChannelRenameEvent

type ChannelRenameEvent struct {
	Type      string            `json:"type"`
	Channel   ChannelRenameInfo `json:"channel"`
	Timestamp string            `json:"event_ts"`
}

ChannelRenameEvent represents the Channel rename event

type ChannelRenameInfo

type ChannelRenameInfo struct {
	ID      string          `json:"id"`
	Name    string          `json:"name"`
	Created *JSONTimeString `json:"created"`
}

ChannelRenameInfo represents the information associated with a Channel rename event

type ChannelUnarchiveEvent

type ChannelUnarchiveEvent ChannelInfoEvent

ChannelUnarchiveEvent represents the Channel unarchive event

type Client

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

func New

func New(token string) *Client

func (*Client) AddPin

func (api *Client) AddPin(channel string, item ItemRef) error

AddPin pins an item in a channel

func (*Client) AddReaction

func (api *Client) AddReaction(name string, item ItemRef) error

AddReaction adds a reaction emoji to a message, file or file comment.

func (*Client) AddStar

func (api *Client) AddStar(channel string, item ItemRef) error

AddStar stars an item in a channel

func (*Client) ArchiveChannel

func (api *Client) ArchiveChannel(channel string) error

ArchiveChannel archives the given channel

func (*Client) ArchiveGroup

func (api *Client) ArchiveGroup(group string) error

ArchiveGroup archives a private group

func (*Client) AuthTest

func (api *Client) AuthTest() (response *AuthTestResponse, error error)

AuthTest tests if the user is able to do authenticated requests or not

func (*Client) CloseGroup

func (api *Client) CloseGroup(group string) (bool, bool, error)

CloseGroup closes a private group

func (*Client) CloseIMChannel

func (api *Client) CloseIMChannel(channel string) (bool, bool, error)

CloseIMChannel closes the direct message channel

func (*Client) CreateChannel

func (api *Client) CreateChannel(channel string) (*Channel, error)

CreateChannel creates a channel with the given name and returns a *Channel

func (*Client) CreateChildGroup

func (api *Client) CreateChildGroup(group string) (*Group, error)

CreateChildGroup creates a new private group archiving the old one This method takes an existing private group and performs the following steps:

  1. Renames the existing group (from "example" to "example-archived").
  2. Archives the existing group.
  3. Creates a new group with the name of the existing group.
  4. Adds all members of the existing group to the new group.

func (*Client) CreateGroup

func (api *Client) CreateGroup(group string) (*Group, error)

CreateGroup creates a private group

func (*Client) Debugf

func (api *Client) Debugf(format string, v ...interface{})

func (*Client) Debugln

func (api *Client) Debugln(v ...interface{})

func (*Client) DeleteFile

func (api *Client) DeleteFile(fileID string) error

DeleteFile deletes a file

func (*Client) DeleteMessage

func (api *Client) DeleteMessage(channel, messageTimestamp string) (string, string, error)

DeleteMessage deletes a message in a channel

func (*Client) DisableUser

func (api *Client) DisableUser(teamName string, uid string) error

DisableUser disabled a user account, given a user ID

func (*Client) GetChannelHistory

func (api *Client) GetChannelHistory(channel string, params HistoryParameters) (*History, error)

GetChannelHistory retrieves the channel history

func (*Client) GetChannelInfo

func (api *Client) GetChannelInfo(channel string) (*Channel, error)

GetChannelInfo retrieves the given channel

func (*Client) GetChannels

func (api *Client) GetChannels(excludeArchived bool) ([]Channel, error)

GetChannels retrieves all the channels

func (*Client) GetEmoji

func (api *Client) GetEmoji() (map[string]string, error)

GetEmoji retrieves all the emojis

func (*Client) GetFileInfo

func (api *Client) GetFileInfo(fileID string, count, page int) (*File, []Comment, *Paging, error)

GetFileInfo retrieves a file and related comments

func (*Client) GetFiles

func (api *Client) GetFiles(params GetFilesParameters) ([]File, *Paging, error)

GetFiles retrieves all files according to the parameters given

func (*Client) GetGroupHistory

func (api *Client) GetGroupHistory(group string, params HistoryParameters) (*History, error)

GetGroupHistory fetches all the history for a private group

func (*Client) GetGroupInfo

func (api *Client) GetGroupInfo(group string) (*Group, error)

GetGroupInfo retrieves the given group

func (*Client) GetGroups

func (api *Client) GetGroups(excludeArchived bool) ([]Group, error)

GetGroups retrieves all groups

func (*Client) GetIMChannels

func (api *Client) GetIMChannels() ([]IM, error)

GetIMChannels returns the list of direct message channels

func (*Client) GetIMHistory

func (api *Client) GetIMHistory(channel string, params HistoryParameters) (*History, error)

GetIMHistory retrieves the direct message channel history

func (*Client) GetReactions

func (api *Client) GetReactions(item ItemRef, params GetReactionsParameters) ([]ItemReaction, error)

GetReactions returns details about the reactions on an item.

func (*Client) GetStarred

func (api *Client) GetStarred(params StarsParameters) ([]StarredItem, *Paging, error)

GetStarred returns a list of StarredItem items. The user then has to iterate over them and figure out what they should be looking at according to what is in the Type.

for _, item := range items {
    switch c.Type {
    case "file_comment":
        log.Println(c.Comment)
    case "file":
         ...

}

This function still exists to maintain backwards compatibility. I exposed it as returning []StarredItem, so it shall stay as StarredItem

func (*Client) GetUserInfo

func (api *Client) GetUserInfo(user string) (*User, error)

GetUserInfo will retrive the complete user information

func (*Client) GetUserPresence

func (api *Client) GetUserPresence(user string) (*UserPresence, error)

GetUserPresence will retrieve the current presence status of given user.

func (*Client) GetUsers

func (api *Client) GetUsers() ([]User, error)

GetUsers returns the list of users (with their detailed information)

func (*Client) InviteGuest

func (api *Client) InviteGuest(
	teamName string,
	channel string,
	firstName string,
	lastName string,
	emailAddress string,
) error

InviteGuest invites a user to Slack as a single-channel guest

func (*Client) InviteRestricted

func (api *Client) InviteRestricted(
	teamName string,
	channel string,
	firstName string,
	lastName string,
	emailAddress string,
) error

InviteRestricted invites a user to Slack as a restricted account

func (*Client) InviteToTeam

func (api *Client) InviteToTeam(
	teamName string,
	firstName string,
	lastName string,
	emailAddress string,
) error

InviteToTeam invites a user to a Slack team

func (*Client) InviteUserToChannel

func (api *Client) InviteUserToChannel(channel, user string) (*Channel, error)

InviteUserToChannel invites a user to a given channel and returns a *Channel

func (*Client) InviteUserToGroup

func (api *Client) InviteUserToGroup(group, user string) (*Group, bool, error)

InviteUserToGroup invites a specific user to a private group

func (*Client) JoinChannel

func (api *Client) JoinChannel(channel string) (*Channel, error)

JoinChannel joins the currently authenticated user to a channel

func (*Client) KickUserFromChannel

func (api *Client) KickUserFromChannel(channel, user string) error

KickUserFromChannel kicks a user from a given channel

func (*Client) KickUserFromGroup

func (api *Client) KickUserFromGroup(group, user string) error

KickUserFromGroup kicks a user from a group

func (*Client) LeaveChannel

func (api *Client) LeaveChannel(channel string) (bool, error)

LeaveChannel makes the authenticated user leave the given channel

func (*Client) LeaveGroup

func (api *Client) LeaveGroup(group string) error

LeaveGroup makes authenticated user leave the group

func (*Client) ListPins

func (api *Client) ListPins(channel string) ([]Item, *Paging, error)

ListPins returns information about the items a user reacted to.

func (*Client) ListReactions

func (api *Client) ListReactions(params ListReactionsParameters) ([]ReactedItem, *Paging, error)

ListReactions returns information about the items a user reacted to.

func (*Client) ListStars

func (api *Client) ListStars(params StarsParameters) ([]Item, *Paging, error)

ListStars returns information about the stars a user added

func (*Client) MarkIMChannel

func (api *Client) MarkIMChannel(channel, ts string) (err error)

MarkIMChannel sets the read mark of a direct message channel to a specific point

func (*Client) NewRTM

func (api *Client) NewRTM() *RTM

NewRTM returns a RTM, which provides a fully managed connection to Slack's websocket-based Real-Time Messaging protocol./

func (*Client) OpenGroup

func (api *Client) OpenGroup(group string) (bool, bool, error)

OpenGroup opens a private group

func (*Client) OpenIMChannel

func (api *Client) OpenIMChannel(user string) (bool, bool, string, error)

OpenIMChannel opens a direct message channel to the user provided as argument Returns some status and the channel ID

func (*Client) PostMessage

func (api *Client) PostMessage(channel, text string, params PostMessageParameters) (string, string, error)

PostMessage sends a message to a channel. Message is escaped by default according to https://api.slack.com/docs/formatting Use http://davestevens.github.io/slack-message-builder/ to help crafting your message.

func (*Client) RemovePin

func (api *Client) RemovePin(channel string, item ItemRef) error

RemovePin un-pins an item from a channel

func (*Client) RemoveReaction

func (api *Client) RemoveReaction(name string, item ItemRef) error

RemoveReaction removes a reaction emoji from a message, file or file comment.

func (*Client) RemoveStar

func (api *Client) RemoveStar(channel string, item ItemRef) error

RemoveStar removes a starred item from a channel

func (*Client) RenameChannel

func (api *Client) RenameChannel(channel, name string) (*Channel, error)

RenameChannel renames a given channel

func (*Client) RenameGroup

func (api *Client) RenameGroup(group, name string) (*Channel, error)

RenameGroup renames a group XXX: They return a channel, not a group. What is this crap? :( Inconsistent api it seems.

func (*Client) Search

func (api *Client) Search(query string, params SearchParameters) (*SearchMessages, *SearchFiles, error)

func (*Client) SearchFiles

func (api *Client) SearchFiles(query string, params SearchParameters) (*SearchFiles, error)

func (*Client) SearchMessages

func (api *Client) SearchMessages(query string, params SearchParameters) (*SearchMessages, error)

func (*Client) SendSSOBindingEmail

func (api *Client) SendSSOBindingEmail(teamName string, user string) error

SendSSOBindingEmail sends an SSO binding email to the specified user

func (*Client) SetChannelPurpose

func (api *Client) SetChannelPurpose(channel, purpose string) (string, error)

SetChannelPurpose sets the channel purpose and returns the purpose that was successfully set

func (*Client) SetChannelReadMark

func (api *Client) SetChannelReadMark(channel, ts string) error

SetChannelReadMark sets the read mark of a given channel to a specific point Clients should try to avoid making this call too often. When needing to mark a read position, a client should set a timer before making the call. In this way, any further updates needed during the timeout will not generate extra calls (just one per channel). This is useful for when reading scroll-back history, or following a busy live channel. A timeout of 5 seconds is a good starting point. Be sure to flush these calls on shutdown/logout.

func (*Client) SetChannelTopic

func (api *Client) SetChannelTopic(channel, topic string) (string, error)

SetChannelTopic sets the channel topic and returns the topic that was successfully set

func (*Client) SetDebug

func (api *Client) SetDebug(debug bool)

SetDebug switches the api into debug mode When in debug mode, it logs various info about what its doing If you ever use this in production, don't call SetDebug(true)

func (*Client) SetGroupPurpose

func (api *Client) SetGroupPurpose(group, purpose string) (string, error)

SetGroupPurpose sets the group purpose

func (*Client) SetGroupReadMark

func (api *Client) SetGroupReadMark(group, ts string) error

SetGroupReadMark sets the read mark on a private group Clients should try to avoid making this call too often. When needing to mark a read position, a client should set a timer before making the call. In this way, any further updates needed during the timeout will not generate extra calls (just one per channel). This is useful for when reading scroll-back history, or following a busy live channel. A timeout of 5 seconds is a good starting point. Be sure to flush these calls on shutdown/logout.

func (*Client) SetGroupTopic

func (api *Client) SetGroupTopic(group, topic string) (string, error)

SetGroupTopic sets the group topic

func (*Client) SetRegular

func (api *Client) SetRegular(teamName string, user string) error

SetRegular enables the specified user

func (*Client) SetRestricted

func (api *Client) SetRestricted(teamName, uid string) error

SetRestricted converts a user into a restricted account

func (*Client) SetUltraRestricted

func (api *Client) SetUltraRestricted(teamName, uid, channel string) error

SetUltraRestricted converts a user into a single-channel guest

func (*Client) SetUserAsActive

func (api *Client) SetUserAsActive() error

SetUserAsActive marks the currently authenticated user as active

func (*Client) SetUserPresence

func (api *Client) SetUserPresence(presence string) error

SetUserPresence changes the currently authenticated user presence

func (*Client) StartRTM

func (api *Client) StartRTM() (info *Info, websocketURL string, err error)

StartRTM calls the "rtm.start" endpoint and returns the provided URL and the full Info block.

To have a fully managed Websocket connection, use `NewRTM`, and call `ManageConnection()` on it.

func (*Client) UnarchiveChannel

func (api *Client) UnarchiveChannel(channel string) error

UnarchiveChannel unarchives the given channel

func (*Client) UnarchiveGroup

func (api *Client) UnarchiveGroup(group string) error

UnarchiveGroup unarchives a private group

func (*Client) UpdateMessage

func (api *Client) UpdateMessage(channel, timestamp, text string) (string, string, string, error)

UpdateMessage updates a message in a channel

func (*Client) UploadFile

func (api *Client) UploadFile(params FileUploadParameters) (file *File, err error)

UploadFile uploads a file

type CommandsChangedEvent

type CommandsChangedEvent struct {
	Type           string         `json:"type"`
	EventTimestamp JSONTimeString `json:"event_ts"`
}

CommandsChangedEvent represents the commands changed event

type Comment

type Comment struct {
	ID        string   `json:"id,omitempty"`
	Created   JSONTime `json:"created,omitempty"`
	Timestamp JSONTime `json:"timestamp,omitempty"`
	User      string   `json:"user,omitempty"`
	Comment   string   `json:"comment,omitempty"`
}

Comment contains all the information relative to a comment

type ConnectedEvent

type ConnectedEvent struct {
	ConnectionCount int // 1 = first time, 2 = second time
	Info            *Info
}

ConnectedEvent is used for when we connect to Slack

type ConnectingEvent

type ConnectingEvent struct {
	Attempt         int // 1 = first attempt, 2 = second attempt
	ConnectionCount int
}

ConnectingEvent contains information about our connection attempt

type ConnectionErrorEvent

type ConnectionErrorEvent struct {
	Attempt  int
	ErrorObj error
}

ConnectionErrorEvent contains information about a connection error

func (*ConnectionErrorEvent) Error

func (c *ConnectionErrorEvent) Error() string

type CtxChannel

type CtxChannel struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

type CtxMessage

type CtxMessage struct {
	User      string `json:"user"`
	Username  string `json:"username"`
	Text      string `json:"text"`
	Timestamp string `json:"ts"`
	Type      string `json:"type"`
}

type DisconnectedEvent

type DisconnectedEvent struct {
	Intentional bool
}

DisconnectedEvent contains information about how we disconnected

type Edited

type Edited struct {
	User      string `json:"user,omitempty"`
	Timestamp string `json:"ts,omitempty"`
}

Edited indicates that a message has been edited.

type EmailDomainChangedEvent

type EmailDomainChangedEvent struct {
	Type           string         `json:"type"`
	EventTimestamp JSONTimeString `json:"event_ts"`
	EmailDomain    string         `json:"email_domain"`
}

EmailDomainChangedEvent represents the email domain changed event

type EmojiChangedEvent

type EmojiChangedEvent struct {
	Type           string         `json:"type"`
	EventTimestamp JSONTimeString `json:"event_ts"`
}

EmojiChangedEvent represents the emoji changed event

type Event

type Event struct {
	Type string `json:"type,omitempty"`
}

Event contains the event type

type File

type File struct {
	ID        string   `json:"id"`
	Created   JSONTime `json:"created"`
	Timestamp JSONTime `json:"timestamp"`

	Name       string `json:"name"`
	Title      string `json:"title"`
	Mimetype   string `json:"mimetype"`
	Filetype   string `json:"filetype"`
	PrettyType string `json:"pretty_type"`
	User       string `json:"user"`

	Mode         string `json:"mode"`
	Editable     bool   `json:"editable"`
	IsExternal   bool   `json:"is_external"`
	ExternalType string `json:"external_type"`

	Size int `json:"size"`

	URL                string `json:"url"`
	URLDownload        string `json:"url_download"`
	URLPrivate         string `json:"url_private"`
	URLPrivateDownload string `json:"url_private_download"`

	Thumb64     string `json:"thumb_64"`
	Thumb80     string `json:"thumb_80"`
	Thumb360    string `json:"thumb_360"`
	Thumb360Gif string `json:"thumb_360_gif"`
	Thumb360W   int    `json:"thumb_360_w"`
	Thumb360H   int    `json:"thumb_360_h"`

	Permalink        string `json:"permalink"`
	EditLink         string `json:"edit_link"`
	Preview          string `json:"preview"`
	PreviewHighlight string `json:"preview_highlight"`
	Lines            int    `json:"lines"`
	LinesMore        int    `json:"lines_more"`

	IsPublic        bool     `json:"is_public"`
	PublicURLShared bool     `json:"public_url_shared"`
	Channels        []string `json:"channels"`
	Groups          []string `json:"groups"`
	InitialComment  Comment  `json:"initial_comment"`
	NumStars        int      `json:"num_stars"`
	IsStarred       bool     `json:"is_starred"`
}

File contains all the information for a file

type FileChangeEvent

type FileChangeEvent fileActionEvent

FileChangeEvent represents the File change event

type FileCommentAddedEvent

type FileCommentAddedEvent struct {
	Comment Comment `json:"comment"`
	// contains filtered or unexported fields
}

FileCommentAddedEvent represents the File comment added event

type FileCommentDeletedEvent

type FileCommentDeletedEvent struct {
	Comment string `json:"comment"`
	// contains filtered or unexported fields
}

FileCommentDeletedEvent represents the File comment deleted event

type FileCommentEditedEvent

type FileCommentEditedEvent struct {
	Comment Comment `json:"comment"`
	// contains filtered or unexported fields
}

FileCommentEditedEvent represents the File comment edited event

type FileCreatedEvent

type FileCreatedEvent fileActionEvent

FileCreatedEvent represents the File created event

type FileDeletedEvent

type FileDeletedEvent fileActionEvent

FileDeletedEvent represents the File deleted event

type FilePrivateEvent

type FilePrivateEvent fileActionEvent

FilePrivateEvent represents the File private event

type FilePublicEvent

type FilePublicEvent fileActionEvent

FilePublicEvent represents the File public event

type FileSharedEvent

type FileSharedEvent fileActionEvent

FileSharedEvent represents the File shared event

type FileUnsharedEvent

type FileUnsharedEvent fileActionEvent

FileUnsharedEvent represents the File unshared event

type FileUploadParameters

type FileUploadParameters struct {
	File           string
	Content        string
	Filetype       string
	Filename       string
	Title          string
	InitialComment string
	Channels       []string
}

FileUploadParameters contains all the parameters necessary (including the optional ones) for an UploadFile() request

type GetFilesParameters

type GetFilesParameters struct {
	User          string
	TimestampFrom JSONTime
	TimestampTo   JSONTime
	Types         string
	Count         int
	Page          int
}

GetFilesParameters contains all the parameters necessary (including the optional ones) for a GetFiles() request

func NewGetFilesParameters

func NewGetFilesParameters() GetFilesParameters

NewGetFilesParameters provides an instance of GetFilesParameters with all the sane default values set

type GetReactionsParameters

type GetReactionsParameters struct {
	Full bool
}

GetReactionsParameters is the inputs to get reactions to an item.

func NewGetReactionsParameters

func NewGetReactionsParameters() GetReactionsParameters

NewGetReactionsParameters initializes the inputs to get reactions to an item.

type Group

type Group struct {
	IsGroup bool `json:"is_group"`
	// contains filtered or unexported fields
}

Group contains all the information for a group

type GroupArchiveEvent

type GroupArchiveEvent ChannelInfoEvent

GroupArchiveEvent represents the Group archive event

type GroupCloseEvent

type GroupCloseEvent ChannelInfoEvent

GroupCloseEvent represents the Group close event

type GroupCreatedEvent

type GroupCreatedEvent struct {
	Type    string             `json:"type"`
	User    string             `json:"user"`
	Channel ChannelCreatedInfo `json:"channel"`
}

GroupCreatedEvent represents the Group created event

type GroupHistoryChangedEvent

type GroupHistoryChangedEvent ChannelHistoryChangedEvent

GroupHistoryChangedEvent represents the Group history changed event

type GroupJoinedEvent

type GroupJoinedEvent ChannelJoinedEvent

GroupJoinedEvent represents the Group joined event

type GroupLeftEvent

type GroupLeftEvent ChannelInfoEvent

GroupLeftEvent represents the Group left event

type GroupMarkedEvent

type GroupMarkedEvent ChannelInfoEvent

GroupMarkedEvent represents the Group marked event

type GroupOpenEvent

type GroupOpenEvent ChannelInfoEvent

GroupOpenEvent represents the Group open event

type GroupRenameEvent

type GroupRenameEvent struct {
	Type      string          `json:"type"`
	Group     GroupRenameInfo `json:"channel"`
	Timestamp string          `json:"ts"`
}

GroupRenameEvent represents the Group rename event

type GroupRenameInfo

type GroupRenameInfo struct {
	ID      string `json:"id"`
	Name    string `json:"name"`
	Created string `json:"created"`
}

GroupRenameInfo represents the group info related to the renamed group

type GroupUnarchiveEvent

type GroupUnarchiveEvent ChannelInfoEvent

GroupUnarchiveEvent represents the Group unarchive event

type HelloEvent

type HelloEvent struct{}

HelloEvent represents the hello event

type History

type History struct {
	Latest   string    `json:"latest"`
	Messages []Message `json:"messages"`
	HasMore  bool      `json:"has_more"`
}

History contains message history information needed to navigate a Channel / Group / DM history

type HistoryParameters

type HistoryParameters struct {
	Latest    string
	Oldest    string
	Count     int
	Inclusive bool
}

HistoryParameters contains all the necessary information to help in the retrieval of history for Channels/Groups/DMs

func NewHistoryParameters

func NewHistoryParameters() HistoryParameters

NewHistoryParameters provides an instance of HistoryParameters with all the sane default values set

type IDGenerator

type IDGenerator interface {
	Next() int
}

IDGenerator provides an interface for generating integer ID values.

func NewSafeID

func NewSafeID(startID int) IDGenerator

NewSafeID returns a new instance of an IDGenerator which is safe for concurrent use by multiple goroutines.

type IM

type IM struct {
	IsIM          bool   `json:"is_im"`
	User          string `json:"user"`
	IsUserDeleted bool   `json:"is_user_deleted"`
	// contains filtered or unexported fields
}

IM contains information related to the Direct Message channel

type IMCloseEvent

type IMCloseEvent ChannelInfoEvent

IMCloseEvent represents the IM close event

type IMCreatedEvent

type IMCreatedEvent struct {
	Type    string             `json:"type"`
	User    string             `json:"user"`
	Channel ChannelCreatedInfo `json:"channel"`
}

IMCreatedEvent represents the IM created event

type IMHistoryChangedEvent

type IMHistoryChangedEvent ChannelHistoryChangedEvent

IMHistoryChangedEvent represents the IM history changed event

type IMMarkedEvent

type IMMarkedEvent ChannelInfoEvent

IMMarkedEvent represents the IM marked event

type IMMarkedHistoryChanged

type IMMarkedHistoryChanged ChannelInfoEvent

IMMarkedHistoryChanged represents the IM marked history changed event

type IMOpenEvent

type IMOpenEvent ChannelInfoEvent

IMOpenEvent represents the IM open event

type Icon

type Icon struct {
	IconURL   string `json:"icon_url,omitempty"`
	IconEmoji string `json:"icon_emoji,omitempty"`
}

Icon is used for bot messages

type Icons

type Icons struct {
	Image48 string `json:"image_48"`
}

Icons XXX: needs further investigation

type IncomingEventError

type IncomingEventError struct {
	ErrorObj error
}

IncomingEventError contains information about an unexpected error receiving a websocket event

func (*IncomingEventError) Error

func (i *IncomingEventError) Error() string

type Info

type Info struct {
	URL      string       `json:"url,omitempty"`
	User     *UserDetails `json:"self,omitempty"`
	Team     *Team        `json:"team,omitempty"`
	Users    []User       `json:"users,omitempty"`
	Channels []Channel    `json:"channels,omitempty"`
	Groups   []Group      `json:"groups,omitempty"`
	Bots     []Bot        `json:"bots,omitempty"`
	IMs      []IM         `json:"ims,omitempty"`
}

Info contains various details about Users, Channels, Bots and the authenticated user. It is returned by StartRTM or included in the "ConnectedEvent" RTM event.

func (Info) GetBotByID

func (info Info) GetBotByID(botID string) *Bot

GetBotByID returns a bot given a bot id

func (Info) GetChannelByID

func (info Info) GetChannelByID(channelID string) *Channel

GetChannelByID returns a channel given a channel id

func (Info) GetGroupByID

func (info Info) GetGroupByID(groupID string) *Group

GetGroupByID returns a group given a group id

func (Info) GetUserByID

func (info Info) GetUserByID(userID string) *User

GetUserByID returns a user given a user id

type InvalidAuthEvent

type InvalidAuthEvent struct{}

InvalidAuthEvent is used in case we can't even authenticate with the API

type Item

type Item struct {
	Type      string   `json:"type"`
	Channel   string   `json:"channel,omitempty"`
	Message   *Message `json:"message,omitempty"`
	File      *File    `json:"file,omitempty"`
	Comment   *Comment `json:"comment,omitempty"`
	Timestamp string   `json:"ts,omitempty"`
}

Item is any type of slack message - message, file, or file comment.

func NewChannelItem

func NewChannelItem(ch string) Item

NewChannelItem turns a channel id into a typed channel struct.

func NewFileCommentItem

func NewFileCommentItem(f *File, c *Comment) Item

NewFileCommentItem turns a file and comment into a typed file_comment struct.

func NewFileItem

func NewFileItem(f *File) Item

NewFileItem turns a file into a typed file struct.

func NewGroupItem

func NewGroupItem(ch string) Item

NewGroupItem turns a channel id into a typed group struct.

func NewIMItem

func NewIMItem(ch string) Item

NewIMItem turns a channel id into a typed im struct.

func NewMessageItem

func NewMessageItem(ch string, m *Message) Item

NewMessageItem turns a message on a channel into a typed message struct.

type ItemReaction

type ItemReaction struct {
	Name  string   `json:"name"`
	Count int      `json:"count"`
	Users []string `json:"users"`
}

ItemReaction is the reactions that have happened on an item.

type ItemRef

type ItemRef struct {
	Channel   string `json:"channel"`
	Timestamp string `json:"timestamp"`
	File      string `json:"file"`
	Comment   string `json:"file_comment"`
}

ItemRef is a reference to a message of any type. One of FileID, CommentId, or the combination of ChannelId and Timestamp must be specified.

func NewRefToComment

func NewRefToComment(comment string) ItemRef

NewRefToComment initializes a reference to a file comment.

func NewRefToFile

func NewRefToFile(file string) ItemRef

NewRefToFile initializes a reference to a file.

func NewRefToMessage

func NewRefToMessage(channel, timestamp string) ItemRef

NewRefToMessage initializes a reference to to a message.

type JSONTime

type JSONTime int64

JSONTime exists so that we can have a String method converting the date

func (JSONTime) String

func (t JSONTime) String() string

String converts the unix timestamp into a string

func (JSONTime) Time

func (t JSONTime) Time() time.Time

Time returns a `time.Time` representation of this value.

type JSONTimeString

type JSONTimeString string

JSONTimeString is an auxiliary type to allow us to format the time as we wish

func (JSONTimeString) String

func (t JSONTimeString) String() string

String converts the unix timestamp into a string

func (JSONTimeString) Time

func (t JSONTimeString) Time() time.Time

Time converts the timestamp string to time.Time

type LatencyReport

type LatencyReport struct {
	Value time.Duration
}

LatencyReport contains information about connection latency

type ListReactionsParameters

type ListReactionsParameters struct {
	User  string
	Count int
	Page  int
	Full  bool
}

ListReactionsParameters is the inputs to find all reactions by a user.

func NewListReactionsParameters

func NewListReactionsParameters() ListReactionsParameters

NewListReactionsParameters initializes the inputs to find all reactions performed by a user.

type ManualPresenceChangeEvent

type ManualPresenceChangeEvent struct {
	Type     string `json:"type"`
	Presence string `json:"presence"`
}

ManualPresenceChangeEvent represents the manual presence change event

type Message

type Message struct {
	Msg
	SubMessage *Msg `json:"message,omitempty"`
}

Message is an auxiliary type to allow us to have a message containing sub messages

type MessageEvent

type MessageEvent Message

MessageEvent represents a Slack Message (used as the event type for an incoming message)

type MessageTooLongEvent

type MessageTooLongEvent struct {
	Message   OutgoingMessage
	MaxLength int
}

MessageTooLongEvent is used when sending a message that is too long

func (*MessageTooLongEvent) Error

func (m *MessageTooLongEvent) Error() string

type Msg

type Msg struct {
	// Basic Message
	Type        string       `json:"type,omitempty"`
	Channel     string       `json:"channel,omitempty"`
	User        string       `json:"user,omitempty"`
	Text        string       `json:"text,omitempty"`
	Timestamp   string       `json:"ts,omitempty"`
	IsStarred   bool         `json:"is_starred,omitempty"`
	PinnedTo    []string     `json:"pinned_to, omitempty"`
	Attachments []Attachment `json:"attachments,omitempty"`
	Edited      *Edited      `json:"edited,omitempty"`

	// Message Subtypes
	SubType string `json:"subtype,omitempty"`

	// Hidden Subtypes
	Hidden           bool   `json:"hidden,omitempty"`     // message_changed, message_deleted, unpinned_item
	DeletedTimestamp string `json:"deleted_ts,omitempty"` // message_deleted
	EventTimestamp   string `json:"event_ts,omitempty"`

	// bot_message (https://api.slack.com/events/message/bot_message)
	BotID    string `json:"bot_id,omitempty"`
	Username string `json:"username,omitempty"`
	Icons    *Icon  `json:"icons,omitempty"`

	// channel_join, group_join
	Inviter string `json:"inviter,omitempty"`

	// channel_topic, group_topic
	Topic string `json:"topic,omitempty"`

	// channel_purpose, group_purpose
	Purpose string `json:"purpose,omitempty"`

	// channel_name, group_name
	Name    string `json:"name,omitempty"`
	OldName string `json:"old_name,omitempty"`

	// channel_archive, group_archive
	Members []string `json:"members,omitempty"`

	// file_share, file_comment, file_mention
	File *File `json:"file,omitempty"`

	// file_share
	Upload bool `json:"upload,omitempty"`

	// file_comment
	Comment *Comment `json:"comment,omitempty"`

	// pinned_item
	ItemType string `json:"item_type,omitempty"`

	// https://api.slack.com/rtm
	ReplyTo int    `json:"reply_to,omitempty"`
	Team    string `json:"team,omitempty"`
}

Msg contains information about a slack message

type OutgoingErrorEvent

type OutgoingErrorEvent struct {
	Message  OutgoingMessage
	ErrorObj error
}

OutgoingErrorEvent contains information in case there were errors sending messages

func (OutgoingErrorEvent) Error

func (o OutgoingErrorEvent) Error() string

type OutgoingMessage

type OutgoingMessage struct {
	ID      int    `json:"id"`
	Channel string `json:"channel,omitempty"`
	Text    string `json:"text,omitempty"`
	Type    string `json:"type,omitempty"`
}

OutgoingMessage is used for the realtime API, and seems incomplete.

type Pagination

type Pagination struct {
	TotalCount int `json:"total_count"`
	Page       int `json:"page"`
	PerPage    int `json:"per_page"`
	PageCount  int `json:"page_count"`
	First      int `json:"first"`
	Last       int `json:"last"`
}

Pagination contains pagination information This is different from Paging in that it contains additional details

type Paging

type Paging struct {
	Count int `json:"count"`
	Total int `json:"total"`
	Page  int `json:"page"`
	Pages int `json:"pages"`
}

Paging contains paging information

type PinAddedEvent

type PinAddedEvent pinEvent

PinAddedEvent represents the Pin added event

type PinRemovedEvent

type PinRemovedEvent pinEvent

PinRemovedEvent represents the Pin removed event

type Ping

type Ping struct {
	ID   int    `json:"id"`
	Type string `json:"type"`
}

Ping contains information about a Ping Event

type Pong

type Pong struct {
	Type    string `json:"type"`
	ReplyTo int    `json:"reply_to"`
}

Pong contains information about a Pong Event

type PostMessageParameters

type PostMessageParameters struct {
	Text        string
	Username    string
	AsUser      bool
	Parse       string
	LinkNames   int
	Attachments []Attachment
	UnfurlLinks bool
	UnfurlMedia bool
	IconURL     string
	IconEmoji   string
	Markdown    bool `json:"mrkdwn,omitempty"`
	EscapeText  bool
}

PostMessageParameters contains all the parameters necessary (including the optional ones) for a PostMessage() request

func NewPostMessageParameters

func NewPostMessageParameters() PostMessageParameters

NewPostMessageParameters provides an instance of PostMessageParameters with all the sane default values set

type PrefChangeEvent

type PrefChangeEvent struct {
	Type  string          `json:"type"`
	Name  string          `json:"name"`
	Value json.RawMessage `json:"value"`
}

PrefChangeEvent represents a user preferences change event

type PresenceChangeEvent

type PresenceChangeEvent struct {
	Type     string `json:"type"`
	Presence string `json:"presence"`
	User     string `json:"user"`
}

PresenceChangeEvent represents the presence change event

type Purpose

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

Purpose contains information about the purpose

type RTM

type RTM struct {
	IncomingEvents chan RTMEvent

	// Client is the main API, embedded
	Client
	// contains filtered or unexported fields
}

RTM represents a managed websocket connection. It also supports all the methods of the `Client` type.

Create this element with Client's NewRTM().

func (*RTM) Disconnect

func (rtm *RTM) Disconnect() error

Disconnect and wait, blocking until a successful disconnection.

func (*RTM) GetInfo

func (rtm *RTM) GetInfo() *Info

GetInfo returns the info structure received when calling "startrtm", holding all channels, groups and other metadata needed to implement a full chat client. It will be non-nil after a call to StartRTM().

func (*RTM) ManageConnection

func (rtm *RTM) ManageConnection()

ManageConnection can be called on a Slack RTM instance returned by the NewRTM method. It will connect to the slack RTM API and handle all incoming and outgoing events. If a connection fails then it will attempt to reconnect and will notify any listeners through an error event on the IncomingEvents channel.

If the connection ends and the disconnect was unintentional then this will attempt to reconnect.

This should only be called once per slack API! Otherwise expect undefined behavior.

The defined error events are located in websocket_internals.go.

func (*RTM) NewOutgoingMessage

func (rtm *RTM) NewOutgoingMessage(text string, channel string) *OutgoingMessage

NewOutgoingMessage prepares an OutgoingMessage that the user can use to send a message. Use this function to properly set the messageID.

func (*RTM) Reconnect

func (rtm *RTM) Reconnect() error

Reconnect only makes sense if you've successfully disconnectd with Disconnect().

func (*RTM) SendMessage

func (rtm *RTM) SendMessage(msg *OutgoingMessage)

SendMessage submits a simple message through the websocket. For more complicated messages, use `rtm.PostMessage` with a complete struct describing your attachments and all.

type RTMError

type RTMError struct {
	Code int
	Msg  string
}

RTMError encapsulates error information as returned by the Slack API

func (RTMError) Error

func (s RTMError) Error() string

type RTMEvent

type RTMEvent struct {
	Type string
	Data interface{}
}

RTMEvent is the main wrapper. You will find all the other messages attached

type RTMResponse

type RTMResponse struct {
	Ok    bool      `json:"ok"`
	Error *RTMError `json:"error"`
}

RTMResponse encapsulates response details as returned by the Slack API

type ReactedItem

type ReactedItem struct {
	Item
	Reactions []ItemReaction
}

ReactedItem is an item that was reacted to, and the details of the reactions.

type ReactionAddedEvent

type ReactionAddedEvent reactionEvent

ReactionAddedEvent represents the Reaction added event

type ReactionRemovedEvent

type ReactionRemovedEvent reactionEvent

ReactionRemovedEvent represents the Reaction removed event

type SearchFiles

type SearchFiles struct {
	Matches    []File `json:"matches"`
	Paging     `json:"paging"`
	Pagination `json:"pagination"`
	Total      int `json:"total"`
}

type SearchMessage

type SearchMessage struct {
	Type      string     `json:"type"`
	Channel   CtxChannel `json:"channel"`
	User      string     `json:"user"`
	Username  string     `json:"username"`
	Timestamp string     `json:"ts"`
	Text      string     `json:"text"`
	Permalink string     `json:"permalink"`
	Previous  CtxMessage `json:"previous"`
	Previous2 CtxMessage `json:"previous_2"`
	Next      CtxMessage `json:"next"`
	Next2     CtxMessage `json:"next_2"`
}

type SearchMessages

type SearchMessages struct {
	Matches    []SearchMessage `json:"matches"`
	Paging     `json:"paging"`
	Pagination `json:"pagination"`
	Total      int `json:"total"`
}

type SearchParameters

type SearchParameters struct {
	Sort          string
	SortDirection string
	Highlight     bool
	Count         int
	Page          int
}

func NewSearchParameters

func NewSearchParameters() SearchParameters

type SlackResponse

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

type StarAddedEvent

type StarAddedEvent starEvent

StarAddedEvent represents the Star added event

type StarRemovedEvent

type StarRemovedEvent starEvent

StarRemovedEvent represents the Star removed event

type StarredItem

type StarredItem Item

type StarsParameters

type StarsParameters struct {
	User  string
	Count int
	Page  int
}

func NewStarsParameters

func NewStarsParameters() StarsParameters

NewStarsParameters initialises StarsParameters with default values

type Team

type Team struct {
	ID     string `json:"id"`
	Name   string `json:"name"`
	Domain string `json:"domain"`
}

Team contains details about a team

type TeamDomainChangeEvent

type TeamDomainChangeEvent struct {
	Type   string `json:"type"`
	URL    string `json:"url"`
	Domain string `json:"domain"`
}

TeamDomainChangeEvent represents the Team domain change event

type TeamJoinEvent

type TeamJoinEvent struct {
	Type string `json:"type"`
	User *User  `json:"user,omitempty"`
}

TeamJoinEvent represents the Team join event

type TeamMigrationStartedEvent

type TeamMigrationStartedEvent struct {
	Type string `json:"type"`
}

TeamMigrationStartedEvent represents the Team migration started event

type TeamPrefChangeEvent

type TeamPrefChangeEvent struct {
	Type  string   `json:"type"`
	Name  string   `json:"name,omitempty"`
	Value []string `json:"value,omitempty"`
}

TeamPrefChangeEvent represents the Team preference change event

type TeamRenameEvent

type TeamRenameEvent struct {
	Type           string          `json:"type"`
	Name           string          `json:"name,omitempty"`
	EventTimestamp *JSONTimeString `json:"event_ts,omitempty"`
}

TeamRenameEvent represents the Team rename event

type Topic

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

Topic contains information about the topic

type UnmarshallingErrorEvent

type UnmarshallingErrorEvent struct {
	ErrorObj error
}

UnmarshallingErrorEvent is used when there are issues deconstructing a response

func (UnmarshallingErrorEvent) Error

func (u UnmarshallingErrorEvent) Error() string

type User

type User struct {
	ID                string      `json:"id"`
	Name              string      `json:"name"`
	Deleted           bool        `json:"deleted"`
	Color             string      `json:"color"`
	RealName          string      `json:"real_name"`
	TZ                string      `json:"tz,omitempty"`
	TZLabel           string      `json:"tz_label"`
	TZOffset          int         `json:"tz_offset"`
	Profile           UserProfile `json:"profile"`
	IsBot             bool        `json:"is_bot"`
	IsAdmin           bool        `json:"is_admin"`
	IsOwner           bool        `json:"is_owner"`
	IsPrimaryOwner    bool        `json:"is_primary_owner"`
	IsRestricted      bool        `json:"is_restricted"`
	IsUltraRestricted bool        `json:"is_ultra_restricted"`
	Has2FA            bool        `json:"has_2fa"`
	HasFiles          bool        `json:"has_files"`
	Presence          string      `json:"presence"`
}

User contains all the information of a user

type UserChangeEvent

type UserChangeEvent struct {
	Type string `json:"type"`
	User User   `json:"user"`
}

UserChangeEvent represents the user change event

type UserDetails

type UserDetails struct {
	ID             string    `json:"id"`
	Name           string    `json:"name"`
	Created        JSONTime  `json:"created"`
	ManualPresence string    `json:"manual_presence"`
	Prefs          UserPrefs `json:"prefs"`
}

UserDetails contains user details coming in the initial response from StartRTM

type UserPrefs

type UserPrefs struct {
}

UserPrefs needs to be implemented

type UserPresence

type UserPresence struct {
	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    JSONTime `json:"last_activity,omitempty"`
}

UserPresence contains details about a user online status

type UserProfile

type UserProfile struct {
	FirstName          string `json:"first_name"`
	LastName           string `json:"last_name"`
	RealName           string `json:"real_name"`
	RealNameNormalized string `json:"real_name_normalized"`
	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"`
	ImageOriginal      string `json:"image_original"`
	Title              string `json:"title"`
}

UserProfile contains all the information details of a given user

type UserTypingEvent

type UserTypingEvent struct {
	Type    string `json:"type"`
	User    string `json:"user"`
	Channel string `json:"channel"`
}

UserTypingEvent represents the user typing event

type WebError

type WebError string

func (WebError) Error

func (s WebError) Error() string

type WebResponse

type WebResponse struct {
	Ok    bool      `json:"ok"`
	Error *WebError `json:"error"`
}

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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