From f4098232c0559fb5ffc87ea3907258d6027591f2 Mon Sep 17 00:00:00 2001 From: Ryan Hitchman Date: Mon, 1 Feb 2010 00:40:54 -0700 Subject: [PATCH] make seen lower case, make quote.py use quote instead of quotes --- plugins/quote.py | 2 +- plugins/seen.py | 13 +++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/plugins/quote.py b/plugins/quote.py index 924c951..84f75b6 100644 --- a/plugins/quote.py +++ b/plugins/quote.py @@ -35,7 +35,7 @@ def quote(bot, input): "random or [#n]th quote by or from <#chan>/adds quote" conn = bot.get_db_connection(bot, input.server) - conn.execute('''create table if not exists quotes + conn.execute('''create table if not exists quote (chan, nick, add_nick, msg, time real, deleted default 0, primary key (chan, nick, msg))''') conn.commit() diff --git a/plugins/seen.py b/plugins/seen.py index 1088b91..7e4d463 100644 --- a/plugins/seen.py +++ b/plugins/seen.py @@ -12,7 +12,7 @@ def seeninput(bot, input): conn = db_connect(bot, input.server) cursor = conn.cursor() - cursor.execute("INSERT OR REPLACE INTO seen(name, date, quote, chan)" + cursor.execute("insert or replace into seen(name, time, quote, chan)" "values(?,?,?,?)", (input.nick.lower(), time.time(), input.msg, input.chan)) conn.commit() @@ -22,7 +22,7 @@ def seeninput(bot, input): def seen(bot, input): ".seen -- Tell when a nickname was last in active in irc" - if len(input.msg) < 6: + if not input.inp: return seen.__doc__ query = input.inp @@ -33,8 +33,7 @@ def seen(bot, input): conn = db_connect(bot, input.server) cursor = conn.cursor() - command = "SELECT date, quote FROM seen WHERE name LIKE ? AND chan = ?" \ - "ORDER BY date DESC" + command = "select time, quote FROM seen WHERE name LIKE ? AND chan = ?" cursor.execute(command, (query, input.chan)) results = cursor.fetchone() @@ -50,10 +49,8 @@ def db_connect(bot, server): "check to see that our db has the the seen table and return a connection." conn = bot.get_db_connection(server) - conn.execute("CREATE TABLE IF NOT EXISTS " - "seen(name varchar(30) not null, date datetime not null, " - "quote varchar(250) not null, chan varchar(32) not null, " - "primary key(name, chan));") + conn.execute("create table if not exists seen(name, time, quote, chan, " + "primary key(name, chan))") conn.commit() return conn