fixed some ping stuff and made a cleanup
This commit is contained in:
16
main.go
16
main.go
@ -3,6 +3,9 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/kf5grd/keybasebot"
|
||||
bot "github.com/kf5grd/keybasebot"
|
||||
@ -39,7 +42,6 @@ func main() {
|
||||
bot: b,
|
||||
}
|
||||
b.LogWriter = w
|
||||
|
||||
// register the bot commands
|
||||
b.Commands = append(b.Commands,
|
||||
keybasebot.BotCommand{
|
||||
@ -48,7 +50,17 @@ func main() {
|
||||
Run: keybasebot.Adapt(sendPong, keybasebot.MessageType("text"), keybasebot.CommandPrefix("!ping")),
|
||||
},
|
||||
)
|
||||
|
||||
// catch ctrl-c so we can clean up
|
||||
c := make(chan os.Signal)
|
||||
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
|
||||
go func() {
|
||||
<-c
|
||||
b.Logger.Info("Caught SIGINT, cleaning up.")
|
||||
b.KB.ClearCommands()
|
||||
b.Logger.Info("Cleared command adverts. Bye.")
|
||||
time.Sleep(time.Second * 2)
|
||||
os.Exit(0)
|
||||
}()
|
||||
// then run
|
||||
b.Run()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user