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
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

View File

@ -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

View File

@ -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()