From 215a2b3a7689f429ebfd19f44e7a09f9461d000c Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Mon, 26 Jan 2004 19:17:59 +0000 Subject: [PATCH] Changed to registry. --- plugins/Topic.py | 23 ++++++++++------------- test/test_Topic.py | 12 ++++++++---- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/plugins/Topic.py b/plugins/Topic.py index 381baff31..4c1e8c6c1 100644 --- a/plugins/Topic.py +++ b/plugins/Topic.py @@ -46,26 +46,23 @@ import ircdb import ircmsgs import plugins import privmsgs +import registry import callbacks -import configurable -class Topic(callbacks.Privmsg, configurable.Mixin): +conf.registerPlugin('Topic') +conf.registerChannelValue(conf.supybot.plugins.Topic, 'separator', + registry.StringSurroundedBySpaces(' || ', """Determines what separator is + used between individually added topics in the channel topic.""")) + +class Topic(callbacks.Privmsg): topicFormatter = '%s (%s)' topicUnformatter = re.compile('(.*) \((\S+)\)') - configurables = configurable.Dictionary( - [('separator', configurable.SpaceSurroundedStrType, ' || ', - "The separator between individual topics in the channel topic.")] - ) - def __init__(self): - callbacks.Privmsg.__init__(self) - configurable.Mixin.__init__(self) - def _splitTopic(self, topic, channel): - separator = self.configurables.get('separator', channel) + separator = self.registryValue('separator', channel) return filter(None, topic.split(separator)) def _joinTopic(self, topics, channel): - separator = self.configurables.get('separator', channel) + separator = self.registryValue('separator', channel) return separator.join(topics) def _unformatTopic(self, topic, channel): @@ -82,7 +79,7 @@ class Topic(callbacks.Privmsg, configurable.Mixin): if the message isn't sent in the channel itself. """ topic = privmsgs.getArgs(args) - separator = self.configurables.get('separator', channel) + separator = self.registryValue('separator', channel) if separator in topic: s = 'You can\'t have %s in your topic' % separator irc.error(s) diff --git a/test/test_Topic.py b/test/test_Topic.py index 721bf93a2..731f765e4 100644 --- a/test/test_Topic.py +++ b/test/test_Topic.py @@ -81,10 +81,14 @@ class TopicTestCase(ChannelPluginTestCase, PluginDocumentation): self.assertError('topic change 0 s/baz/biff/') def testConfig(self): - self.assertNotError('topic config separator <==>') - _ = self.getMsg('topic add foo') - m = self.getMsg('topic add bar') - self.failUnless('<==>' in m.args[1]) + try: + conf.supybot.plugins.Topic.separator.setValue(' <==> ') + _ = self.getMsg('topic add foo') + m = self.getMsg('topic add bar') + self.failUnless('<==>' in m.args[1]) + finally: + default = conf.supybot.plugins.Topic.separator.default + conf.supybot.plugins.Topic.separator.setValue(default) def testReorder(self): _ = self.getMsg('topic add foo')