From aa9dc12c9b4c50abf8e5381e62028a24dcd41be8 Mon Sep 17 00:00:00 2001 From: Chris Sexton Date: Mon, 30 Nov 2020 14:55:35 -0500 Subject: [PATCH] countdown: maybe use actually January --- main.go | 2 ++ plugins/countdown/countdown.go | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index 08a9bd0..03ef348 100644 --- a/main.go +++ b/main.go @@ -15,6 +15,7 @@ import ( "github.com/velour/catbase/plugins/achievements" "github.com/velour/catbase/plugins/aoc" + "github.com/velour/catbase/plugins/countdown" "github.com/velour/catbase/plugins/goals" "github.com/velour/catbase/plugins/meme" "github.com/velour/catbase/plugins/sms" @@ -152,6 +153,7 @@ func main() { b.AddPlugin(meme.New(b)) b.AddPlugin(achievements.New(b)) b.AddPlugin(sms.New(b)) + b.AddPlugin(countdown.New(b)) b.AddPlugin(gpt2.New(b)) // catches anything left, will always return true b.AddPlugin(fact.New(b)) diff --git a/plugins/countdown/countdown.go b/plugins/countdown/countdown.go index a5bc721..3d4d5f0 100644 --- a/plugins/countdown/countdown.go +++ b/plugins/countdown/countdown.go @@ -12,7 +12,8 @@ import ( "github.com/velour/catbase/config" ) -var nextYear = time.Date(time.Now().Year()+1, 0, 0, 0, 0, 0, 0, time.Local) +var nextYear = time.Date(time.Now().Year()+1, time.January, 0, 0, 0, 0, 0, time.Local) +var thisYear = time.Now().Year() type CountdownPlugin struct { b bot.Bot @@ -52,8 +53,7 @@ func (p *CountdownPlugin) newYearRollover() { logError(err, "error getting transaction") return } - year := time.Now().Year() - 1 - q := fmt.Sprintf(`insert into counter_%d select * from counter`, year) + q := fmt.Sprintf(`create table counter_%d as select * from counter`, thisYear) _, err = tx.Exec(q) if err != nil { logError(err, "error running insert into")