mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 05:09:23 +01:00
Added --with option to quote command.
This commit is contained in:
parent
e40183f1e5
commit
b4b2b2b883
@ -121,14 +121,15 @@ class Quotes(ChannelDBHandler, callbacks.Privmsg):
|
||||
irc.reply(msg, s)
|
||||
|
||||
def quote(self, irc, msg, args):
|
||||
"""[<channel>] --{id,regexp,from}=<value> [--{id,regexp,from}=<value>]
|
||||
"""[<channel>] --{id,regexp,from,with}=<value> ]
|
||||
|
||||
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)
|
||||
|
@ -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')
|
||||
|
Loading…
Reference in New Issue
Block a user