From d9a8cb9a124457065a9f510dba25a4a338a803ab Mon Sep 17 00:00:00 2001 From: mutantmonkey Date: Sat, 22 Oct 2011 21:12:54 -0400 Subject: [PATCH] ensure that messages are encoded in utf-8 during calls to safe() --- irc.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/irc.py b/irc.py index 6fb3740..c8da354 100755 --- a/irc.py +++ b/irc.py @@ -101,7 +101,7 @@ class Bot(asynchat.async_chat): if use_ssl: sock = ssl.wrap_socket(sock, ssl_version=ssl.PROTOCOL_TLSv1) # FIXME: ssl module does not appear to work properly with nonblocking sockets - sock.setblocking(0) + #sock.setblocking(0) self.set_socket(sock) def handle_connect(self): @@ -175,6 +175,8 @@ class Bot(asynchat.async_chat): return def safe(input): + if type(input) == str: + input = input.encode('utf-8') input = input.replace(b'\n', b'') return input.replace(b'\r', b'') self.__write((b'PRIVMSG', safe(recipient)), safe(text))