diff --git a/royalbot.py b/royalbot.py index 1c553ca2..d7510a7b 100644 --- a/royalbot.py +++ b/royalbot.py @@ -117,10 +117,12 @@ while(True): if(steam['response']['players']): online = steam['response']['players'][0]['personastate'] name = steam['response']['players'][0]['personaname'] - if(steam['response']['players'][0]['gameextrainfo']): - ingame = steam['response']['players'][0]['gameextrainfo'] - else: + try: + steam['response']['players'][0]['gameextrainfo']) + except KeyError: ingame = None + else: + ingame = steam['response']['players'][0]['gameextrainfo'] text = "" if(online == 0): text = unichr(9898) + " Offline" @@ -136,7 +138,7 @@ while(True): text = unichr(55357) + unichr(56629) + " Disponibile per scambiare" elif(online == 6): text = unichr(55357) + unichr(56629) + " Disponibile per giocare" - if ingame: + if ingame is not None: sendMessage(name + " sta giocando a " + unichr(55357) + unichr(56628) + " " + ingame + ".", msg['chat']['id']) else: sendMessage(name + " e' " + text + ".", msg['chat']['id'])