From 0a2304021a5b4d94a370fe8d6f629fb144cde93f Mon Sep 17 00:00:00 2001 From: Sridhar Ratna Date: Wed, 2 Jan 2008 04:18:10 +0000 Subject: [PATCH] limit limitFreq to per channel --- plugins.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/plugins.py b/plugins.py index 0582c1f..1f3874a 100644 --- a/plugins.py +++ b/plugins.py @@ -60,12 +60,13 @@ def limitFreq(secs, msg=None): """ Limit the frequency of execution of the function to avoid IRC spamming """ - lastmsg = [None] + lastmsg = {} def decorator(func): def proxy(self, arg=None): now = datetime.now() - if lastmsg[0] is not None: - diff = now - lastmsg[0] + last = lastmsg.get(self.channel, None) + if last is not None: + diff = now - last if diff.seconds < secs: log.msg('too quick!') if msg: @@ -73,7 +74,7 @@ def limitFreq(secs, msg=None): return func(self, arg) - lastmsg[0] = now + lastmsg[self.channel] = now return decorate(proxy, func) return decorator @@ -184,7 +185,7 @@ class Commands(BotActions): def cmd_source(self, args=None): "how to access lusty's source code" - self.toUser(SOURCE) + self.toChannel(SOURCE) def cmd_tell(self, args=None): if args: -- 2.11.4.GIT