Version: v0.24.1 Latest Latest

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

Go to latest
Published: Dec 9, 2019 License: Apache-2.0 Imports: 18 Imported by: 0




View Source
const TokenCookieName = "slack_token"

TokenCookieName is the name of a cookie containing a token for a user session.


This section is empty.


func WithToken

func WithToken(ctx context.Context, tok *AuthToken) context.Context

WithToken will return a new context authorized for API calls with the given AuthToken.


type API

type API state

API allows making calls to implemented Slack API methods.

API methods implement permission/scope checking.

func (*API) AuthRevoke

func (st *API) AuthRevoke(ctx context.Context, test bool) (bool, error)

AuthRevoke will revoke the auth token from the provided context.

func (*API) ChannelsCreate

func (st *API) ChannelsCreate(ctx context.Context, opts ConversationCreateOpts) (*Channel, error)

ChannelsCreate is used to create a channel.

func (*API) ChatPostMessage

func (st *API) ChatPostMessage(ctx context.Context, opts ChatPostMessageOptions) (*Message, error)

ChatPostMessage posts a message to a channel.

func (*API) ConversationsInfo

func (st *API) ConversationsInfo(ctx context.Context, id string) (*Channel, error)

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

func (st *API) GroupsCreate(ctx context.Context, opts ConversationCreateOpts) (*Channel, error)

GroupsCreate is used to create a channel.

func (*API) OAuthAccess

func (st *API) OAuthAccess(ctx context.Context, opts OAuthAccessOpts) (*AuthToken, error)

OAuthAccess will exchange a temporary code for an access token.

type App

type App struct {
	ID        string
	Name      string
	Secret    string
	AuthToken *AuthToken

type AppInfo

type AppInfo struct {
	Name         string
	ClientID     string
	ClientSecret string
	AccessToken  string

AppInfo contains information for an installed Slack app.

type AuthToken

type AuthToken struct {
	ID     string
	Scopes []string
	User   string
	IsBot  bool

AuthToken represents a state of authorization with the Slack server.

func ContextToken

func ContextToken(ctx context.Context) *AuthToken

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

	AsUser bool

	ThreadTS string

ChatPostMessageOptions are parameters for a `chat.postMessage` call.

type ConversationCreateOpts

type ConversationCreateOpts struct {
	Name     string
	Validate bool

ConversationCreateOpts is used to configure a new channel or group.

type ConversationsListOpts

type ConversationsListOpts struct {
	Cursor          string
	ExcludeArchived bool
	Limit           int
	Types           string

ConversationsListOpts contains parameters for the ConversationsList API call.

type Message

type Message struct {
	TS   string `json:"ts"`
	Text string `json:"text"`
	User string `json:"user"`

Message represents a Slack message.

type OAuthAccessOpts

type OAuthAccessOpts struct {
	ClientID     string
	ClientSecret string
	Code         string

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 NewServer

func NewServer() *Server

NewServer creates a new blank Server.

func (Server) API

func (st Server) API() *API

API returns an API instance.

func (Server) InstallApp

func (st Server) InstallApp(name string, scopes ...string) AppInfo

InstallApp will "install" a new app to this Slack server.

func (Server) InstallStaticApp

func (st Server) InstallStaticApp(app AppInfo, scopes ...string) (*AppInfo, error)

InstallApp will "install" a new app to this Slack server using pre-configured AppInfo.

func (Server) Messages

func (st Server) Messages(chanID string) []Message

Messages will return all messages from a given channel/group.

func (Server) NewChannel

func (st Server) NewChannel(name string) ChannelInfo

NewChannel will create a new Slack channel with the given name.

func (Server) NewUser

func (st Server) NewUser(name string) UserInfo

NewUser will create a new Slack user with the given name.

func (*Server) ServeAuthRevoke

func (s *Server) ServeAuthRevoke(w http.ResponseWriter, req *http.Request)

ServeAuthRevoke implements the auth.revoke 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) ServeConversationsInfo

func (s *Server) ServeConversationsInfo(w http.ResponseWriter, req *http.Request)

ServeConversationsInfo serves a request to the `` 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) ServeOAuthAuthorize

func (s *Server) ServeOAuthAuthorize(w http.ResponseWriter, req *http.Request)

func (Server) SetAutoCreateChannel

func (st Server) SetAutoCreateChannel(value bool)

SetAutoCreateChannel, if set to true, will cause messages sent to non-existant channels to succeed by creating the channel automatically.

type User

type User struct {
	ID   string
	Name string

type UserInfo

type UserInfo struct {
	ID        string
	Name      string
	AuthToken string

UserInfo contains information for a newly created user.


Path Synopsis

Jump to

Keyboard shortcuts

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