Example #1
0
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")
}
Example #2
0
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)
}