# README
Slack API in Go

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.
Change log
v0.1.0 - May 28, 2017
This is released before adding context support. As the used context package is the one from Go 1.7 this will be the last compatible with Go < 1.7.
Please check 0.1.0
CHANGELOG.md
As of this version a CHANGELOG.md is available. Please visit it for updates.
Installing
go get
$ go get -u 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
# Packages
No description provided by the author
# Functions
ApplyMsgOptions utility function for debugging/testing chat requests.
No description provided by the author
No description provided by the author
GetOAuthToken retrieves an AccessToken.
GetOAuthTokenContext retrieves an AccessToken with a custom context.
No description provided by the author
No description provided by the author
MsgOptionAsUser whether or not to send the message as the user.
MsgOptionAttachments provide attachments for the message.
MsgOptionDelete deletes a message based on the timestamp.
MsgOptionDisableMarkdown disables markdown.
MsgOptionDisableMediaUnfurl disables media unfurling.
MsgOptionEnableLinkUnfurl enables link unfurling.
MsgOptionPost posts a messages, this is the default.
MsgOptionPostMessageParameters maintain backwards compatibility.
MsgOptionText provide the text for the message, optionally escape the provided text.
MsgOptionUpdate updates a message based on the timestamp.
No description provided by the author
NewAccessLogParameters provides an instance of AccessLogParameters with all the sane default values set.
NewChannelItem turns a channel id into a typed channel struct.
NewFileCommentItem turns a file and comment into a typed file_comment struct.
NewFileItem turns a file into a typed file struct.
NewGetFilesParameters provides an instance of GetFilesParameters with all the sane default values set.
NewGetReactionsParameters initializes the inputs to get reactions to an item.
NewGroupItem turns a channel id into a typed group struct.
NewHistoryParameters provides an instance of HistoryParameters with all the sane default values set.
NewIMItem turns a channel id into a typed im struct.
NewListReactionsParameters initializes the inputs to find all reactions performed by a user.
NewMessageItem turns a message on a channel into a typed message struct.
NewPostMessageParameters provides an instance of PostMessageParameters with all the sane default values set.
NewRefToComment initializes a reference to a file comment.
NewRefToFile initializes a reference to a file.
NewRefToMessage initializes a reference to to a message.
NewResponseMessageParameters provides an instance of ResponseMessageParameters with all the sane default values set.
NewSafeID returns a new instance of an IDGenerator which is safe for concurrent use by multiple goroutines.
No description provided by the author
NewStarsParameters initialises StarsParameters with default values.
No description provided by the author
SetHTTPClient allows you to specify a custom http.Client Use this instead of the package level HTTPClient variable if you want to use a custom client like the Stackdriver Trace HTTPClient https://godoc.org/cloud.google.com/go/trace#HTTPClient.
SetLogger let's library users supply a logger, so that api debugging can be logged along with the application's debugging info.
# Constants
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Add here the defaults in the siten.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
MaxMessageTextLength is the current maximum message length in number of characters as defined here https://api.slack.com/rtm#limits.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Variables
HTTPClient sets a custom http.Client deprecated: in favor of SetHTTPClient().
Added as a var so that we can change this for testing purposes
*/.
No description provided by the author
# Structs
AccessLogParameters contains all the parameters necessary (including the optional ones) for a GetAccessLogs() request.
AccountsChangedEvent represents the accounts changed event.
AckErrorEvent i.
AckMessage is used for messages received in reply to other messages.
Attachment contains all the information for an attachment.
AttachmentAction is a button or menu to be included in the attachment.
AttachmentActionCallback is sent from Slack when a user clicks a button in an interactive message (aka AttachmentAction).
AttachmentActionOption the individual option to appear in action menu.
AttachmentActionOptionGroup is a semi-hierarchal way to list available options to appear in action menu.
AttachmentField contains information for an attachment field An Attachment can contain multiple of these.
No description provided by the author
No description provided by the author
No description provided by the author
Bot contains information about a bot.
BotAddedEvent represents the bot added event.
BotChangedEvent represents the bot changed event.
Channel contains information about the channel.
ChannelCreatedEvent represents the Channel created event.
ChannelCreatedInfo represents the information associated with the Channel created event.
ChannelHistoryChangedEvent represents the Channel history changed event.
ChannelInfoEvent represents the Channel info event.
ChannelJoinedEvent represents the Channel joined event.
ChannelRenameEvent represents the Channel rename event.
ChannelRenameInfo represents the information associated with a Channel rename event.
No description provided by the author
CommandsChangedEvent represents the commands changed event.
Comment contains all the information relative to a comment.
ConfirmationField are used to ask users to confirm actions.
ConnectedEvent is used for when we connect to Slack.
ConnectingEvent contains information about our connection attempt.
ConnectionErrorEvent contains information about a connection error.
No description provided by the author
No description provided by the author
Dialog object sent to Slack.
Elements in dialog.
No description provided by the author
AttachmentActionOptionGroup is a semi-hierarchal way to list available options to appear in action menu.
No description provided by the author
DisconnectedEvent contains information about how we disconnected.
No description provided by the author
DNDUpdatedEvent represents the update event for Do Not Disturb.
Edited indicates that a message has been edited.
EmailDomainChangedEvent represents the email domain changed event.
EmojiChangedEvent represents the emoji changed event.
Event contains the event type.
File contains all the information for a file.
FileCommentAddedEvent represents the File comment added event.
FileCommentDeletedEvent represents the File comment deleted event.
FileCommentEditedEvent represents the File comment edited event.
FileUploadParameters contains all the parameters necessary (including the optional ones) for an UploadFile() request.
GetFilesParameters contains all the parameters necessary (including the optional ones) for a GetFiles() request.
GetReactionsParameters is the inputs to get reactions to an item.
Group contains all the information for a group.
GroupCreatedEvent represents the Group created event.
GroupRenameEvent represents the Group rename event.
GroupRenameInfo represents the group info related to the renamed group.
HelloEvent represents the hello event.
History contains message history information needed to navigate a Channel / Group / DM history.
HistoryParameters contains all the necessary information to help in the retrieval of history for Channels/Groups/DMs.
Icon is used for bot messages.
Icons XXX: needs further investigation.
IM contains information related to the Direct Message channel.
IMCreatedEvent represents the IM created event.
IncomingEventError contains information about an unexpected error receiving a websocket event.
Info contains various details about Users, Channels, Bots and the authenticated user.
InvalidAuthEvent is used in case we can't even authenticate with the API.
Item is any type of slack message - message, file, or file comment.
ItemReaction is the reactions that have happened on an item.
ItemRef is a reference to a message of any type.
LatencyReport contains information about connection latency.
ListReactionsParameters is the inputs to find all reactions by a user.
No description provided by the author
No description provided by the author
ManualPresenceChangeEvent represents the manual presence change event.
Message is an auxiliary type to allow us to have a message containing sub messages.
MessageTooLongEvent is used when sending a message that is too long.
Msg contains information about a slack message.
No description provided by the author
No description provided by the author
No description provided by the author
OutgoingErrorEvent contains information in case there were errors sending messages.
OutgoingMessage is used for the realtime API, and seems incomplete.
Pagination contains pagination information This is different from Paging in that it contains additional details.
Paging contains paging information.
Ping contains information about a Ping Event.
Pong contains information about a Pong Event.
PostMessageParameters contains all the parameters necessary (including the optional ones) for a PostMessage() request.
PrefChangeEvent represents a user preferences change event.
PresenceChangeEvent represents the presence change event.
Purpose contains information about the purpose.
ReactedItem is an item that was reacted to, and the details of the reactions.
ReconnectUrlEvent represents the receiving reconnect url event.
Reply contains information about a reply for a thread.
ResponseMessageParameters contains all the parameters necessary (including the optional ones) for a PostResponse() request.
RTM represents a managed websocket connection.
RTMError encapsulates error information as returned by the Slack API.
RTMEvent is the main wrapper.
RTMOptions allows configuration of various options available for RTM messaging
This structure will evolve in time so please make sure you are always using the named keys for every entry available as per Go 1 compatibility promise adding fields to this structure should not be considered a breaking change.
RTMResponse encapsulates response details as returned by the Slack API.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Team contains details about a team.
TeamDomainChangeEvent represents the Team domain change event.
No description provided by the author
No description provided by the author
TeamJoinEvent represents the Team join event.
TeamMigrationStartedEvent represents the Team migration started event.
TeamPrefChangeEvent represents the Team preference change event.
TeamRenameEvent represents the Team rename event.
No description provided by the author
Topic contains information about the topic.
No description provided by the author
UnfurlParmaeters contains all the parameters necessary (including the optional ones) for a ChatUnfurl() request.
UnmarshallingErrorEvent is used when there are issues deconstructing a response.
UpdateMessageParameters contains all the parameters necessary (including the optional ones) for a UpdateMessage() request.
User contains all the information of a user.
UserChangeEvent represents the user change event.
UserDetails contains user details coming in the initial response from StartRTM.
UserGroup contains all the information of a user group.
UserGroupPrefs contains default channels and groups (private channels).
No description provided by the author
No description provided by the author
UserPrefs needs to be implemented.
UserPresence contains details about a user online status.
UserProfile contains all the information details of a given user.
No description provided by the author
UserTypingEvent represents the user typing event.
No description provided by the author
No description provided by the author
# Interfaces
HTTPRequester defines the minimal interface needed for an http.Client to be implemented.
IDGenerator provides an interface for generating integer ID values.
# Type aliases
ChannelArchiveEvent represents the Channel archive event.
ChannelDeletedEvent represents the Channel deleted event.
ChannelLeftEvent represents the Channel left event.
ChannelMarkedEvent represents the Channel marked event.
ChannelUnarchiveEvent represents the Channel unarchive event.
FileChangeEvent represents the File change event.
FileCreatedEvent represents the File created event.
FileDeletedEvent represents the File deleted event.
FilePrivateEvent represents the File private event.
FilePublicEvent represents the File public event.
FileSharedEvent represents the File shared event.
FileUnsharedEvent represents the File unshared event.
GroupArchiveEvent represents the Group archive event.
GroupCloseEvent represents the Group close event.
GroupHistoryChangedEvent represents the Group history changed event.
GroupJoinedEvent represents the Group joined event.
GroupLeftEvent represents the Group left event.
GroupMarkedEvent represents the Group marked event.
GroupOpenEvent represents the Group open event.
GroupUnarchiveEvent represents the Group unarchive event.
IMCloseEvent represents the IM close event.
IMHistoryChangedEvent represents the IM history changed event.
IMMarkedEvent represents the IM marked event.
IMMarkedHistoryChanged represents the IM marked history changed event.
IMOpenEvent represents the IM open event.
JSONTime exists so that we can have a String method converting the date.
MessageEvent represents a Slack Message (used as the event type for an incoming message).
MsgOption option provided when sending a message.
PinAddedEvent represents the Pin added event.
PinRemovedEvent represents the Pin removed event.
ReactionAddedEvent represents the Reaction added event.
ReactionRemovedEvent represents the Reaction removed event.
StarAddedEvent represents the Star added event.
No description provided by the author
StarRemovedEvent represents the Star removed event.
No description provided by the author