From fe8d683eb33790d74f3b29c4db46215ecd78494c Mon Sep 17 00:00:00 2001 From: ak Date: Tue, 20 Oct 2026 17:37:50 -0700 Subject: [PATCH] Preserve countdown ordering at zero delay --- plugins/doobie.go | 3 ++- plugins/doobie_test.go | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/doobie.go b/plugins/doobie.go index b6ca3ec..02266ad 100644 --- a/plugins/doobie.go +++ b/plugins/doobie.go @@ -200,10 +200,11 @@ func (p *Doobie) advance(b *bot.Bot, channelKey string, sequence *doobieSequence return } line := doobieCountdownSteps[sequence.step] - sequence.timer = time.AfterFunc(p.delay, func() { p.advance(b, channelKey, sequence) }) p.mu.Unlock() b.Send(sequence.target, line) + // Enqueue this step before the next timer can run, including zero delay. + p.schedule(b, channelKey, sequence) } func (p *Doobie) randomClosingLine() string { diff --git a/plugins/doobie_test.go b/plugins/doobie_test.go index cff6ae7..e6a99db 100644 --- a/plugins/doobie_test.go +++ b/plugins/doobie_test.go @@ -103,6 +103,7 @@ func TestDoobieSequenceSendsFourSingleLineMessages(t *testing.T) { b := bot.New(cfg, nil, nil, zap.NewNop()) // Replace the queue with a fast capture queue so the test does not depend on // an IRC connection or the production pacing rate. + b.Queue.Drain(context.Background()) b.Queue = bot.NewQueue(1000, 20, func(message bot.Outgoing) { sent <- message.Text }) p := &Doobie{} if err := p.Init(bot.PluginConfig{"countdown_delay_seconds": 0, "cooldown_seconds": 1}, nil); err != nil {