mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-16 14:42:53 +01:00
Added a "quotegrabs get" command to get quotegrabs by id
This commit is contained in:
parent
c746f9459b
commit
f051166e60
@ -200,7 +200,27 @@ class QuoteGrabs(plugins.ChannelDBHandler,
|
||||
l.append(item_str)
|
||||
irc.reply(msg, utils.commaAndify(l))
|
||||
|
||||
def get(self, irc, msg, args):
|
||||
"""<id>
|
||||
|
||||
Return the quotegrab with the given <id>.
|
||||
"""
|
||||
id = privmsgs.getArgs(args)
|
||||
try:
|
||||
id = int(id)
|
||||
except ValueError:
|
||||
irc.error(msg, '%r does not appear to be a valid quotegrab id'%id)
|
||||
return
|
||||
channel = privmsgs.getChannel(msg, args)
|
||||
db = self.getDb(channel)
|
||||
cursor = db.cursor()
|
||||
cursor.execute("""SELECT quote FROM quotegrabs
|
||||
WHERE id = %s""", id)
|
||||
if cursor.rowcount == 0:
|
||||
irc.error(msg, 'No quotegrab for id %r' % id)
|
||||
return
|
||||
quote = cursor.fetchone()[0]
|
||||
irc.reply(msg, quote)
|
||||
|
||||
|
||||
Class = QuoteGrabs
|
||||
|
@ -84,5 +84,14 @@ class QuoteGrabsTestCase(ChannelPluginTestCase, PluginDocumentation):
|
||||
self.assertNotError('quote FoO')
|
||||
self.assertNotError('quote Foo')
|
||||
|
||||
def testGet(self):
|
||||
testPrefix= 'foo!bar@baz'
|
||||
self.assertError('quotegrabs get asdf')
|
||||
self.assertError('quotegrabs get 1')
|
||||
self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'test',
|
||||
prefix=testPrefix))
|
||||
self.assertNotError('grab foo')
|
||||
self.assertResponse('quotegrabs get 1', '<foo> test')
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user