addquote now returns the number id of the quote that was added, i.e. Quote #4 added

This commit is contained in:
James Vega 2003-09-12 10:54:25 +00:00
parent 0aa448bfc7
commit 91274d3f54

View File

@ -84,11 +84,18 @@ class Quotes(ChannelDBHandler, callbacks.Privmsg):
quote = privmsgs.getArgs(args) quote = privmsgs.getArgs(args)
db = self.getDb(channel) db = self.getDb(channel)
cursor = db.cursor() cursor = db.cursor()
quotetime = int(time.time())
cursor.execute("""INSERT INTO quotes cursor.execute("""INSERT INTO quotes
VALUES(NULL, %s, %s, %s)""", VALUES(NULL, %s, %s, %s)""",
msg.nick, int(time.time()), quote) msg.nick, quotetime, quote)
db.commit() db.commit()
irc.reply(msg, conf.replySuccess) criteria = ['added_by=%s' % msg.nick]
criteria.append('added_at=%s' % quotetime)
criteria.append('quote=%s' % quote)
sql = """SELECT id FROM quotes WHERE %s""" % ' AND '.join(criteria)
cursor.execute(sql)
quoteid = cursor.fetchone()[0]
irc.reply(msg, '%s (Quote #%s added)' % (conf.replySuccess, quoteid))
def numquotes(self, irc, msg, args): def numquotes(self, irc, msg, args):
"""[<channel>] """[<channel>]