Daily Archives: 14.04.2020
Go library for creating slack bots
You can use it like that:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
package main import ( "context" "github.com/shomali11/slacker" "log" ) func main() { bot := slacker.NewClient("<YOUR SLACK BOT TOKEN>") definition := &slacker.CommandDefinition{ Handler: func(request slacker.Request, response slacker.ResponseWriter) { response.Reply("pong") }, } bot.Command("ping", definition) ctx, cancel := context.WithCancel(context.Background()) defer cancel() err := bot.Listen(ctx) if err != nil { log.Fatal(err) } } |
https://github.com/shomali11/slacker