make seen lower case, make quote.py use quote instead of quotes

This commit is contained in:
Ryan Hitchman 2010-02-01 00:40:54 -07:00
parent 595a37f0e0
commit f4098232c0
2 changed files with 6 additions and 9 deletions

View File

@ -35,7 +35,7 @@ def quote(bot, input):
"random or [#n]th quote by <nick> or from <#chan>/adds quote" "random or [#n]th quote by <nick> or from <#chan>/adds quote"
conn = bot.get_db_connection(bot, input.server) 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, (chan, nick, add_nick, msg, time real, deleted default 0,
primary key (chan, nick, msg))''') primary key (chan, nick, msg))''')
conn.commit() conn.commit()

View File

@ -12,7 +12,7 @@ def seeninput(bot, input):
conn = db_connect(bot, input.server) conn = db_connect(bot, input.server)
cursor = conn.cursor() 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(), "values(?,?,?,?)", (input.nick.lower(), time.time(),
input.msg, input.chan)) input.msg, input.chan))
conn.commit() conn.commit()
@ -22,7 +22,7 @@ def seeninput(bot, input):
def seen(bot, input): def seen(bot, input):
".seen <nick> -- Tell when a nickname was last in active in irc" ".seen <nick> -- Tell when a nickname was last in active in irc"
if len(input.msg) < 6: if not input.inp:
return seen.__doc__ return seen.__doc__
query = input.inp query = input.inp
@ -33,8 +33,7 @@ def seen(bot, input):
conn = db_connect(bot, input.server) conn = db_connect(bot, input.server)
cursor = conn.cursor() cursor = conn.cursor()
command = "SELECT date, quote FROM seen WHERE name LIKE ? AND chan = ?" \ command = "select time, quote FROM seen WHERE name LIKE ? AND chan = ?"
"ORDER BY date DESC"
cursor.execute(command, (query, input.chan)) cursor.execute(command, (query, input.chan))
results = cursor.fetchone() 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." "check to see that our db has the the seen table and return a connection."
conn = bot.get_db_connection(server) conn = bot.get_db_connection(server)
conn.execute("CREATE TABLE IF NOT EXISTS " conn.execute("create table if not exists seen(name, time, quote, chan, "
"seen(name varchar(30) not null, date datetime not null, " "primary key(name, chan))")
"quote varchar(250) not null, chan varchar(32) not null, "
"primary key(name, chan));")
conn.commit() conn.commit()
return conn return conn