catch actions and don't send output to cmds during action (#20)

closes issue #18
pull/22/head
M. Hancock 2018-01-12 11:17:12 -08:00 committed by GitHub
parent 0c3e4e08ee
commit 311457148e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 2 deletions

View File

@ -25,7 +25,7 @@ class Message:
if text: if text:
self.text = text self.text = text
if not (cmd or text): if not (cmd or text):
print('Please pass Message a command or text!') raise TypeError('missing cmd or text parameter')
class Bot(irc.bot.SingleServerIRCBot): class Bot(irc.bot.SingleServerIRCBot):
@ -127,6 +127,9 @@ class Bot(irc.bot.SingleServerIRCBot):
def on_privmsg(self, c, e): def on_privmsg(self, c, e):
self.process_command(c, e) self.process_command(c, e)
def on_action(self, c, e):
self.process_command(c, e)
def process_command(self, c, e): def process_command(self, c, e):
nick = e.source.nick nick = e.source.nick
text = e.arguments[0] text = e.arguments[0]
@ -134,6 +137,9 @@ class Bot(irc.bot.SingleServerIRCBot):
chan = nick chan = nick
else: else:
chan = e.target chan = e.target
if e.type == 'action':
cmd = ''
else:
cmd = text.split(' ')[0] cmd = text.split(' ')[0]
self.logger.debug( self.logger.debug(
'Message info: channel: {}, nick: {}, cmd: {}, text: {}'.format(chan, nick, cmd, text) 'Message info: channel: {}, nick: {}, cmd: {}, text: {}'.format(chan, nick, cmd, text)