gempir/go-twitch-irc

Bot stops listen messages after while

Satont opened this issue · 5 comments

Satont commented

I'm joining 200+ channels via 1 client, with followed code (cutted message handler):

go func() {
		for {
			token, err := tokensGrpc.RequestBotToken(
				context.Background(), &tokens.GetBotTokenRequest{
					BotId: opts.Model.ID,
				},
			)
			client.Client.SetIRCToken(fmt.Sprintf("oauth:%s", token.AccessToken))
			err = client.Connect()
			if err != nil {
				opts.Logger.Sugar().Error(err)
			}
		}
	}()

But after while bot stops listening chat messages, with no errors in console.

Can it be because i joined to many channels on 1 instance, or what should be the reason?

Also, how i can debug it, or if channels counts matters, how would you recommend scale my connections? I never done that, would appreciate help.

gempir commented

I join a bit more than 200 channels with my bot.

Only thing I do maybe differently is waiting for the connection to be ready? I'm not sure what else is different.

https://github.com/gempir/gempbot/blob/main/internal/bot/bot.go#L100

Satont commented

Only thing I do maybe differently is waiting for the connection to be ready?

Yea, i'm calling Join before bot actually connected. But isnt library handles that? Because even readme saying it's ok:

func main() {
	// or client := twitch.NewAnonymousClient() for an anonymous user (no write capabilities)
	client := twitch.NewClient("yourtwitchusername", "oauth:123123123")

	client.OnPrivateMessage(func(message twitch.PrivateMessage) {
		fmt.Println(message.Message)
	})

	client.Join("gempir")

	err := client.Connect()
	if err != nil {
		panic(err)
	}
}
gempir commented

yeah it should.

Satont commented

yeah it should.

So, is there way to debug why my bot stoping listening messages after while?

gempir commented

Sorry I can't really offer more support, you'll have to figure out on your own.