diff --git a/locales/de.po b/locales/de.po index a2b751c57..42d84374d 100644 --- a/locales/de.po +++ b/locales/de.po @@ -955,8 +955,7 @@ msgstr "" #: ../src/conf.py:995 msgid "" "Determines how many old messages the bot will\n" -" keep around in its history. Changing this variable will not take effect\n" -" until the bot is restarted." +" keep around in its history." msgstr "" #: ../src/conf.py:1000 diff --git a/locales/fi.po b/locales/fi.po index 0dfc9326a..d3673651e 100644 --- a/locales/fi.po +++ b/locales/fi.po @@ -1503,13 +1503,9 @@ msgstr "" #: src/conf.py:1019 msgid "" "Determines how many old messages the bot will\n" -" keep around in its history. Changing this variable will not take " -"effect\n" -" until the bot is restarted." +" keep around in its history." msgstr "" -"Määrittää kuinka vanhoja viestejä botti pitää historiassaan. Tämän " -"asetusarvon\n" -" muuttaminen ei vaikuta ennen uudelleenkäynnistystä." +"Määrittää kuinka vanhoja viestejä botti pitää historiassaan." #: src/conf.py:1024 #, fuzzy diff --git a/locales/fr.po b/locales/fr.po index 7980a7fa1..1638266a9 100644 --- a/locales/fr.po +++ b/locales/fr.po @@ -992,9 +992,8 @@ msgstr "Détermine quelle vhost le bot bindera avant de se connecter au serve #: ../src/conf.py:1019 msgid "" "Determines how many old messages the bot will\n" -" keep around in its history. Changing this variable will not take effect\n" -" until the bot is restarted." -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." +" keep around in its history." +msgstr "Détermine combien de vieux messages le bot gardera dans son historique." #: ../src/conf.py:1024 msgid "" diff --git a/locales/it.po b/locales/it.po index c4e5eb139..10bb7e147 100644 --- a/locales/it.po +++ b/locales/it.po @@ -1183,11 +1183,9 @@ msgstr "" #: src/conf.py:1019 msgid "" "Determines how many old messages the bot will\n" -" keep around in its history. Changing this variable will not take effect\n" -" until the bot is restarted." +" keep around in its history." msgstr "" -"Determina quanti messaggi vecchi terrà il bot nella cronologia. La modifica\n" -" di questa variabile non avrà effetto finché non si riavvia il bot." +"Determina quanti messaggi vecchi terrà il bot nella cronologia." #: src/conf.py:1024 msgid "" diff --git a/locales/messages.pot b/locales/messages.pot index 54684508f..f07929209 100644 --- a/locales/messages.pot +++ b/locales/messages.pot @@ -982,8 +982,7 @@ msgstr "" #: src/conf.py:1019 msgid "" "Determines how many old messages the bot will\n" -" keep around in its history. Changing this variable will not take effect\n" -" until the bot is restarted." +" keep around in its history." msgstr "" #: src/conf.py:1024 diff --git a/src/conf.py b/src/conf.py index 7069f5871..99c7e2e94 100644 --- a/src/conf.py +++ b/src/conf.py @@ -1038,8 +1038,7 @@ registerGlobalValue(supybot.protocols.irc, 'vhost', registerGlobalValue(supybot.protocols.irc, 'maxHistoryLength', registry.Integer(1000, _("""Determines how many old messages the bot will - keep around in its history. Changing this variable will not take effect - until the bot is restarted."""))) + keep around in its history."""))) registerGlobalValue(supybot.protocols.irc, 'throttleTime', registry.Float(1.0, _("""A floating point number of seconds to throttle diff --git a/src/irclib.py b/src/irclib.py index 767ed552e..b46886c2d 100644 --- a/src/irclib.py +++ b/src/irclib.py @@ -346,6 +346,9 @@ class IrcState(IrcCommandDispatcher): nicksToHostmasks=None, channels=None): if history is None: 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: supported = utils.InsensitivePreservingDict() if nicksToHostmasks is None: diff --git a/test/test_irclib.py b/test/test_irclib.py index 8190ff5cd..038823496 100644 --- a/test/test_irclib.py +++ b/test/test_irclib.py @@ -36,10 +36,8 @@ import supybot.conf as conf import supybot.irclib as irclib import supybot.ircmsgs as ircmsgs -# The test framework used to provide these, but not it doesn't. We'll add -# messages to as we find bugs (if indeed we find bugs). -msgs = [] -rawmsgs = [] +rawmsgs = 'foo bar baz qux quux corge grault garply waldo fred'.split() +msgs = map(lambda x:ircmsgs.privmsg('#channel', x), rawmsgs) class IrcMsgQueueTestCase(SupyTestCase): mode = ircmsgs.op('#foo', 'jemfinch') @@ -258,8 +256,7 @@ class IrcStateTestCase(SupyTestCase): self.failUnless(st.channels['#foo'].isOp('baz')) def testHistory(self): - if len(msgs) < 10: - return + assert len(msgs) >= 10 maxHistoryLength = conf.supybot.protocols.irc.maxHistoryLength with maxHistoryLength.context(10): state = irclib.IrcState() @@ -272,6 +269,10 @@ class IrcStateTestCase(SupyTestCase): self.assertEqual(len(state.history), maxHistoryLength()) self.assertEqual(list(state.history), 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): state = irclib.IrcState()