mirror of
https://github.com/progval/Limnoria.git
synced 2025-04-30 23:41:06 -05: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)
|
irc.reply(msg, s)
|
||||||
|
|
||||||
def quote(self, irc, msg, args):
|
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
|
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
|
quote; --id is the id number of the quote; --regexp is a regular
|
||||||
expression to search for.
|
expression to search for.
|
||||||
"""
|
"""
|
||||||
channel = privmsgs.getChannel(msg, args)
|
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:
|
if not optlist and not rest:
|
||||||
raise callbacks.ArgumentError
|
raise callbacks.ArgumentError
|
||||||
criteria = []
|
criteria = []
|
||||||
@ -144,6 +145,9 @@ class Quotes(ChannelDBHandler, callbacks.Privmsg):
|
|||||||
except ValueError:
|
except ValueError:
|
||||||
irc.error(msg, '--id value must be an integer.')
|
irc.error(msg, '--id value must be an integer.')
|
||||||
return
|
return
|
||||||
|
elif option == 'with':
|
||||||
|
criteria.append('quote LIKE %s')
|
||||||
|
formats.append('%%%s%%' % argument)
|
||||||
elif option == 'from':
|
elif option == 'from':
|
||||||
criteria.append('added_by=%s')
|
criteria.append('added_by=%s')
|
||||||
formats.append(argument)
|
formats.append(argument)
|
||||||
|
@ -47,6 +47,8 @@ class QuotesTestCase(PluginTestCase, PluginDocumentation):
|
|||||||
self.assertResponse('quote #foo 3', '#3: baz')
|
self.assertResponse('quote #foo 3', '#3: baz')
|
||||||
self.assertRegexp('quote #foo --regexp m/ba/', 'bar.*baz')
|
self.assertRegexp('quote #foo --regexp m/ba/', 'bar.*baz')
|
||||||
self.assertRegexp('quote #foo --regexp 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('quoteinfo #foo 1')
|
||||||
self.assertNotError('randomquote #foo')
|
self.assertNotError('randomquote #foo')
|
||||||
self.assertError('removequote #foo 4')
|
self.assertError('removequote #foo 4')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user