From d05506ee22667a50e0d8b4f1a3354df466fe99e2 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Tue, 23 Oct 2012 16:34:38 +0000 Subject: [PATCH] Seen: Add supybot.plugins.Seen.minimumNonWildcard. --- plugins/Seen/config.py | 4 ++++ plugins/Seen/plugin.py | 4 ++++ plugins/Seen/test.py | 2 ++ 3 files changed, 10 insertions(+) diff --git a/plugins/Seen/config.py b/plugins/Seen/config.py index d7111bf93..7c39b83bb 100644 --- a/plugins/Seen/config.py +++ b/plugins/Seen/config.py @@ -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: diff --git a/plugins/Seen/plugin.py b/plugins/Seen/plugin.py index 3fc0c5eab..c519d4e5c 100644 --- a/plugins/Seen/plugin.py +++ b/plugins/Seen/plugin.py @@ -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)]] diff --git a/plugins/Seen/test.py b/plugins/Seen/test.py index 7319e77c4..04abeb877 100644 --- a/plugins/Seen/test.py +++ b/plugins/Seen/test.py @@ -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)