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.
This commit is contained in:
Jeremy Fincher 2005-02-03 20:13:49 +00:00
parent f930913b05
commit 6b75be6e60
3 changed files with 16 additions and 10 deletions

View File

@ -917,12 +917,12 @@ registerGlobalValue(supybot.protocols.irc.ping, 'interval',
registry.Integer(120, """Determines the number of seconds between sending registry.Integer(120, """Determines the number of seconds between sending
pings to the server, if pings are being sent to the server.""")) pings to the server, if pings are being sent to the server."""))
registerGlobalValue(supybot.protocols.irc, 'queueDuplicateMessages', registerGlobalValue(supybot.protocols.irc, 'refuseToQueueDuplicateMessages',
registry.Boolean(False, """Determines whether the bot will allow duplicate registry.Boolean(False, """Determines whether the bot will refuse duplicate
messages to be queued for delivery to the server. This is a safety 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 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, multiple times; most of the time it doesn't matter, unless you're doing
you'll probably want it to disallowed.""")) certain kinds of plugin hacking."""))
### ###
# supybot.protocols.http # supybot.protocols.http

View File

@ -166,7 +166,7 @@ class IrcMsgQueue(object):
def enqueue(self, msg): def enqueue(self, msg):
"""Enqueues a given message.""" """Enqueues a given message."""
if msg in self.msgs and \ if msg in self.msgs and \
not conf.supybot.protocols.irc.queueDuplicateMessages(): conf.supybot.protocols.irc.refuseToQueueDuplicateMessages():
s = str(msg).strip() s = str(msg).strip()
log.info('Not adding message %q to queue, already added.', s) log.info('Not adding message %q to queue, already added.', s)
return False return False

View File

@ -127,11 +127,17 @@ class IrcMsgQueueTestCase(SupyTestCase):
self.assertEqual(self.msgs[1], q.dequeue()) self.assertEqual(self.msgs[1], q.dequeue())
def testNoIdenticals(self): def testNoIdenticals(self):
configVar = conf.supybot.protocols.irc.refuseToQueueDuplicateMessages
original = configVar()
try:
configVar.setValue(True)
q = irclib.IrcMsgQueue() q = irclib.IrcMsgQueue()
q.enqueue(self.msg) q.enqueue(self.msg)
q.enqueue(self.msg) q.enqueue(self.msg)
self.assertEqual(self.msg, q.dequeue()) self.assertEqual(self.msg, q.dequeue())
self.failIf(q) self.failIf(q)
finally:
configVar.setValue(original)
def testJoinBeforeWho(self): def testJoinBeforeWho(self):
q = irclib.IrcMsgQueue() q = irclib.IrcMsgQueue()