From 311457148e97d8cfd652b60dadc1d3a13ace3773 Mon Sep 17 00:00:00 2001 From: "M. Hancock" Date: Fri, 12 Jan 2018 11:17:12 -0800 Subject: [PATCH] catch actions and don't send output to cmds during action (#20) closes issue #18 --- pinhook/bot.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pinhook/bot.py b/pinhook/bot.py index 711bf90..c899dfd 100644 --- a/pinhook/bot.py +++ b/pinhook/bot.py @@ -25,7 +25,7 @@ class Message: if text: self.text = 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): @@ -127,6 +127,9 @@ class Bot(irc.bot.SingleServerIRCBot): def on_privmsg(self, c, e): self.process_command(c, e) + def on_action(self, c, e): + self.process_command(c, e) + def process_command(self, c, e): nick = e.source.nick text = e.arguments[0] @@ -134,7 +137,10 @@ class Bot(irc.bot.SingleServerIRCBot): chan = nick else: chan = e.target - cmd = text.split(' ')[0] + if e.type == 'action': + cmd = '' + else: + cmd = text.split(' ')[0] self.logger.debug( 'Message info: channel: {}, nick: {}, cmd: {}, text: {}'.format(chan, nick, cmd, text) )