Fixed formatting.
This commit is contained in:
parent
146ae3c279
commit
4069dd21a3
89 changed files with 615 additions and 496 deletions
|
@ -1,5 +1,5 @@
|
|||
" tell.py: written by sklnd in July 2009"
|
||||
" 2010.01.25 - modified by Scaevolus"
|
||||
""" tell.py: written by sklnd in July 2009
|
||||
2010.01.25 - modified by Scaevolus"""
|
||||
|
||||
import time
|
||||
import re
|
||||
|
@ -8,10 +8,10 @@ from util import hook, timesince
|
|||
|
||||
|
||||
def db_init(db):
|
||||
"check to see that our db has the tell table and return a dbection."
|
||||
"""check to see that our db has the tell table and return a dbection."""
|
||||
db.execute("create table if not exists tell"
|
||||
"(user_to, user_from, message, chan, time,"
|
||||
"primary key(user_to, message))")
|
||||
"(user_to, user_from, message, chan, time,"
|
||||
"primary key(user_to, message))")
|
||||
db.commit()
|
||||
|
||||
return db
|
||||
|
@ -19,8 +19,8 @@ def db_init(db):
|
|||
|
||||
def get_tells(db, user_to):
|
||||
return db.execute("select user_from, message, time, chan from tell where"
|
||||
" user_to=lower(?) order by time",
|
||||
(user_to.lower(),)).fetchall()
|
||||
" user_to=lower(?) order by time",
|
||||
(user_to.lower(),)).fetchall()
|
||||
|
||||
|
||||
@hook.singlethread
|
||||
|
@ -38,12 +38,12 @@ def tellinput(paraml, input=None, notice=None, db=None, bot=None, nick=None, con
|
|||
reltime = timesince.timesince(time)
|
||||
|
||||
reply = "%s sent you a message %s ago from %s: %s" % (user_from, reltime, chan,
|
||||
message)
|
||||
message)
|
||||
if len(tells) > 1:
|
||||
reply += " (+%d more, %sshowtells to view)" % (len(tells) - 1, conn.conf["command_prefix"])
|
||||
|
||||
db.execute("delete from tell where user_to=lower(?) and message=?",
|
||||
(nick, message))
|
||||
(nick, message))
|
||||
db.commit()
|
||||
notice(reply)
|
||||
|
||||
|
@ -66,13 +66,13 @@ def showtells(inp, nick='', chan='', notice=None, db=None):
|
|||
notice("%s sent you a message %s ago from %s: %s" % (user_from, past, chan, message))
|
||||
|
||||
db.execute("delete from tell where user_to=lower(?)",
|
||||
(nick,))
|
||||
(nick,))
|
||||
db.commit()
|
||||
|
||||
|
||||
@hook.command
|
||||
def tell(inp, nick='', chan='', db=None, input=None, notice=None):
|
||||
"tell <nick> <message> -- Relay <message> to <nick> when <nick> is around."
|
||||
"""tell <nick> <message> -- Relay <message> to <nick> when <nick> is around."""
|
||||
query = inp.split(' ', 1)
|
||||
|
||||
if len(query) != 2:
|
||||
|
@ -102,14 +102,14 @@ def tell(inp, nick='', chan='', db=None, input=None, notice=None):
|
|||
db_init(db)
|
||||
|
||||
if db.execute("select count() from tell where user_to=?",
|
||||
(user_to,)).fetchone()[0] >= 10:
|
||||
(user_to,)).fetchone()[0] >= 10:
|
||||
notice("That person has too many messages queued.")
|
||||
return
|
||||
|
||||
try:
|
||||
db.execute("insert into tell(user_to, user_from, message, chan,"
|
||||
"time) values(?,?,?,?,?)", (user_to, user_from, message,
|
||||
chan, time.time()))
|
||||
"time) values(?,?,?,?,?)", (user_to, user_from, message,
|
||||
chan, time.time()))
|
||||
db.commit()
|
||||
except db.IntegrityError:
|
||||
notice("Message has already been queued.")
|
||||
|
|
Reference in a new issue