|
|
@ -3,6 +3,9 @@ package main |
|
|
|
import ( |
|
|
|
import ( |
|
|
|
"fmt" |
|
|
|
"fmt" |
|
|
|
"os" |
|
|
|
"os" |
|
|
|
|
|
|
|
"os/signal" |
|
|
|
|
|
|
|
"syscall" |
|
|
|
|
|
|
|
"time" |
|
|
|
|
|
|
|
|
|
|
|
"github.com/kf5grd/keybasebot" |
|
|
|
"github.com/kf5grd/keybasebot" |
|
|
|
bot "github.com/kf5grd/keybasebot" |
|
|
|
bot "github.com/kf5grd/keybasebot" |
|
|
@ -39,7 +42,6 @@ func main() { |
|
|
|
bot: b, |
|
|
|
bot: b, |
|
|
|
} |
|
|
|
} |
|
|
|
b.LogWriter = w |
|
|
|
b.LogWriter = w |
|
|
|
|
|
|
|
|
|
|
|
// register the bot commands
|
|
|
|
// register the bot commands
|
|
|
|
b.Commands = append(b.Commands, |
|
|
|
b.Commands = append(b.Commands, |
|
|
|
keybasebot.BotCommand{ |
|
|
|
keybasebot.BotCommand{ |
|
|
@ -48,7 +50,17 @@ func main() { |
|
|
|
Run: keybasebot.Adapt(sendPong, keybasebot.MessageType("text"), keybasebot.CommandPrefix("!ping")), |
|
|
|
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
|
|
|
|
// then run
|
|
|
|
b.Run() |
|
|
|
b.Run() |
|
|
|
} |
|
|
|
} |
|
|
|