mirror of
https://git.sr.ht/~ashkeel/strimertul
synced 2024-09-18 01:50:50 +00:00
lint fixes
This commit is contained in:
parent
283648405e
commit
d13e47d3ce
3 changed files with 22 additions and 9 deletions
16
main.go
16
main.go
|
@ -25,8 +25,6 @@ import (
|
|||
_ "net/http/pprof"
|
||||
)
|
||||
|
||||
const AppTitle = "strimertül"
|
||||
|
||||
const AppHeader = `
|
||||
_ _ _ O O _
|
||||
__| |_ _ _(_)_ __ ___ _ _| |_ _ _| |
|
||||
|
@ -35,8 +33,6 @@ const AppHeader = `
|
|||
|
||||
var appVersion = "v0.0.0-UNKNOWN"
|
||||
|
||||
const DefaultBind = "localhost:4337"
|
||||
|
||||
//go:embed frontend/dist/*
|
||||
var frontend embed.FS
|
||||
|
||||
|
@ -100,7 +96,11 @@ func main() {
|
|||
// Loading routine
|
||||
db, err := database.Open(badger.DefaultOptions(*dbdir), manager)
|
||||
failOnError(err, "Could not open DB")
|
||||
defer db.Close()
|
||||
defer func() {
|
||||
if err := db.Close(); err != nil {
|
||||
log.WithError(err).Error("Could not close DB")
|
||||
}
|
||||
}()
|
||||
|
||||
if *cleanup {
|
||||
// Run DB garbage collection until it's done
|
||||
|
@ -133,7 +133,11 @@ func main() {
|
|||
// Create logger and endpoints
|
||||
httpServer, err := http.NewServer(manager)
|
||||
failOnError(err, "Could not initialize http server")
|
||||
defer httpServer.Close()
|
||||
defer func() {
|
||||
if err := httpServer.Close(); err != nil {
|
||||
log.WithError(err).Error("Could not close DB")
|
||||
}
|
||||
}()
|
||||
|
||||
fedir, _ := fs.Sub(frontend, "frontend/dist")
|
||||
httpServer.SetFrontend(fedir)
|
||||
|
|
|
@ -38,9 +38,19 @@ func NewServer(manager *modules.Manager) (*Server, error) {
|
|||
server: &http.Server{},
|
||||
}
|
||||
err := db.GetJSON(ServerConfigKey, &server.Config)
|
||||
if err != nil {
|
||||
// Initialize with default config
|
||||
server.Config = ServerConfig{
|
||||
Bind: "localhost:4337",
|
||||
EnableStaticServer: false,
|
||||
KVPassword: "",
|
||||
}
|
||||
// Save
|
||||
err = db.PutJSON(ServerConfigKey, server.Config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
server.hub, err = kv.NewHub(db.Client(), kv.HubOptions{
|
||||
Password: server.Config.KVPassword,
|
||||
|
|
|
@ -34,7 +34,6 @@ type BotTimerModule struct {
|
|||
lastTrigger map[string]time.Time
|
||||
bot *Bot
|
||||
messages [AverageMessageWindow]int
|
||||
lastMinute int
|
||||
mu sync.Mutex
|
||||
startTime time.Time
|
||||
}
|
||||
|
@ -106,7 +105,7 @@ func (m *BotTimerModule) runTimers() {
|
|||
defer m.mu.Unlock()
|
||||
for name, timer := range m.Config.Timers {
|
||||
// Must be enabled
|
||||
if timer.Enabled != true {
|
||||
if !timer.Enabled {
|
||||
continue
|
||||
}
|
||||
// Check if enough time has passed
|
||||
|
|
Loading…
Reference in a new issue