mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-11 20:52:42 +01:00
Changed to registry.
This commit is contained in:
parent
81009586fb
commit
215a2b3a76
@ -46,26 +46,23 @@ import ircdb
|
|||||||
import ircmsgs
|
import ircmsgs
|
||||||
import plugins
|
import plugins
|
||||||
import privmsgs
|
import privmsgs
|
||||||
|
import registry
|
||||||
import callbacks
|
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)'
|
topicFormatter = '%s (%s)'
|
||||||
topicUnformatter = re.compile('(.*) \((\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):
|
def _splitTopic(self, topic, channel):
|
||||||
separator = self.configurables.get('separator', channel)
|
separator = self.registryValue('separator', channel)
|
||||||
return filter(None, topic.split(separator))
|
return filter(None, topic.split(separator))
|
||||||
|
|
||||||
def _joinTopic(self, topics, channel):
|
def _joinTopic(self, topics, channel):
|
||||||
separator = self.configurables.get('separator', channel)
|
separator = self.registryValue('separator', channel)
|
||||||
return separator.join(topics)
|
return separator.join(topics)
|
||||||
|
|
||||||
def _unformatTopic(self, topic, channel):
|
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.
|
if the message isn't sent in the channel itself.
|
||||||
"""
|
"""
|
||||||
topic = privmsgs.getArgs(args)
|
topic = privmsgs.getArgs(args)
|
||||||
separator = self.configurables.get('separator', channel)
|
separator = self.registryValue('separator', channel)
|
||||||
if separator in topic:
|
if separator in topic:
|
||||||
s = 'You can\'t have %s in your topic' % separator
|
s = 'You can\'t have %s in your topic' % separator
|
||||||
irc.error(s)
|
irc.error(s)
|
||||||
|
@ -81,10 +81,14 @@ class TopicTestCase(ChannelPluginTestCase, PluginDocumentation):
|
|||||||
self.assertError('topic change 0 s/baz/biff/')
|
self.assertError('topic change 0 s/baz/biff/')
|
||||||
|
|
||||||
def testConfig(self):
|
def testConfig(self):
|
||||||
self.assertNotError('topic config separator <==>')
|
try:
|
||||||
_ = self.getMsg('topic add foo')
|
conf.supybot.plugins.Topic.separator.setValue(' <==> ')
|
||||||
m = self.getMsg('topic add bar')
|
_ = self.getMsg('topic add foo')
|
||||||
self.failUnless('<==>' in m.args[1])
|
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):
|
def testReorder(self):
|
||||||
_ = self.getMsg('topic add foo')
|
_ = self.getMsg('topic add foo')
|
||||||
|
Loading…
Reference in New Issue
Block a user