hotfix for message too long

pull/63/head
Mallory Hancock 2019-03-02 10:47:02 -08:00
parent 23f5c76f13
commit 76dba086b3
1 changed files with 9 additions and 5 deletions

View File

@ -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)