ensure that messages are encoded in utf-8 during calls to safe()
This commit is contained in:
4
irc.py
4
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))
|
||||
|
||||
Reference in New Issue
Block a user