From 76dba086b36e1d4d0eec0c5cd131f06309a77239 Mon Sep 17 00:00:00 2001 From: Mallory Hancock Date: Sat, 2 Mar 2019 10:47:02 -0800 Subject: [PATCH] hotfix for message too long --- pinhook/bot.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/pinhook/bot.py b/pinhook/bot.py index 22750c2..c24d67a 100644 --- a/pinhook/bot.py +++ b/pinhook/bot.py @@ -248,14 +248,18 @@ 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 c.MessageTooLong: + self.logger.error('output message too long: {}'.format(msg)) 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 c.MessageTooLong: + self.logger.error('output message too long: {}'.format(msg)) else: self.logger.warning("Unsupported output type '{}'".format(output.msg_type)) time.sleep(.5)