From c2d029f9183d56d6fe9290fcae98ab2a044e0953 Mon Sep 17 00:00:00 2001 From: Gisle Aune Date: Sun, 9 Aug 2020 13:01:06 +0200 Subject: [PATCH] fix posts not being logged after logbot reconnect. --- internal/bot/bot.go | 2 ++ internal/bot/channel.go | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/bot/bot.go b/internal/bot/bot.go index 02c12db..6c291b1 100644 --- a/internal/bot/bot.go +++ b/internal/bot/bot.go @@ -53,6 +53,8 @@ func (bot *Bot) Connect(server string, ssl bool, maxRetries int) (err error) { } bot.ctx, bot.ctxCancel = context.WithCancel(bot.client.Context()) + bot.channels = make(map[string]*Channel) + retries := 0 for maxRetries == 0 || retries < maxRetries { err = bot.client.Connect(server, ssl) diff --git a/internal/bot/channel.go b/internal/bot/channel.go index 6d067e7..887f537 100644 --- a/internal/bot/channel.go +++ b/internal/bot/channel.go @@ -29,7 +29,7 @@ type Channel struct { } func newChannel(parent *Bot, name string, client *irc.Client) *Channel { - ctx, cancel := context.WithCancel(context.Background()) + ctx, cancel := context.WithCancel(parent.ctx) return &Channel{ name: name, @@ -266,7 +266,7 @@ func (channel *Channel) loop() { channel.lastPostSessionID = "" } - case <-channel.parentCtx.Done(): + case <-channel.ctx.Done(): { // Time to pack up shop. return