irclib: Apply changes to supybot.protocols.irc.maxHistoryLength immediately.

This commit is contained in:
Valentin Lorentz 2012-12-27 12:24:24 +00:00
parent cab1830140
commit 1d2eefe880
8 changed files with 19 additions and 25 deletions

View File

@ -955,8 +955,7 @@ msgstr ""
#: ../src/conf.py:995 #: ../src/conf.py:995
msgid "" msgid ""
"Determines how many old messages the bot will\n" "Determines how many old messages the bot will\n"
" keep around in its history. Changing this variable will not take effect\n" " keep around in its history."
" until the bot is restarted."
msgstr "" msgstr ""
#: ../src/conf.py:1000 #: ../src/conf.py:1000

View File

@ -1503,13 +1503,9 @@ msgstr ""
#: src/conf.py:1019 #: src/conf.py:1019
msgid "" msgid ""
"Determines how many old messages the bot will\n" "Determines how many old messages the bot will\n"
" keep around in its history. Changing this variable will not take " " keep around in its history."
"effect\n"
" until the bot is restarted."
msgstr "" msgstr ""
"Määrittää kuinka vanhoja viestejä botti pitää historiassaan. Tämän " "Määrittää kuinka vanhoja viestejä botti pitää historiassaan."
"asetusarvon\n"
" muuttaminen ei vaikuta ennen uudelleenkäynnistystä."
#: src/conf.py:1024 #: src/conf.py:1024
#, fuzzy #, fuzzy

View File

@ -992,9 +992,8 @@ msgstr "Détermine quelle vhost le bot bindera avant de se connecter au serve
#: ../src/conf.py:1019 #: ../src/conf.py:1019
msgid "" msgid ""
"Determines how many old messages the bot will\n" "Determines how many old messages the bot will\n"
" keep around in its history. Changing this variable will not take effect\n" " keep around in its history."
" until the bot is restarted." msgstr "Détermine combien de vieux messages le bot gardera dans son historique."
msgstr "Détermine combien de vieux messages le bot gardera dans son historique. Changer cette variable ne prend effet qu'après avoir redémarré le bot."
#: ../src/conf.py:1024 #: ../src/conf.py:1024
msgid "" msgid ""

View File

@ -1183,11 +1183,9 @@ msgstr ""
#: src/conf.py:1019 #: src/conf.py:1019
msgid "" msgid ""
"Determines how many old messages the bot will\n" "Determines how many old messages the bot will\n"
" keep around in its history. Changing this variable will not take effect\n" " keep around in its history."
" until the bot is restarted."
msgstr "" msgstr ""
"Determina quanti messaggi vecchi terrà il bot nella cronologia. La modifica\n" "Determina quanti messaggi vecchi terrà il bot nella cronologia."
" di questa variabile non avrà effetto finché non si riavvia il bot."
#: src/conf.py:1024 #: src/conf.py:1024
msgid "" msgid ""

View File

@ -982,8 +982,7 @@ msgstr ""
#: src/conf.py:1019 #: src/conf.py:1019
msgid "" msgid ""
"Determines how many old messages the bot will\n" "Determines how many old messages the bot will\n"
" keep around in its history. Changing this variable will not take effect\n" " keep around in its history."
" until the bot is restarted."
msgstr "" msgstr ""
#: src/conf.py:1024 #: src/conf.py:1024

View File

@ -1038,8 +1038,7 @@ registerGlobalValue(supybot.protocols.irc, 'vhost',
registerGlobalValue(supybot.protocols.irc, 'maxHistoryLength', registerGlobalValue(supybot.protocols.irc, 'maxHistoryLength',
registry.Integer(1000, _("""Determines how many old messages the bot will registry.Integer(1000, _("""Determines how many old messages the bot will
keep around in its history. Changing this variable will not take effect keep around in its history.""")))
until the bot is restarted.""")))
registerGlobalValue(supybot.protocols.irc, 'throttleTime', registerGlobalValue(supybot.protocols.irc, 'throttleTime',
registry.Float(1.0, _("""A floating point number of seconds to throttle registry.Float(1.0, _("""A floating point number of seconds to throttle

View File

@ -346,6 +346,9 @@ class IrcState(IrcCommandDispatcher):
nicksToHostmasks=None, channels=None): nicksToHostmasks=None, channels=None):
if history is None: if history is None:
history = RingBuffer(conf.supybot.protocols.irc.maxHistoryLength()) history = RingBuffer(conf.supybot.protocols.irc.maxHistoryLength())
def resize_history():
self.history.resize(conf.supybot.protocols.irc.maxHistoryLength())
conf.supybot.protocols.irc.maxHistoryLength.addCallback(resize_history)
if supported is None: if supported is None:
supported = utils.InsensitivePreservingDict() supported = utils.InsensitivePreservingDict()
if nicksToHostmasks is None: if nicksToHostmasks is None:

View File

@ -36,10 +36,8 @@ import supybot.conf as conf
import supybot.irclib as irclib import supybot.irclib as irclib
import supybot.ircmsgs as ircmsgs import supybot.ircmsgs as ircmsgs
# The test framework used to provide these, but not it doesn't. We'll add rawmsgs = 'foo bar baz qux quux corge grault garply waldo fred'.split()
# messages to as we find bugs (if indeed we find bugs). msgs = map(lambda x:ircmsgs.privmsg('#channel', x), rawmsgs)
msgs = []
rawmsgs = []
class IrcMsgQueueTestCase(SupyTestCase): class IrcMsgQueueTestCase(SupyTestCase):
mode = ircmsgs.op('#foo', 'jemfinch') mode = ircmsgs.op('#foo', 'jemfinch')
@ -258,8 +256,7 @@ class IrcStateTestCase(SupyTestCase):
self.failUnless(st.channels['#foo'].isOp('baz')) self.failUnless(st.channels['#foo'].isOp('baz'))
def testHistory(self): def testHistory(self):
if len(msgs) < 10: assert len(msgs) >= 10
return
maxHistoryLength = conf.supybot.protocols.irc.maxHistoryLength maxHistoryLength = conf.supybot.protocols.irc.maxHistoryLength
with maxHistoryLength.context(10): with maxHistoryLength.context(10):
state = irclib.IrcState() state = irclib.IrcState()
@ -272,6 +269,10 @@ class IrcStateTestCase(SupyTestCase):
self.assertEqual(len(state.history), maxHistoryLength()) self.assertEqual(len(state.history), maxHistoryLength())
self.assertEqual(list(state.history), self.assertEqual(list(state.history),
msgs[len(msgs) - maxHistoryLength():]) msgs[len(msgs) - maxHistoryLength():])
with maxHistoryLength.context(5):
self.assertEqual(len(state.history), maxHistoryLength())
self.assertEqual(list(state.history),
msgs[len(msgs) - maxHistoryLength():])
def testWasteland005(self): def testWasteland005(self):
state = irclib.IrcState() state = irclib.IrcState()