From a74173fee2d09f92ca81a5c29ada87e84cb197af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juhani=20Krekel=C3=A4?= Date: Sat, 20 Jan 2018 16:49:37 +0200 Subject: [PATCH] Replace irc.bot_response and irc.bot_response_bytes with an interface that autoconverts if needed --- ircbot.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ircbot.py b/ircbot.py index 3adbb5d..17b602c 100644 --- a/ircbot.py +++ b/ircbot.py @@ -75,11 +75,10 @@ class API: self.serverthread_object.send_line_raw(line) def bot_response(self, recipient, message): - """Prefix message with ZWSP and convert from unicode to bytestring.""" - self.msg(recipient, ('\u200b' + message).encode('utf-8')) + """Prefix message with ZWSP and convert from unicode to bytestring if necessary.""" + if isinstance(message, str): + message = message.encode('utf-8') - def bot_response_bytes(self, recipient, message): - """Prefix message (bytestring) with ZWSP""" self.msg(recipient, '\u200b'.encode('utf-8') + message) def nick(self, nick):