This commit is contained in:
Luke Rogers 2014-02-21 14:55:33 +13:00
parent 2d90288856
commit 87b1d3d7f4
6 changed files with 21 additions and 13 deletions

View file

@ -9,7 +9,8 @@ def correction(inp, message=None, input=None, notice=None, db=None):
else:
nick = input.nick
last_message = db.execute("select name, quote from seen_user where name"
" like ? and chan = ?", (nick.lower(), input.chan.lower())).fetchone()
" like :nick and chan = :chan", {'nick': nick.lower(),
'chan': input.chan.lower()}).fetchone()
if last_message:
splitinput = input.msg.split("/")

View file

@ -69,7 +69,8 @@ def encrypt(inp, bot=None, db=None, notice=None):
# store the encoded text and IV in the DB for decoding later
db.execute("insert or replace into encryption(encrypted, iv)"
"values(?,?)", (encoded, iv_encoded))
"values(:encoded,:iv)", {'encoded': encoded,
'iv': iv_encoded})
db.commit()
return encoded
@ -97,7 +98,7 @@ def decrypt(inp, bot=None, db=None, notice=None):
# get the encoded IV from the database and decode it
iv_encoded = db.execute("select iv from encryption where"
" encrypted=?", (text,)).fetchone()[0]
" encrypted=:text", {'text': text}).fetchone()[0]
iv = base64.b64decode(iv_encoded)
# create AES cipher, decode text, decrypt text, and unpad it

View file

@ -14,6 +14,11 @@ def db_init(db):
db_ready = True
@hook.onload
def init(paraml, db=None):
db_init(db)
@hook.command(autohelp=False)
def horoscope(inp, db=None, notice=None, nick=None):
"""horoscope <sign> -- Get your horoscope."""
@ -29,8 +34,8 @@ def horoscope(inp, db=None, notice=None, nick=None):
db.execute("create table if not exists horoscope(nick primary key, sign)")
if not sign:
sign = db.execute("select sign from horoscope where nick=lower(:nick)",
{'nick':nick}).fetchone()
sign = db.execute("select sign from horoscope where "
"nick=lower(:nick)", {'nick': nick}).fetchone()
if not sign:
notice("horoscope <sign> -- Get your horoscope")
return
@ -49,8 +54,8 @@ def horoscope(inp, db=None, notice=None, nick=None):
return "Could not get the horoscope for {}.".format(inp)
if inp and not dontsave:
db.execute("insert or replace into horoscope(nick, sign) values (:nick,:signS)",
{'nick':nick.lower(), 'sign': sign})
db.execute("insert or replace into horoscope(nick, sign) values (:nick, :sign)",
{'nick': nick.lower(), 'sign': sign})
db.commit()
return result

View file

@ -25,8 +25,8 @@ def lastfm(inp, nick='', db=None, bot=None, notice=None):
db.execute("create table if not exists lastfm(nick primary key, acc)")
if not user:
user = db.execute("select acc from lastfm where nick=lower(?)",
(nick,)).fetchone()
user = db.execute("select acc from lastfm where nick=lower(:nick)",
{'nick': nick}).fetchone()
if not user:
notice(lastfm.__doc__)
return
@ -76,8 +76,8 @@ def lastfm(inp, nick='', db=None, bot=None, notice=None):
out += ending
if inp and not dontsave:
db.execute("insert or replace into lastfm(nick, acc) values (?,?)",
(nick.lower(), user))
db.execute("insert or replace into lastfm(nick, acc) values "
"(:nick, :account)", {'nick': nick.lower(), 'account': user})
db.commit()
return out

View file

@ -36,3 +36,5 @@ def pre(inp):
size = ''
return '{} - {}{} - {} ({} ago)'.format(section, name, size, date_string, since)
print pre("top gear")

View file

@ -23,8 +23,7 @@ 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(:user) order by time",
{'user': user_to}).fetchall()
" user_to=lower(:user) order by time", {'user': user_to}).fetchall()
@hook.singlethread