0. tests for event replay Tests are now included for the event replay features. This includes many fixes on top of the last commit as well as some tweaks to config module values. 1. activity module An activity module is created to track the useractive events and provide a counter for them. It also encapsulates logic to discard old useractive events. 2. web module A web module is created. This module serves a static webpage showing runtime information. Currently it only shows a snapshot of the user activity data. It is my intention that it eventually also shows an audit log, known users and channels, uptime, and more. Future work will also be needed in order to use HTML templating so that it doesn't look so... basic. Live updates to the information may also be desired. Signed-off-by: Ava Affine <ava@sunnypup.io>
69 lines
1.3 KiB
Go
69 lines
1.3 KiB
Go
package main
|
|
|
|
import (
|
|
"flag"
|
|
"log"
|
|
|
|
"gitlab.com/whom/bingobot/internal/activity"
|
|
"gitlab.com/whom/bingobot/internal/config"
|
|
"gitlab.com/whom/bingobot/internal/discord"
|
|
"gitlab.com/whom/bingobot/internal/logging"
|
|
"gitlab.com/whom/bingobot/internal/state"
|
|
"gitlab.com/whom/bingobot/internal/web"
|
|
)
|
|
|
|
var (
|
|
token = flag.String("token", "", "Bot authentication token")
|
|
)
|
|
|
|
func main() {
|
|
var err error
|
|
|
|
err = config.Init()
|
|
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
logging.Init()
|
|
flag.Parse()
|
|
|
|
if err := state.Init(
|
|
config.Get().InMemoryEventCacheSize,
|
|
config.Get().PersistentCacheStore,
|
|
); err != nil {
|
|
log.Fatalf("couldn't initialize state engine: %s", err.Error())
|
|
}
|
|
|
|
if err := activity.Start(); err != nil {
|
|
// TODO: handle gracefully and continue?
|
|
log.Fatalf("failed to start activity module: %s", err.Error())
|
|
}
|
|
|
|
if err := web.Start(); err != nil {
|
|
log.Fatalf("failed to start local web server: %s", err.Error())
|
|
}
|
|
|
|
// start this LAST
|
|
if err := state.Start(); err != nil {
|
|
log.Fatalf("failed to start state machine: %s", err.Error())
|
|
}
|
|
defer state.Teardown()
|
|
|
|
if err := startBot(); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|
|
|
|
func startBot() error {
|
|
err := discord.Connect(*token)
|
|
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
logging.Info("shutting down gracefully", "type", "shutdown")
|
|
discord.Close()
|
|
|
|
return nil
|
|
}
|