diff --git a/LinkRelay/plugin.py b/LinkRelay/plugin.py index ca8216f..b83ac26 100644 --- a/LinkRelay/plugin.py +++ b/LinkRelay/plugin.py @@ -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): diff --git a/LinkRelay/test.py b/LinkRelay/test.py index 79fdf71..e65691a 100644 --- a/LinkRelay/test.py +++ b/LinkRelay/test.py @@ -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 | "')