-- import "github.com/autom8ter/slasher"
func ExampleHandler()
type HandlerFunc func(s *Slasher, client *slack.Client, command *slack.SlashCommand) (interface{}, error)
A handler func is run against an incoming slack slash command. It is up to the user of this library to define their own handlers
type Slasher struct {
}
Slasher holds a slack client, a map of functions map[string]HandlerFunc and an array of allowed users
func NewSlasher(token string) *Slasher
Creates a newe slasher instance
func (s *Slasher) AddHandler(command string, function HandlerFunc)
Adds a slack slash command handler
func (s *Slasher) BashScipt(script string) ([]byte, error)
runs exec.Command("/bin/sh", "-c", script)
func (s *Slasher) CommandHandlers() []string
Names of all supported slash commands
func (s *Slasher) DeleteHandler(command string)
Deletes a handler delete(s.functions, command)
func (s *Slasher) Error(w http.ResponseWriter, err error)
Writes a wrapped Slasher error to the response
func (s *Slasher) Exec(args ...string) ([]byte, error)
runs exec.Command(args[0], args[1:]...)
func (s *Slasher) Exists(command string) bool
Checks if a function exists for the command
func (s *Slasher) HandlerFunc() http.HandlerFunc
func (s *Slasher) JSON(w http.ResponseWriter, obj interface{})
Writes pretty json to the response
func (s *Slasher) Python3Script(cmd string) ([]byte, error)
runs exec.Command("python3", "-c", cmd)
func (s *Slasher) ShellScript(script string) ([]byte, error)
exec.Command("/bin/sh", "-c", script)
func (s *Slasher) String(w http.ResponseWriter, response string)
Writes the string to the response