diff --git a/plugins/Quotes.py b/plugins/Quotes.py index 382af24ee..234596e90 100644 --- a/plugins/Quotes.py +++ b/plugins/Quotes.py @@ -121,14 +121,15 @@ class Quotes(ChannelDBHandler, callbacks.Privmsg): irc.reply(msg, s) def quote(self, irc, msg, args): - """[] --{id,regexp,from}= [--{id,regexp,from}=] + """[] --{id,regexp,from,with}= ] Returns quote(s) matching the given criteria. --from is who added the quote; --id is the id number of the quote; --regexp is a regular expression to search for. """ channel = privmsgs.getChannel(msg, args) - (optlist, rest) = getopt.getopt(args, '', ['id=', 'regexp=', 'from=']) + (optlist, rest) = getopt.getopt(args, '', ['id=', 'regexp=', + 'from=', 'with=']) if not optlist and not rest: raise callbacks.ArgumentError criteria = [] @@ -144,6 +145,9 @@ class Quotes(ChannelDBHandler, callbacks.Privmsg): except ValueError: irc.error(msg, '--id value must be an integer.') return + elif option == 'with': + criteria.append('quote LIKE %s') + formats.append('%%%s%%' % argument) elif option == 'from': criteria.append('added_by=%s') formats.append(argument) diff --git a/test/test_Quotes.py b/test/test_Quotes.py index e13a9a59d..ee4295d8a 100644 --- a/test/test_Quotes.py +++ b/test/test_Quotes.py @@ -47,6 +47,8 @@ class QuotesTestCase(PluginTestCase, PluginDocumentation): self.assertResponse('quote #foo 3', '#3: baz') self.assertRegexp('quote #foo --regexp m/ba/', 'bar.*baz') self.assertRegexp('quote #foo --regexp ba', 'bar.*baz') + self.assertRegexp('quote #foo --with bar', '#2: bar') + self.assertRegexp('quote #foo bar', '#2: bar') self.assertNotError('quoteinfo #foo 1') self.assertNotError('randomquote #foo') self.assertError('removequote #foo 4')