prevent double joins accross workers, reduce log spam ab it

This commit is contained in:
gempir 2022-12-21 17:30:21 +01:00
parent 8046b1b39b
commit a1e0da464e
2 changed files with 8 additions and 3 deletions

View File

@ -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()

View File

@ -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))