Added a "quotegrabs get" command to get quotegrabs by id

This commit is contained in:
Daniel DiPaolo 2003-11-05 23:56:30 +00:00
parent c746f9459b
commit f051166e60
2 changed files with 31 additions and 2 deletions

View File

@ -200,8 +200,28 @@ class QuoteGrabs(plugins.ChannelDBHandler,
l.append(item_str) l.append(item_str)
irc.reply(msg, utils.commaAndify(l)) 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 Class = QuoteGrabs

View File

@ -84,5 +84,14 @@ class QuoteGrabsTestCase(ChannelPluginTestCase, PluginDocumentation):
self.assertNotError('quote FoO') self.assertNotError('quote FoO')
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: # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: