slack

package
v0.38.0 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2021 License: MIT Imports: 12 Imported by: 0

README

Slackbot integration for Variant 2

This package provides a HTTP server that handles Slack interaction callbacks so that it can run any variant command in response to a Slack slash command.

Acknowledgements

I've learned how to code a Slack bot in Go by reading the following repositories and articles:

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

type Connection struct {

	// Channel is the Slack channel name with the "#" prefix to post messages
	Channel string

	// VerificationToken is the token to verify interaction callbacks
	VerificationToken string

	// BotUserOAuthAccessToken can be obtained from https://api.slack.com/apps/<APP ID>/oauth?
	BotUserOAuthAccessToken string

	Client *slack.Client

	HandleSlashCommand func(*Connection, string, slack.SlashCommand) string
	// contains filtered or unexported fields
}

func New

func New(triggerCmd, botUserOAuthAccessToken string, verificationToken string, callback func(*Connection, string, slack.SlashCommand) string) *Connection

func (*Connection) Notify

func (conn *Connection) Notify(n Notification) error

func (*Connection) RegisterInteractionCallbackHandler

func (conn *Connection) RegisterInteractionCallbackHandler(callbackID string, callback InteractionCallbackHandler)

func (*Connection) Run

func (conn *Connection) Run() error

func (*Connection) Select

func (conn *Connection) Select(sel Selection) (*string, error)

type HTTPHandler

type HTTPHandler interface {
	ServeHTTP(w http.ResponseWriter, r *http.Request)
}

type InteractionCallbackHandler

type InteractionCallbackHandler func(slack.InteractionCallback) (interface{}, error)

type InteractionsHandler

type InteractionsHandler func(callback slack.InteractionCallback) (interface{}, error)

type Notification

type Notification struct {
	Text string
}

type Selection

type Selection struct {
	Options []string
}

Jump to

Keyboard shortcuts

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