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"
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()

View File

@ -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 <nick> -- 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