Hotfix/too big error (#63)

* hotfix for message too long

* fix spacing error

* fix error name

* add breaks
pull/74/head
Mal Hancock 2019-03-02 11:02:14 -08:00 committed by GitHub
parent 23f5c76f13
commit 3b07ed99b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 5 deletions

View File

@ -248,14 +248,20 @@ class Bot(irc.bot.SingleServerIRCBot):
if not output.msg: if not output.msg:
return return
for msg in output.msg: for msg in output.msg:
if len(msg.encode('UTF-8')) > 512: if output.msg_type == pinhook.plugin.OutputType.Message:
self.logger.error('output message too long: {}'.format(msg))
elif output.msg_type == pinhook.plugin.OutputType.Message:
self.logger.debug('output message: {}'.format(msg)) self.logger.debug('output message: {}'.format(msg))
try:
c.privmsg(chan, msg) 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: elif output.msg_type == pinhook.plugin.OutputType.Action:
self.logger.debug('output action: {}'.format(msg)) self.logger.debug('output action: {}'.format(msg))
try:
c.action(chan, msg) c.action(chan, msg)
except irc.client.MessageTooLong:
self.logger.error('output message too long: {}'.format(msg))
break
else: else:
self.logger.warning("Unsupported output type '{}'".format(output.msg_type)) self.logger.warning("Unsupported output type '{}'".format(output.msg_type))
time.sleep(.5) time.sleep(.5)