Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/autom8ter/slasher
slasher makes it easy to write http servers that respond to slack slash commands
https://github.com/autom8ter/slasher
go golang-library slack slack-commands
Last synced: about 2 hours ago
JSON representation
slasher makes it easy to write http servers that respond to slack slash commands
- Host: GitHub
- URL: https://github.com/autom8ter/slasher
- Owner: autom8ter
- Created: 2020-01-20T02:27:35.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-01-22T00:53:48.000Z (almost 5 years ago)
- Last Synced: 2024-06-20T10:19:22.856Z (5 months ago)
- Topics: go, golang-library, slack, slack-commands
- Language: Go
- Homepage:
- Size: 1.57 MB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# slasher
--
import "github.com/autom8ter/slasher"## Usage
#### func ExampleHandler
```go
func ExampleHandler()
```#### type HandlerFunc
```go
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
```go
type Slasher struct {
}
```Slasher holds a slack client, a map of functions map[string]HandlerFunc and an
array of allowed users#### func NewSlasher
```go
func NewSlasher(token string) *Slasher
```
Creates a newe slasher instance#### func (*Slasher) AddHandler
```go
func (s *Slasher) AddHandler(command string, function HandlerFunc)
```
Adds a slack slash command handler#### func (*Slasher) BashScipt
```go
func (s *Slasher) BashScipt(script string) ([]byte, error)
```
runs exec.Command("/bin/sh", "-c", script)#### func (*Slasher) CommandHandlers
```go
func (s *Slasher) CommandHandlers() []string
```
Names of all supported slash commands#### func (*Slasher) DeleteHandler
```go
func (s *Slasher) DeleteHandler(command string)
```
Deletes a handler delete(s.functions, command)#### func (*Slasher) Error
```go
func (s *Slasher) Error(w http.ResponseWriter, err error)
```
Writes a wrapped Slasher error to the response#### func (*Slasher) Exec
```go
func (s *Slasher) Exec(args ...string) ([]byte, error)
```
runs exec.Command(args[0], args[1:]...)#### func (*Slasher) Exists
```go
func (s *Slasher) Exists(command string) bool
```
Checks if a function exists for the command#### func (*Slasher) HandlerFunc
```go
func (s *Slasher) HandlerFunc() http.HandlerFunc
```#### func (*Slasher) JSON
```go
func (s *Slasher) JSON(w http.ResponseWriter, obj interface{})
```
Writes pretty json to the response#### func (*Slasher) Python3Script
```go
func (s *Slasher) Python3Script(cmd string) ([]byte, error)
```
runs exec.Command("python3", "-c", cmd)#### func (*Slasher) ShellScript
```go
func (s *Slasher) ShellScript(script string) ([]byte, error)
```
exec.Command("/bin/sh", "-c", script)#### func (*Slasher) String
```go
func (s *Slasher) String(w http.ResponseWriter, response string)
```
Writes the string to the response