From 6b75be6e60a3e6fe32da4a9fbd7f05e94d59e355 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Thu, 3 Feb 2005 20:13:49 +0000 Subject: [PATCH] Changed supybot.protocols.irc.queueDuplicateMessages. Changed supybot.protocols.irc.queueDuplicateMessages to supybot.protocols.irc.refuseToQueueDuplicateMessages, and changed the default to be to allow duplicate messages, rather than to reject them. --- src/conf.py | 8 ++++---- src/irclib.py | 2 +- test/test_irclib.py | 16 +++++++++++----- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/conf.py b/src/conf.py index d09a4811b..0cb33d411 100644 --- a/src/conf.py +++ b/src/conf.py @@ -917,12 +917,12 @@ registerGlobalValue(supybot.protocols.irc.ping, 'interval', registry.Integer(120, """Determines the number of seconds between sending pings to the server, if pings are being sent to the server.""")) -registerGlobalValue(supybot.protocols.irc, 'queueDuplicateMessages', - registry.Boolean(False, """Determines whether the bot will allow duplicate +registerGlobalValue(supybot.protocols.irc, 'refuseToQueueDuplicateMessages', + registry.Boolean(False, """Determines whether the bot will refuse duplicate messages to be queued for delivery to the server. This is a safety mechanism put in place to prevent plugins from sending the same message - multiple times; most of the time it doesn't matter, but when it does, - you'll probably want it to disallowed.""")) + multiple times; most of the time it doesn't matter, unless you're doing + certain kinds of plugin hacking.""")) ### # supybot.protocols.http diff --git a/src/irclib.py b/src/irclib.py index 8bc88e54a..6fb93e9d2 100644 --- a/src/irclib.py +++ b/src/irclib.py @@ -166,7 +166,7 @@ class IrcMsgQueue(object): def enqueue(self, msg): """Enqueues a given message.""" if msg in self.msgs and \ - not conf.supybot.protocols.irc.queueDuplicateMessages(): + conf.supybot.protocols.irc.refuseToQueueDuplicateMessages(): s = str(msg).strip() log.info('Not adding message %q to queue, already added.', s) return False diff --git a/test/test_irclib.py b/test/test_irclib.py index d6216c1fd..ea7bd9869 100644 --- a/test/test_irclib.py +++ b/test/test_irclib.py @@ -127,11 +127,17 @@ class IrcMsgQueueTestCase(SupyTestCase): self.assertEqual(self.msgs[1], q.dequeue()) def testNoIdenticals(self): - q = irclib.IrcMsgQueue() - q.enqueue(self.msg) - q.enqueue(self.msg) - self.assertEqual(self.msg, q.dequeue()) - self.failIf(q) + configVar = conf.supybot.protocols.irc.refuseToQueueDuplicateMessages + original = configVar() + try: + configVar.setValue(True) + q = irclib.IrcMsgQueue() + q.enqueue(self.msg) + q.enqueue(self.msg) + self.assertEqual(self.msg, q.dequeue()) + self.failIf(q) + finally: + configVar.setValue(original) def testJoinBeforeWho(self): q = irclib.IrcMsgQueue()