From 97228afb7d7f9710d8120849d9a2c99a8dd4bd13 Mon Sep 17 00:00:00 2001 From: James Lu Date: Mon, 18 May 2015 14:20:23 -0700 Subject: [PATCH] Aka.search: be case insensitive and handle "not found" errors correctly Closes #1110. --- plugins/Aka/plugin.py | 10 ++++++---- plugins/Aka/test.py | 2 ++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/plugins/Aka/plugin.py b/plugins/Aka/plugin.py index 06dc85752..c0cc48774 100644 --- a/plugins/Aka/plugin.py +++ b/plugins/Aka/plugin.py @@ -743,6 +743,7 @@ class Aka(callbacks.Plugin): Searches Akas defined for . If 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: - matching = [aka for aka in aka_list if query in aka] + 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 diff --git a/plugins/Aka/test.py b/plugins/Aka/test.py index f888054f6..6d2a9ea72 100644 --- a/plugins/Aka/test.py +++ b/plugins/Aka/test.py @@ -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: