Documentation ¶
Index ¶
- Constants
- func WithToken(ctx context.Context, tok *AuthToken) context.Context
- type API
- func (st *API) AuthRevoke(ctx context.Context, test bool) (bool, error)
- func (st *API) ChannelsCreate(ctx context.Context, opts ConversationCreateOpts) (*Channel, error)
- func (st *API) ChatPostMessage(ctx context.Context, opts ChatPostMessageOptions) (*Message, error)
- func (st *API) ConversationsInfo(ctx context.Context, id string) (*Channel, error)
- func (st *API) ConversationsList(ctx context.Context, opts ConversationsListOpts) ([]Channel, string, error)
- func (st *API) GroupsCreate(ctx context.Context, opts ConversationCreateOpts) (*Channel, error)
- func (st *API) OAuthAccess(ctx context.Context, opts OAuthAccessOpts) (*AuthToken, error)
- func (st *API) TeamInfo(ctx context.Context, id string) (*Team, error)
- func (st *API) UserGroupList(ctx context.Context) ([]UserGroup, error)
- func (st *API) UserGroupsUsersUpdate(ctx context.Context, opts UserGroupsUsersUpdateOptions) (*UserGroup, error)
- func (st *API) UsersInfo(ctx context.Context, id string) (*User, error)
- type Action
- type App
- type AppInfo
- type AuthToken
- type Channel
- type ChannelInfo
- type ChatPostMessageOptions
- type ConversationCreateOpts
- type ConversationsListOpts
- type Message
- type OAuthAccessOpts
- type Server
- func (st Server) API() *API
- func (st Server) DeleteMessage(chanID, ts string) bool
- func (st Server) InstallApp(name string, scopes ...string) AppInfo
- func (st Server) InstallStaticApp(app AppInfo, scopes ...string) (*AppInfo, error)
- func (st Server) Messages(chanID string) []Message
- func (st Server) NewChannel(name string) ChannelInfo
- func (st Server) NewUser(name string) UserInfo
- func (st Server) NewUserGroup(name string) UserGroupInfo
- func (s *Server) PerformActionAs(userID string, a Action) error
- func (s *Server) ServeActionResponse(w http.ResponseWriter, r *http.Request)
- func (s *Server) ServeAuthRevoke(w http.ResponseWriter, req *http.Request)
- func (s *Server) ServeAuthTest(w http.ResponseWriter, req *http.Request)
- func (s *Server) ServeChannelsCreate(w http.ResponseWriter, req *http.Request)
- func (s *Server) ServeChatPostMessage(w http.ResponseWriter, req *http.Request)
- func (s *Server) ServeChatUpdate(w http.ResponseWriter, req *http.Request)
- func (s *Server) ServeConversationsInfo(w http.ResponseWriter, req *http.Request)
- func (s *Server) ServeConversationsList(w http.ResponseWriter, req *http.Request)
- func (s *Server) ServeGroupsCreate(w http.ResponseWriter, req *http.Request)
- func (s *Server) ServeHTTP(w http.ResponseWriter, req *http.Request)
- func (s *Server) ServeOAuthAccess(w http.ResponseWriter, req *http.Request)
- func (s *Server) ServeTeamInfo(w http.ResponseWriter, req *http.Request)
- func (s *Server) ServeUserGroupList(w http.ResponseWriter, req *http.Request)
- func (s *Server) ServeUserGroupsUsersUpdate(w http.ResponseWriter, req *http.Request)
- func (s *Server) ServeUsersInfo(w http.ResponseWriter, req *http.Request)
- func (s *Server) SetActionURL(appID string, actionURL string)
- func (st Server) SetAutoCreateChannel(value bool)
- func (s *Server) SetURLPrefix(prefix string)
- func (st Server) UserGroupUserIDs(ugID string) []string
- type Team
- type TeamInfoOpts
- type User
- type UserGroup
- type UserGroupInfo
- type UserGroupsUsersUpdateOptions
- type UserInfo
- type UsersInfoOpts
Constants ¶
const TokenCookieName = "slack_token"
TokenCookieName is the name of a cookie containing a token for a user session.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type API ¶
type API state
API allows making calls to implemented Slack API methods.
API methods implement permission/scope checking.
func (*API) AuthRevoke ¶
AuthRevoke will revoke the auth token from the provided context.
func (*API) ChannelsCreate ¶
ChannelsCreate is used to create a channel.
func (*API) ChatPostMessage ¶
ChatPostMessage posts a message to a channel.
func (*API) ConversationsInfo ¶
ConversationsInfo returns information about a conversation.
func (*API) ConversationsList ¶
func (st *API) ConversationsList(ctx context.Context, opts ConversationsListOpts) ([]Channel, string, error)
ConversationsList returns a list of channel-like conversations in a workspace.
func (*API) GroupsCreate ¶
GroupsCreate is used to create a channel.
func (*API) OAuthAccess ¶
OAuthAccess will exchange a temporary code for an access token.
func (*API) UserGroupList ¶ added in v0.31.0
UserGroupList returns a list of User Groups in a workspace.
func (*API) UserGroupsUsersUpdate ¶ added in v0.31.0
func (st *API) UserGroupsUsersUpdate(ctx context.Context, opts UserGroupsUsersUpdateOptions) (*UserGroup, error)
UserGroupsUsersUpdate updates the list of users within a user group and returns the user group.
type AppInfo ¶
type AppInfo struct { Name string ClientID string ClientSecret string AccessToken string TeamID string SigningSecret string ActionURL string }
AppInfo contains information for an installed Slack app.
type AuthToken ¶
AuthToken represents a state of authorization with the Slack server.
func ContextToken ¶
ContextToken will return a copy of the AuthToken from the given context.
type Channel ¶
type Channel struct { ID string `json:"id"` Name string `json:"name"` IsChannel bool `json:"is_channel"` IsGroup bool `json:"is_group"` IsArchived bool `json:"is_archived"` }
Channel represents a Slack channel or group.
type ChannelInfo ¶
type ChannelInfo struct {
ID, Name string
}
ChannelInfo contains information about a newly created Slack channel.
type ChatPostMessageOptions ¶
type ChatPostMessageOptions struct { ChannelID string Text string Color string Actions []Action AsUser bool User string UpdateTS string ThreadTS string Broadcast bool }
ChatPostMessageOptions are parameters for a `chat.postMessage` call.
type ConversationCreateOpts ¶
ConversationCreateOpts is used to configure a new channel or group.
type ConversationsListOpts ¶
ConversationsListOpts contains parameters for the ConversationsList API call.
type Message ¶
type Message struct { TS string `json:"ts"` ThreadTS string `json:"thread_ts"` UpdateTS string `json:"update_ts"` Text string `json:"text"` User string `json:"user"` Broadcast bool `json:"reply_broadcast"` Color string `json:"color"` ChannelID string ToUserID string Actions []Action }
Message represents a Slack message.
type OAuthAccessOpts ¶
OAuthAccessOpts contains parameters for an OAuthAccess API call.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server implements a mock Slack API.
func (Server) DeleteMessage ¶ added in v0.28.0
DeleteMessage will delete a message from channel history.
func (Server) InstallApp ¶
InstallApp will "install" a new app to this Slack server.
func (Server) InstallStaticApp ¶
InstallApp will "install" a new app to this Slack server using pre-configured AppInfo.
func (Server) NewChannel ¶
func (st Server) NewChannel(name string) ChannelInfo
NewChannel will create a new Slack channel with the given name.
func (Server) NewUserGroup ¶ added in v0.31.0
func (st Server) NewUserGroup(name string) UserGroupInfo
NewUserGroup will create a new Slack user group with the given name.
func (*Server) PerformActionAs ¶ added in v0.29.0
PerformActionAs will perform the action as the given user.
func (*Server) ServeActionResponse ¶ added in v0.29.0
func (s *Server) ServeActionResponse(w http.ResponseWriter, r *http.Request)
func (*Server) ServeAuthRevoke ¶
func (s *Server) ServeAuthRevoke(w http.ResponseWriter, req *http.Request)
ServeAuthRevoke implements the auth.revoke API call.
func (*Server) ServeAuthTest ¶ added in v0.27.0
func (s *Server) ServeAuthTest(w http.ResponseWriter, req *http.Request)
ServeAuthTest serves a request to the `auth.test` API call.
func (*Server) ServeChannelsCreate ¶
func (s *Server) ServeChannelsCreate(w http.ResponseWriter, req *http.Request)
ServeChannelsCreate serves a request to the `channels.create` API call.
func (*Server) ServeChatPostMessage ¶
func (s *Server) ServeChatPostMessage(w http.ResponseWriter, req *http.Request)
ServeChatPostMessage serves a request to the `chat.postMessage` API call.
func (*Server) ServeChatUpdate ¶ added in v0.29.0
func (s *Server) ServeChatUpdate(w http.ResponseWriter, req *http.Request)
ServeChatUpdate serves a request to the `chat.update` API call.
func (*Server) ServeConversationsInfo ¶
func (s *Server) ServeConversationsInfo(w http.ResponseWriter, req *http.Request)
ServeConversationsInfo serves a request to the `conversations.info` API call.
func (*Server) ServeConversationsList ¶
func (s *Server) ServeConversationsList(w http.ResponseWriter, req *http.Request)
ServeConversationsList serves a request to the `conversations.list` API call.
func (*Server) ServeGroupsCreate ¶
func (s *Server) ServeGroupsCreate(w http.ResponseWriter, req *http.Request)
ServeGroupsCreate serves a request to the `Groups.create` API call.
func (*Server) ServeHTTP ¶
func (s *Server) ServeHTTP(w http.ResponseWriter, req *http.Request)
ServeHTTP serves the Slack API.
func (*Server) ServeOAuthAccess ¶
func (s *Server) ServeOAuthAccess(w http.ResponseWriter, req *http.Request)
ServeOAuthAccess serves a request to the `oauth.access` API call.
func (*Server) ServeTeamInfo ¶ added in v0.31.0
func (s *Server) ServeTeamInfo(w http.ResponseWriter, req *http.Request)
ServeTeamInfo serves a request to the `team.info` API call.
func (*Server) ServeUserGroupList ¶ added in v0.31.0
func (s *Server) ServeUserGroupList(w http.ResponseWriter, req *http.Request)
ServeUserGroupList serves a request to the `usergroups.list` API call.
func (*Server) ServeUserGroupsUsersUpdate ¶ added in v0.31.0
func (s *Server) ServeUserGroupsUsersUpdate(w http.ResponseWriter, req *http.Request)
ServeUserGroupsUsersUpdate serves a request to the `usergroups.users.update` API call.
func (*Server) ServeUsersInfo ¶ added in v0.31.0
func (s *Server) ServeUsersInfo(w http.ResponseWriter, req *http.Request)
ServeUsersInfo serves a request to the `users.info` API call.
func (*Server) SetActionURL ¶ added in v0.29.0
func (Server) SetAutoCreateChannel ¶
func (st Server) SetAutoCreateChannel(value bool)
SetAutoCreateChannel, if set to true, will cause messages sent to non-existent channels to succeed by creating the channel automatically.
func (*Server) SetURLPrefix ¶ added in v0.29.0
SetURLPrefix will update the URL prefix for this server.
func (Server) UserGroupUserIDs ¶ added in v0.31.0
UserGroupUserIDs will return all users from a given user group.
type TeamInfoOpts ¶ added in v0.31.0
type TeamInfoOpts struct {
Team string
}
TeamInfoOpts contains parameters for the TeamInfo API call.
type UserGroup ¶ added in v0.31.0
type UserGroup struct { ID string `json:"id"` Name string `json:"name"` Handle string `json:"handle"` IsUserGroup bool `json:"is_usergroup"` Users []string `json:"users"` }
UserGroup represents a Slack user group.
type UserGroupInfo ¶ added in v0.31.0
type UserGroupInfo struct {
ID, Name, Handle string
}
UserGroupInfo contains information about a newly created Slack user group.
type UserGroupsUsersUpdateOptions ¶ added in v0.31.0
type UsersInfoOpts ¶ added in v0.31.0
type UsersInfoOpts struct {
User string
}
UsersInfoOpts contains parameters for the UsersInfo API call.
Source Files ¶
- actions.go
- api.go
- authrevoke.go
- authtest.go
- channelscreate.go
- chatpostmessage.go
- conversationsinfo.go
- conversationslist.go
- groupscreate.go
- http.go
- login.go
- oauthaccess.go
- permissions.go
- server.go
- state.go
- teaminfo.go
- user.go
- usergroupslist.go
- usergroupsusersupdate.go
- usersinfo.go
- util.go
- validate.go