From 0c94d71960bc9c22f6d899cb05c00463f785e2f8 Mon Sep 17 00:00:00 2001 From: Chris Sexton <3216719+chrissexton@users.noreply.github.com> Date: Tue, 10 Jan 2023 21:36:14 -0500 Subject: [PATCH] twitch: assume defaults if twitch doesn't tell us a game --- plugins/twitch/twitch.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/plugins/twitch/twitch.go b/plugins/twitch/twitch.go index b2f2de8..e43a19b 100644 --- a/plugins/twitch/twitch.go +++ b/plugins/twitch/twitch.go @@ -475,8 +475,13 @@ func (p *Twitch) onlineCB(w http.ResponseWriter, r *http.Request) { twitcher.online = true twitcher.URL = twitcher.url() - twitcher.gameID = streams.Data.Streams[0].GameID - twitcher.Game = streams.Data.Streams[0].GameName + if len(streams.Data.Streams) > 0 { + twitcher.gameID = streams.Data.Streams[0].GameID + twitcher.Game = streams.Data.Streams[0].GameName + } else { + twitcher.gameID = "-1" + twitcher.Game = p.c.Get("twitch.unknowngame", "IDK, Twitch didn't tell me") + } if ch := p.c.Get("twitch.channel", ""); ch != "" { p.streaming(p.b.DefaultConnector(), ch, twitcher) if p.c.GetBool("twitch.irc", false) {