From 6ee433112944c4854e9cecce2adc2e9c7f6a8c88 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Wed, 6 Mar 2019 17:31:25 -0800 Subject: [PATCH] Fix !uptime when not streaming --- bot.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bot.py b/bot.py index 98c64b2..a8ced32 100644 --- a/bot.py +++ b/bot.py @@ -131,7 +131,11 @@ class UptimeResponse(Response): async with aiohttp.ClientSession() as session: async with session.get(url, headers=headers) as response: text = await response.text() - start_time_s = json.loads(text)['data'][0]['started_at'] + data = json.loads(text)['data'] + if not data: + msg = 'not currently streaming!' + return PRIVMSG.format(channel=config.channel, msg=msg) + start_time_s = data[0]['started_at'] start_time = datetime.datetime.strptime( start_time_s, '%Y-%m-%dT%H:%M:%SZ', )