From c23d205928499b578e0742363dbfd8dc0116f394 Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Wed, 26 May 2010 18:33:03 +0200 Subject: Replaced module's __call__ with a keyword mechanism. --- modules/tracking.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'modules/tracking.py') diff --git a/modules/tracking.py b/modules/tracking.py index 94b8d86..aa33980 100644 --- a/modules/tracking.py +++ b/modules/tracking.py @@ -54,6 +54,7 @@ class Module: def __init__(self, bot): self.setup_db() self.irc = bot + self.irc.register_keyword('!track', self) self.tracking = [] self.lc = LoopingCall(self.lc_callback) if bot: @@ -200,21 +201,18 @@ class Module: session.close() return msg - def __call__(self, nick, channel, msg): - if not msg.startswith('!track'): - return - + def keyword(self, nick, channel, kw, msg): args = msg.split() - if len(args) < 2: + if len(args) < 1: self.irc.msg(channel if not channel == self.irc.nickname else nick.split('!')[0], 'Usage: !track (start|stop|status TRACKINGNO)|list') return - mode = args[1] + mode = args[0] if mode.lower() in ('start', 'stop', 'status'): - if len(args) != 3 and mode.lower() != 'status': + if len(args) != 2 and mode.lower() != 'status': self.irc.msg(channel if not channel == self.irc.nickname else nick.split('!')[0], 'Usage: !track (start|stop|status TRACKINGNO)|list') return - code = args[2] if len(args) == 3 else '' + code = args[1] if len(args) == 2 else '' msg = None if mode.lower() == 'start': -- cgit v1.2.3