bobo is Slack Bot Kit with flexibility for Golang.
$ go get -u github.com/eure/bobo
$ make build
for Raspberry Pi
$ make build-arm6
SLACK_RTM_TOKEN=xoxb-0000... ./bin/bobo
Name | Description |
---|---|
SLACK_RTM_TOKEN |
Slack Bot Token |
SLACK_BOT_TOKEN |
Slack Bot Token |
SLACK_TOKEN |
Slack Bot Token |
BOBO_DEBUG |
Flag for debug logging. Set boolean like value. |
At first, create your own command.
import (
"github.com/eure/bobo/command"
)
// EchoCommand is an example command.
// This command says same text.
var EchoCommand = command.BasicCommandTemplate{
Help: "reply same text",
MentionCommand: "echo",
GenerateFn: func(d command.CommandData) command.Command {
c := command.Command{}
if d.TextOther == "" {
return c
}
text := fmt.Sprintf("<@%s> %s", d.SenderID, d.TextOther)
task := command.NewReplyEngineTask(d.Engine, d.Channel, text)
c.Add(task)
return c
},
}
Then create main.go
and add the command,
package main
import (
"github.com/eure/bobo"
"github.com/eure/bobo/command"
"github.com/eure/bobo/engine/slack"
"github.com/eure/bobo/log"
)
// Entry Point
func main() {
bobo.Run(bobo.RunOption{
Engine: &slack.SlackEngine{},
Logger: &log.StdLogger{
IsDebug: bobo.IsDebug(),
},
CommandSet: command.NewCommandSet(
// defalt example commands
command.PingCommand,
command.HelpCommand,
// add your original commands
EchoCommand,
),
})
}
And run it with Slack Token,
SLACK_RTM_TOKEN=xoxb-0000... go run ./main.go
bobo supports self-upgrading binary using jpillora/overseer.
Set these option on RunOption
,
UseUpgrade = true
UpgradeFetcher = fetcher.Interface
(see document)
package main
import (
"time"
"github.com/jpillora/overseer/fetcher"
"github.com/eure/bobo"
"github.com/eure/bobo/command"
"github.com/eure/bobo/engine/slack"
"github.com/eure/bobo/log"
)
// Entry Point
func main() {
bobo.Run(bobo.RunOption{
Engine: &slack.SlackEngine{},
Logger: &log.StdLogger{
IsDebug: bobo.IsDebug(),
},
CommandSet: command.NewCommandSet(),
// Set upgrade options
UseUpgrade: true,
UpgradeFetcher: &fetcher.File{
Path: "/usr/local/bin/my-bobo-binary", // watch the path for updating
Interval: 60 * time.Second,
},
})
}
- Slack
- Reply message
- Reply message as a thread
- Add reaction
- Upload file
- GoogleHome
This project depends on these awesome libraries,