From a1e0da464ee61c127b2eae9e8ccbc96cc908687e Mon Sep 17 00:00:00 2001 From: gempir Date: Wed, 21 Dec 2022 17:30:21 +0100 Subject: [PATCH] prevent double joins accross workers, reduce log spam ab it --- bot/main.go | 7 ++++++- helix/user.go | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/bot/main.go b/bot/main.go index d1a55e3..536181b 100644 --- a/bot/main.go +++ b/bot/main.go @@ -108,7 +108,11 @@ func (b *Bot) Join(channelNames ...string) { // already joined but join again in case it was a temporary ban worker.client.Join(channel) joined = true - } else if len(worker.joinedChannels) < 50 { + } + } + + for _, worker := range b.worker { + if len(worker.joinedChannels) < 50 { log.Info("[bot] joining " + channel) worker.client.Join(channel) worker.joinedChannels[channel] = true @@ -116,6 +120,7 @@ func (b *Bot) Join(channelNames ...string) { break } } + if !joined { client := b.newClient() go client.Connect() diff --git a/helix/user.go b/helix/user.go index eccef7b..2884859 100644 --- a/helix/user.go +++ b/helix/user.go @@ -140,7 +140,7 @@ func (c *Client) GetUsersByUserIds(userIDs []string) (map[string]UserData, error for _, id := range userIDs { value, ok := userCacheByID.Load(id) if !ok { - log.Warningf("Could not find userId, channel might be banned: %s", id) + log.Debugf("Could not find userId, channel might be banned: %s", id) continue } result[id] = *(value.(*UserData)) @@ -198,7 +198,7 @@ func (c *Client) GetUsersByUsernames(usernames []string) (map[string]UserData, e username = strings.ToLower(username) value, ok := userCacheByUsername.Load(username) if !ok { - log.Warningf("Could not find username, channel might be banned: %s", username) + log.Debugf("Could not find username, channel might be banned: %s", username) continue } result[username] = *(value.(*UserData))