From 241084db6fd0198e30cfb018d7ede28ce611cb9f Mon Sep 17 00:00:00 2001 From: mutantmonkey Date: Thu, 22 Sep 2011 23:32:24 -0400 Subject: [PATCH] fix intermittent disconnections --- bot.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bot.py b/bot.py index 3c34950..590fa13 100755 --- a/bot.py +++ b/bot.py @@ -13,11 +13,13 @@ import irc home = os.getcwd() def decode(bytes): - if type(bytes) == str: + if not bytes or type(bytes) == str: return bytes - try: text = bytes.decode('utf-8') + try: + text = bytes.decode('utf-8') except UnicodeDecodeError: - try: text = bytes.decode('iso-8859-1') + try: + text = bytes.decode('iso-8859-1') except UnicodeDecodeError: text = bytes.decode('cp1252') return text