.tell: limit the .tell user to three tells per person at one time

This commit is contained in:
Chris Skalenda 2009-07-05 10:40:04 -05:00
parent df77f79242
commit e268a06268
1 changed files with 6 additions and 2 deletions

View File

@ -56,11 +56,15 @@ def tell(bot, input):
if query[2] != "": if query[2] != "":
dbpath = os.path.join(bot.persist_dir, dbname) dbpath = os.path.join(bot.persist_dir, dbname)
conn = dbconnect(dbpath) conn = dbconnect(dbpath)
filterUser = conn.execute("select count(*) from tell_probation where name=?", (input.nick,)).fetchone()
if filterUser[0] > 0: command = "select count(*) from tell_probation where name=?"
if conn.execute(command, (input.nick,)).fetchone()[0] > 0:
return "No." return "No."
command = "select count(*) from tell where name=? and user_from=?"
if conn.execute(command, (query[0], input.nick)).fetchone()[0] >= 3:
return "You've told that person too many things."
cursor = conn.cursor() cursor = conn.cursor()
command = "insert into tell(name, user_from, quote, chan, date) values(?,?,?,?,?)" command = "insert into tell(name, user_from, quote, chan, date) values(?,?,?,?,?)"
cursor.execute(command, (query[0], input.nick, query[2], input.chan, datetime.datetime.now())) cursor.execute(command, (query[0], input.nick, query[2], input.chan, datetime.datetime.now()))