From 1bf746791e14151e7f5806a72448bfd305a470ac Mon Sep 17 00:00:00 2001 From: Thomas Coppi Date: Fri, 27 Apr 2007 22:02:28 -0600 Subject: [PATCH] Add an 'iscmd' field to the list passed to registered events. Fixes a problem that can occur if the only word on a line is the same as a command a registered event is looking for. --- scrappy.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/scrappy.py b/scrappy.py index e24040a..79017b3 100755 --- a/scrappy.py +++ b/scrappy.py @@ -13,7 +13,7 @@ def debug(msg): def externfunc(c,list): print "Externfunc" def deadline(c,list): - if list[3] == "deadline": + if list[4] == "deadline" and list[3]: c.privmsg(list[0],"The deadline for SoC has expired.") class scrappy: @@ -98,6 +98,7 @@ class scrappy: def on_pubmsg(self, c, event): arg = event.arguments()[0] + iscmd = False nick = irclib_scrappy.nm_to_n(event.source()) user = irclib_scrappy.nm_to_u(event.source()) @@ -105,16 +106,18 @@ class scrappy: if arg[0] == self.cmdchar: cmd = arg[1:] - else + iscmd = True + else: cmd = arg #dispatch the command for func in self.pubmsg_events: - func(c,[nick,user,host,cmd]) + func(c,[nick,user,host,iscmd,cmd]) def on_privmsg(self, c, event): cmd = event.arguments()[0] - + iscmd = False + nick = irclib_scrappy.nm_to_n(event.source()) user = irclib_scrappy.nm_to_u(event.source()) host = irclib_scrappy.nm_to_h(event.source()) @@ -123,10 +126,11 @@ class scrappy: c.privmsg(nick,"You privmsged me, you don't need to " + "prefix commands with %s" % self.cmdchar) cmd = cmd[1:] + iscmd = True #dispatch the command for func in self.privmsg_events: - func(c,[nick,user,host,cmd]) + func(c,[nick,user,host,iscmd,cmd]) def on_disconnect(self, c, event): -- 2.11.4.GIT