Documentation ¶
Index ¶
- Constants
- Variables
- func AssembleSlackAuthURL(redirectURL string) string
- func GetOAuthV2Token(ctx context.Context, clientID, clientSecret, code, redirectURI string) (resp *slack.OAuthV2Response, err error)
- func HandleNoTeamEvent(ctx context.Context, event ChatEvent) (responseBytes []byte)
- type BadEvent
- type ChatEvent
- type EventedChatSystem
- type Formatter
- func (f *Formatter) FormatBlockQuote(msg string) string
- func (f *Formatter) FormatBold(msg string) string
- func (f *Formatter) FormatChangeLink(project string, number int, url, subject string) string
- func (f *Formatter) FormatChannelLink(channelID string) string
- func (f *Formatter) FormatCode(text string) string
- func (f *Formatter) FormatItalic(msg string) string
- func (f *Formatter) FormatLink(url, text string) string
- func (f *Formatter) FormatUserLink(chatID string) string
- func (f *Formatter) UnwrapChannelLink(channelLink string) string
- func (f *Formatter) UnwrapLink(link string) string
- func (f *Formatter) UnwrapUserLink(userLink string) string
- type OAuthV2Response
- type OAuthV2ResponseTeam
- type OAuthV2ResponseUser
Constants ¶
const ( // AddToSlackButton contains the HTML to create the appropriate "Add To Slack" button for this application. AddToSlackButton = `` /* 251-byte string literal not displayed */ )
Variables ¶
var ( // ClientID is the ID issued to this app by Slack. ClientID = flag.String("slack-client-id", "13639549360.893676519079", "ID issued to this app by Slack") // ClientSecret is the secret issued to this app by Slack. ClientSecret = flag.String("slack-client-secret", "", "Client secret issued to this app by Slack") // SigningSecret is the signing secret issued to this app by Slack. SigningSecret = flag.String("slack-signing-secret", "", "Signing secret issued to this app by Slack") )
var ErrStopTeam = errors.New("stop this team")
ErrStopTeam is returned by HandleEvent when the app has been uninstalled from that team.
var ErrVerifyFailed = errors.New("verify error")
ErrVerifyFailed is the error returned when a request can not be verified as coming from the chat system.
Functions ¶
func AssembleSlackAuthURL ¶
AssembleSlackAuthURL assembles a slack auth URL with the necessary client ID, scopes, user scopes, and redirect URI.
func GetOAuthV2Token ¶
func GetOAuthV2Token(ctx context.Context, clientID, clientSecret, code, redirectURI string) (resp *slack.OAuthV2Response, err error)
GetOAuthV2Token issues a call to Slack to get a OAuth V2 token.
Types ¶
type BadEvent ¶
type BadEvent struct {
// contains filtered or unexported fields
}
BadEvent is an error type returned when a request from the chat system can not be parsed.
type ChatEvent ¶
type ChatEvent struct {
// contains filtered or unexported fields
}
ChatEvent encapsulates a chat system event, to avoid leaking Slack implementation details.
type EventedChatSystem ¶
type EventedChatSystem interface { messages.ChatSystem HandleEvent(ctx context.Context, event ChatEvent) error }
EventedChatSystem is the interface implemented by chat systems that have events to process.
func NewSlackInterface ¶
func NewSlackInterface(logger *zap.Logger, setupData string) (EventedChatSystem, error)
NewSlackInterface creates an EventedChatSystem instance for a Slack server.
type Formatter ¶
type Formatter struct{}
Formatter defines how messages can be formatted on Slack.
func (*Formatter) FormatBlockQuote ¶
FormatBlockQuote formats a message (line or paragraph) as a block quote, according to Slack syntax.
func (*Formatter) FormatBold ¶
FormatBold formats a message as bold according to Slack syntax.
func (*Formatter) FormatChangeLink ¶
FormatChangeLink formats a link to a Gerrit change according to Slack syntax.
func (*Formatter) FormatChannelLink ¶
FormatChannelLink formats a reference to a channel ID.
func (*Formatter) FormatCode ¶
FormatCode formats text as fixed-width (like a code listing) according to Slack syntax.
func (*Formatter) FormatItalic ¶
FormatItalic formats a message in italics according to Slack syntax.
func (*Formatter) FormatLink ¶
FormatLink formats an arbitrary link with the given text according to Slack syntax.
func (*Formatter) FormatUserLink ¶
FormatUserLink formats a reference to a user chat ID.
func (*Formatter) UnwrapChannelLink ¶
UnwrapChannelLink accepts a formatted channel link and returns the associated channel ID.
func (*Formatter) UnwrapLink ¶
UnwrapLink accepts a formatted link and returns the associated URL.
func (*Formatter) UnwrapUserLink ¶
UnwrapUserLink accepts a formatted user link and returns the chat ID of the associated user.
type OAuthV2Response ¶
type OAuthV2Response struct { AccessToken string `json:"access_token"` TokenType string `json:"token_type"` Scope string `json:"scope"` BotUserID string `json:"bot_user_id"` AppID string `json:"app_id"` Team OAuthV2ResponseTeam `json:"team"` Enterprise OAuthV2ResponseTeam `json:"enterprise"` AuthedUser OAuthV2ResponseUser `json:"authed_user"` slack.SlackResponse }
OAuthV2Response is the structure of the JSON Slack provides as OAuth authentication for a team.
type OAuthV2ResponseTeam ¶
OAuthV2ResponseTeam is the structure of a team definition as returned by Slack as part of an OAuthV2Response.
type OAuthV2ResponseUser ¶
type OAuthV2ResponseUser struct { ID string `json:"id"` Scope string `json:"scope"` AccessToken string `json:"access_token"` TokenType string `json:"token_type"` }
OAuthV2ResponseUser is the structure of a user definition as returned by Slack as part of an OAuthV2Response.