Fixed ugliness (tons of returns?) and SyntaxError (missing parenthese).

This commit is contained in:
Jeremy Fincher 2003-08-26 11:24:06 +00:00
parent 5289f6bc75
commit cfe4ce14a9

View File

@ -122,19 +122,15 @@ class Quotes(ChannelDBHandler, callbacks.Privmsg):
cursor.execute("""SELECT id, quote FROM quotes WHERE p(quote)""") cursor.execute("""SELECT id, quote FROM quotes WHERE p(quote)""")
if cursor.rowcount == 0: if cursor.rowcount == 0:
irc.reply(msg, 'No quotes matched that regexp.') irc.reply(msg, 'No quotes matched that regexp.')
return
elif cursor.rowcount == 1: elif cursor.rowcount == 1:
(id, quote) = cursor.fetchone() (id, quote) = cursor.fetchone()
irc.reply(msg, 'Quote %s: %s' % (id, quote)) irc.reply(msg, 'Quote %s: %s' % (id, quote))
return
elif cursor.rowcount > 5: elif cursor.rowcount > 5:
ids = [t[0] for t in cursor.fetchall()] ids = [t[0] for t in cursor.fetchall()]
irc.reply(msg, 'Quotes %s matched.' % ', '.join(ids)) irc.reply(msg, 'Quotes %s matched.' % ', '.join(ids))
return
else: else:
L = ['%s: %s' % (id,s[:30]) for (id,s) in cursor.fetchall()] L = ['%s: %s' % (id,s[:30]) for (id,s) in cursor.fetchall()]
irc.reply(msg, 'These quotes matched: %s' % ', '.join(L)) irc.reply(msg, 'These quotes matched: %s' % ', '.join(L))
return
def randomquote(self, irc, msg, args): def randomquote(self, irc, msg, args):
"[<channel>] (if not sent through the channel itself)" "[<channel>] (if not sent through the channel itself)"
@ -149,7 +145,6 @@ class Quotes(ChannelDBHandler, callbacks.Privmsg):
return return
(id, quote) = cursor.fetchone() (id, quote) = cursor.fetchone()
irc.reply(msg, '%s [#%s]' % (quote, id)) irc.reply(msg, '%s [#%s]' % (quote, id))
return
def quoteinfo(self, irc, msg, args): def quoteinfo(self, irc, msg, args):
"[<channel>] (if not sent through the channel itself) <number>" "[<channel>] (if not sent through the channel itself) <number>"
@ -158,16 +153,14 @@ class Quotes(ChannelDBHandler, callbacks.Privmsg):
db = self.getDb(channel) db = self.getDb(channel)
cursor = db.cursor() cursor = db.cursor()
cursor.execute("""SELECT * FROM quotes WHERE id=%s""", id) cursor.execute("""SELECT * FROM quotes WHERE id=%s""", id)
(id, added_by, added_at, quote) = cursor.fetchone() if cursor.rowcount == 1:
if row: (id, added_by, added_at, quote) = cursor.fetchone()
timestamp = time.strftime(conf.humanTimestampFormat, timestamp = time.strftime(conf.humanTimestampFormat,
time.localtime(int(added_at))) time.localtime(int(added_at)))
irc.reply(msg, 'Quote %r added by %s at %s.' % \ irc.reply(msg, 'Quote %r added by %s at %s.' % \
(quote, added_by, timestamp) (quote, added_by, timestamp))
return
else: else:
irc.reply(msg, 'There isn\'t a quote with that id.') irc.reply(msg, 'There isn\'t a quote with that id.')
return
def removequote(self, irc, msg, args): def removequote(self, irc, msg, args):
"[<channel>] (if not sent through the channel itself) <number>" "[<channel>] (if not sent through the channel itself) <number>"