Seen: Add supybot.plugins.Seen.minimumNonWildcard.

This commit is contained in:
Valentin Lorentz 2012-10-23 16:34:38 +00:00
parent 32b0b12c1f
commit d05506ee22
3 changed files with 10 additions and 0 deletions

View File

@ -45,6 +45,10 @@ Seen = conf.registerPlugin('Seen')
# This is where your configuration variables (if any) should go. For example:
# conf.registerGlobalValue(Seen, 'someConfigVariableName',
# registry.Boolean(False, _("""Help for someConfigVariableName.""")))
conf.registerChannelValue(Seen, 'minimumNonWildcard',
registry.NonNegativeInteger(2, _("""The minimum non-wildcard characters
required to perform a 'seen' request. Of course, it only applies if there
is a wildcard in the request.""")))
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:

View File

@ -192,6 +192,10 @@ class Seen(callbacks.Plugin):
try:
results = []
if '*' in name:
if (len(name.replace('*', '')) <
self.registryValue('minimumNonWildcard', channel)):
irc.error(_('Not enough non-wildcard characters.'),
Raise=True)
results = db.seenWildcard(channel, name)
else:
results = [[name, db.seen(channel, name)]]

View File

@ -66,11 +66,13 @@ class ChannelDBTestCase(ChannelPluginTestCase):
prefix=self.prefix))
self.assertNotError('seen last')
self.assertNotError('list')
self.assertError('seen *')
self.assertNotError('seen %s' % self.nick)
m = self.assertNotError('seen %s' % self.nick.upper())
self.failUnless(self.nick.upper() in m.args[1])
self.assertRegexp('seen user %s' % self.nick,
'^%s was last seen' % self.nick)
self.assertNotError('config plugins.Seen.minimumNonWildcard 0')
for wildcard in self.wildcardTest:
self.assertRegexp('seen %s' % wildcard,
'^%s was last seen' % self.nick)