mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-11 12:42:34 +01:00
Merge pull request #1111 from GLolol/aka/search
Aka.search: be case insensitive & handle "not found" errors correctly
This commit is contained in:
commit
1acb68a8b4
@ -743,6 +743,7 @@ class Aka(callbacks.Plugin):
|
|||||||
|
|
||||||
Searches Akas defined for <channel>. If <channel> is not specified,
|
Searches Akas defined for <channel>. If <channel> is not specified,
|
||||||
searches all global Akas."""
|
searches all global Akas."""
|
||||||
|
query = callbacks.canonicalName(query, preserve_spaces=True)
|
||||||
channel = 'global'
|
channel = 'global'
|
||||||
for (option, arg) in optlist:
|
for (option, arg) in optlist:
|
||||||
if option == 'channel':
|
if option == 'channel':
|
||||||
@ -751,12 +752,13 @@ class Aka(callbacks.Plugin):
|
|||||||
Raise=True)
|
Raise=True)
|
||||||
channel = arg
|
channel = arg
|
||||||
aka_list = self._db.get_aka_list(channel)
|
aka_list = self._db.get_aka_list(channel)
|
||||||
aka_list = [k[0] for k in aka_list]
|
aka_list = [callbacks.canonicalName(k[0], preserve_spaces=True)
|
||||||
if aka_list:
|
for k in aka_list]
|
||||||
matching = [aka for aka in aka_list if query in aka]
|
matching = [aka for aka in aka_list if query in aka]
|
||||||
|
if matching:
|
||||||
irc.replies(matching)
|
irc.replies(matching)
|
||||||
else:
|
else:
|
||||||
irc.error(_("No matching Akas found."))
|
irc.error(_("No matching Akas were found."))
|
||||||
search = wrap(search, [getopts({'channel': 'channel'}), 'text'])
|
search = wrap(search, [getopts({'channel': 'channel'}), 'text'])
|
||||||
|
|
||||||
Class = Aka
|
Class = Aka
|
||||||
|
@ -238,5 +238,7 @@ class AkaTestCase(PluginTestCase):
|
|||||||
self.assertRegexp('aka search f', 'foo')
|
self.assertRegexp('aka search f', 'foo')
|
||||||
self.assertError('aka search abcdefghijklmnop')
|
self.assertError('aka search abcdefghijklmnop')
|
||||||
self.assertRegexp('aka search many', 'many words')
|
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:
|
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
|
||||||
|
Loading…
Reference in New Issue
Block a user