fix intermittent disconnections

master
mutantmonkey 2011-09-22 23:32:24 -04:00
parent e8ce0a1782
commit 241084db6f
1 changed files with 5 additions and 3 deletions

8
bot.py
View File

@ -13,11 +13,13 @@ import irc
home = os.getcwd() home = os.getcwd()
def decode(bytes): def decode(bytes):
if type(bytes) == str: if not bytes or type(bytes) == str:
return bytes return bytes
try: text = bytes.decode('utf-8') try:
text = bytes.decode('utf-8')
except UnicodeDecodeError: except UnicodeDecodeError:
try: text = bytes.decode('iso-8859-1') try:
text = bytes.decode('iso-8859-1')
except UnicodeDecodeError: except UnicodeDecodeError:
text = bytes.decode('cp1252') text = bytes.decode('cp1252')
return text return text