Topic: Add supybot.plugins.Topic.alwaysSetOnJoin.

This commit is contained in:
Valentin Lorentz 2013-08-17 17:48:07 +00:00
parent e3acc03fd6
commit b57be07f1c
3 changed files with 5 additions and 1 deletions

View File

@ -61,6 +61,9 @@ conf.registerChannelValue(Topic, 'recognizeTopiclen',
conf.registerChannelValue(Topic, 'default', conf.registerChannelValue(Topic, 'default',
registry.String('', _("""Determines what the default topic for the channel registry.String('', _("""Determines what the default topic for the channel
is. This is used by the default command to set this topic."""))) is. This is used by the default command to set this topic.""")))
conf.registerChannelValue(Topic, 'alwaysSetOnJoin',
registry.Boolean(False, _("""Determines whether the bot will set the topic
every time it joins, or only if the topic is empty.""")))
conf.registerGroup(Topic, 'undo') conf.registerGroup(Topic, 'undo')
conf.registerChannelValue(Topic.undo, 'max', conf.registerChannelValue(Topic.undo, 'max',
registry.NonNegativeInteger(10, _("""Determines the number of previous registry.NonNegativeInteger(10, _("""Determines the number of previous

View File

@ -248,7 +248,7 @@ class Topic(callbacks.Plugin):
self.log.debug('Not trying to restore topic in %s. I\'m not opped ' self.log.debug('Not trying to restore topic in %s. I\'m not opped '
'and %s is +t.', channel, channel) 'and %s is +t.', channel, channel)
return return
if c.topic == '': if c.topic == '' or self.registryValue('alwaysSetOnJoin', channel):
try: try:
topics = self.lastTopics[channel] topics = self.lastTopics[channel]
self._sendTopics(irc, channel, topics) self._sendTopics(irc, channel, topics)

View File

@ -225,6 +225,7 @@ class TopicTestCase(ChannelPluginTestCase):
finally: finally:
conf.supybot.plugins.Topic.default.setValue(original) conf.supybot.plugins.Topic.default.setValue(original)
def testTopic(self): def testTopic(self):
original = conf.supybot.plugins.Topic.format() original = conf.supybot.plugins.Topic.format()
try: try: