From 3b07ed99b2364b5bfe7c6ef671185e0dbc4902bd Mon Sep 17 00:00:00 2001 From: Mal Hancock Date: Sat, 2 Mar 2019 11:02:14 -0800 Subject: [PATCH] Hotfix/too big error (#63) * hotfix for message too long * fix spacing error * fix error name * add breaks --- pinhook/bot.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/pinhook/bot.py b/pinhook/bot.py index 22750c2..fde7725 100644 --- a/pinhook/bot.py +++ b/pinhook/bot.py @@ -248,14 +248,20 @@ class Bot(irc.bot.SingleServerIRCBot): if not output.msg: return for msg in output.msg: - if len(msg.encode('UTF-8')) > 512: - self.logger.error('output message too long: {}'.format(msg)) - elif output.msg_type == pinhook.plugin.OutputType.Message: + if output.msg_type == pinhook.plugin.OutputType.Message: self.logger.debug('output message: {}'.format(msg)) - c.privmsg(chan, msg) + try: + c.privmsg(chan, msg) + except irc.client.MessageTooLong: + self.logger.error('output message too long: {}'.format(msg)) + break elif output.msg_type == pinhook.plugin.OutputType.Action: self.logger.debug('output action: {}'.format(msg)) - c.action(chan, msg) + try: + c.action(chan, msg) + except irc.client.MessageTooLong: + self.logger.error('output message too long: {}'.format(msg)) + break else: self.logger.warning("Unsupported output type '{}'".format(output.msg_type)) time.sleep(.5)