func TestCheckMessage(t *testing.T) { p := echo.NewPlugin() ok, _ := p.CheckMessage(testEvent, testEvent.BaseText()) if !ok { t.Errorf("ERROR check = NG") } }
func TestDoAction(t *testing.T) { p := echo.NewPlugin() next := p.DoAction(testEvent, testEvent.BaseText()) if next != true { t.Errorf("ERROR next != true") } }
func TestSysstdBuildPluginsHelp(t *testing.T) { botCtx, err := slackbot.NewBotContext("hoge_token") if err != nil { t.Error(err) } botCtx.AddPlugin("echo", echo.NewPlugin()) p := sysstd.NewPlugin(botCtx.PluginManager()) ev := plugins.NewTestEvent("botID help") p.DoAction(ev, "help") }
func main() { var token string flag.StringVar(&token, "token", os.Getenv("SLACK_BOT_TOKEN"), "SlackのBotToken") flag.Parse() bot, err := slackbot.NewBotContext(token) if err != nil { panic(err) } bot.AddPlugin("echo", echo.NewPlugin()) bot.Run(func(event plugins.BotEvent) { if event.ChannelName() == "#general" { event.Reply("OK") } }) http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { w.Write([]byte("OK")) }) http.ListenAndServe(":8000", nil) }