mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-23 02:49:27 +01:00
Alias: make regex for valid alias names configurable
This commit is contained in:
parent
54e9b4be09
commit
963a17c817
@ -43,5 +43,7 @@ def configure(advanced):
|
||||
Alias = conf.registerPlugin('Alias')
|
||||
conf.registerGroup(Alias, 'aliases')
|
||||
conf.registerGroup(Alias, 'escapedaliases')
|
||||
conf.registerGlobalValue(Alias, 'validName',
|
||||
registry.String(r'^[a-z.|!?][a-z0-9.|!]*$', _("""Regex which alias names must match in order to be valid""")))
|
||||
|
||||
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
|
||||
|
@ -336,13 +336,9 @@ class Alias(callbacks.Plugin):
|
||||
irc.error(_('There is no such alias.'))
|
||||
unlock = wrap(unlock, [('checkCapability', 'admin'), 'commandName'])
|
||||
|
||||
_validNameRe = re.compile(r'^[a-z.|!?][a-z0-9.|!]*$')
|
||||
def addAlias(self, irc, name, alias, lock=False):
|
||||
if not self._validNameRe.search(name):
|
||||
raise AliasError('Names can only contain alphanumerical '
|
||||
'characters, dots, pipes, and '
|
||||
'exclamation/interrogatin marks '
|
||||
'(and the first character cannot be a number).')
|
||||
if not re.search(self.registryValue('validName'), name):
|
||||
raise AliasError('Invalid alias name.')
|
||||
realName = callbacks.canonicalName(name)
|
||||
if name != realName:
|
||||
s = format(_('That name isn\'t valid. Try %q instead.'), realName)
|
||||
|
@ -112,8 +112,7 @@ class AliasTestCase(ChannelPluginTestCase):
|
||||
self.failIf('foobar' in cb.aliases)
|
||||
self.assertError('foobar')
|
||||
|
||||
self.assertRegexp('alias add café ignore', 'Error.*can only contain')
|
||||
self.assertRegexp('alias add 1abc ignore', 'Error.*can only contain')
|
||||
self.assertRegexp('alias add abc\x07 ignore', 'Error.*Invalid')
|
||||
|
||||
def testOptionalArgs(self):
|
||||
self.assertNotError('alias add myrepr "repr @1"')
|
||||
|
Loading…
Reference in New Issue
Block a user