My bot joins my chat perfectly and respond any other commands but uptime command doesn’t work. I’m very new to this chat bot thing.
Error I got:
Traceback (most recent call last):
File “./bot.py”, line 152, in
get_stream_uptime()
File “./bot.py”, line 39, in get_stream_uptime
if get_stream_status():
File “./bot.py”, line 35, in get_stream_status
if online_data[‘stream’] != None:
KeyError: ‘stream’
If you haven’t already, I would change your password if you put it on a public paste site – And probably regenerate your applications secret key to be safe. (Anybody who subscribes to emails from twitch dev forums still has access to the password.)
Re: The original post,
If the stream is offline it returns a null object, not a stream object (you will also get a null object if you had a web exception, such as not passing a ClientID]. You need to check if your api object is null first, and if not, THEN do your checks.
I would recommend also catching web exceptions (whatever that looks like in python) and printing the http status code + error message if you get one.
Re: @BarryCarlyon 's point, you need to either send your ClientID as a header value in your api request, or as a ?client_id=xxxxxx at the end of the url.