LinkRelay: Make relays management case-insentive.

master
Valentin Lorentz 2013-08-06 14:51:17 +00:00
parent 00f0941b4d
commit 66bbb34dea
2 changed files with 9 additions and 6 deletions

View File

@ -394,20 +394,20 @@ class LinkRelay(callbacks.Plugin):
s = ' | '.join(args)
currentConfig = self.registryValue('relays')
config = list(map(ircutils.IrcString, currentConfig.split(' || ')))
if add == True:
if s in currentConfig.split(' || '):
if s in config:
return False
if currentConfig == '':
self.setRegistryValue('relays', value=s)
else:
self.setRegistryValue('relays',
value=' || '.join((currentConfig,s)))
value=' || '.join((currentConfig, s)))
else:
newConfig = currentConfig.split(' || ')
if s not in newConfig:
if s not in config:
return False
newConfig.remove(s)
self.setRegistryValue('relays', value=' || '.join(newConfig))
config.remove(s)
self.setRegistryValue('relays', value=' || '.join(config))
return True
def _parseOptlist(self, irc, msg, tupleOptlist):

View File

@ -56,6 +56,9 @@ class LinkRelayTestCase(ChannelPluginTestCase):
self.assertResponse('config supybot.plugins.LinkRelay.relays',
'#test | test | #foo | bar | ')
self.assertRegexp('linkrelay add --to #foo@bar', 'already exists')
self.assertRegexp('linkrelay add --to #FOO@bar', 'already exists')
def testRemove(self):
self.assertNotError('config supybot.plugins.LinkRelay.relays '
'"#foo | bar | #baz | bam | "')