Aka.search: be case insensitive and handle "not found" errors correctly

Closes #1110.
This commit is contained in:
James Lu 2015-05-18 14:20:23 -07:00
parent c01acf828c
commit 97228afb7d
2 changed files with 8 additions and 4 deletions

View File

@ -743,6 +743,7 @@ class Aka(callbacks.Plugin):
Searches Akas defined for <channel>. If <channel> is not specified,
searches all global Akas."""
query = callbacks.canonicalName(query, preserve_spaces=True)
channel = 'global'
for (option, arg) in optlist:
if option == 'channel':
@ -751,12 +752,13 @@ class Aka(callbacks.Plugin):
Raise=True)
channel = arg
aka_list = self._db.get_aka_list(channel)
aka_list = [k[0] for k in aka_list]
if aka_list:
aka_list = [callbacks.canonicalName(k[0], preserve_spaces=True)
for k in aka_list]
matching = [aka for aka in aka_list if query in aka]
if matching:
irc.replies(matching)
else:
irc.error(_("No matching Akas found."))
irc.error(_("No matching Akas were found."))
search = wrap(search, [getopts({'channel': 'channel'}), 'text'])
Class = Aka

View File

@ -238,5 +238,7 @@ class AkaTestCase(PluginTestCase):
self.assertRegexp('aka search f', 'foo')
self.assertError('aka search abcdefghijklmnop')
self.assertRegexp('aka search many', 'many words')
# This should be case insensitive too.
self.assertRegexp('aka search MaNY', 'many words')
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: