stuff
This commit is contained in:
parent
2d90288856
commit
87b1d3d7f4
6 changed files with 21 additions and 13 deletions
|
@ -9,7 +9,8 @@ def correction(inp, message=None, input=None, notice=None, db=None):
|
||||||
else:
|
else:
|
||||||
nick = input.nick
|
nick = input.nick
|
||||||
last_message = db.execute("select name, quote from seen_user where name"
|
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:
|
if last_message:
|
||||||
splitinput = input.msg.split("/")
|
splitinput = input.msg.split("/")
|
||||||
|
|
|
@ -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
|
# store the encoded text and IV in the DB for decoding later
|
||||||
db.execute("insert or replace into encryption(encrypted, iv)"
|
db.execute("insert or replace into encryption(encrypted, iv)"
|
||||||
"values(?,?)", (encoded, iv_encoded))
|
"values(:encoded,:iv)", {'encoded': encoded,
|
||||||
|
'iv': iv_encoded})
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
return encoded
|
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
|
# get the encoded IV from the database and decode it
|
||||||
iv_encoded = db.execute("select iv from encryption where"
|
iv_encoded = db.execute("select iv from encryption where"
|
||||||
" encrypted=?", (text,)).fetchone()[0]
|
" encrypted=:text", {'text': text}).fetchone()[0]
|
||||||
iv = base64.b64decode(iv_encoded)
|
iv = base64.b64decode(iv_encoded)
|
||||||
|
|
||||||
# create AES cipher, decode text, decrypt text, and unpad it
|
# create AES cipher, decode text, decrypt text, and unpad it
|
||||||
|
|
|
@ -14,6 +14,11 @@ def db_init(db):
|
||||||
db_ready = True
|
db_ready = True
|
||||||
|
|
||||||
|
|
||||||
|
@hook.onload
|
||||||
|
def init(paraml, db=None):
|
||||||
|
db_init(db)
|
||||||
|
|
||||||
|
|
||||||
@hook.command(autohelp=False)
|
@hook.command(autohelp=False)
|
||||||
def horoscope(inp, db=None, notice=None, nick=None):
|
def horoscope(inp, db=None, notice=None, nick=None):
|
||||||
"""horoscope <sign> -- Get your horoscope."""
|
"""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)")
|
db.execute("create table if not exists horoscope(nick primary key, sign)")
|
||||||
|
|
||||||
if not sign:
|
if not sign:
|
||||||
sign = db.execute("select sign from horoscope where nick=lower(:nick)",
|
sign = db.execute("select sign from horoscope where "
|
||||||
{'nick':nick}).fetchone()
|
"nick=lower(:nick)", {'nick': nick}).fetchone()
|
||||||
if not sign:
|
if not sign:
|
||||||
notice("horoscope <sign> -- Get your horoscope")
|
notice("horoscope <sign> -- Get your horoscope")
|
||||||
return
|
return
|
||||||
|
@ -49,7 +54,7 @@ def horoscope(inp, db=None, notice=None, nick=None):
|
||||||
return "Could not get the horoscope for {}.".format(inp)
|
return "Could not get the horoscope for {}.".format(inp)
|
||||||
|
|
||||||
if inp and not dontsave:
|
if inp and not dontsave:
|
||||||
db.execute("insert or replace into horoscope(nick, sign) values (:nick,:signS)",
|
db.execute("insert or replace into horoscope(nick, sign) values (:nick, :sign)",
|
||||||
{'nick': nick.lower(), 'sign': sign})
|
{'nick': nick.lower(), 'sign': sign})
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
|
|
|
@ -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)")
|
db.execute("create table if not exists lastfm(nick primary key, acc)")
|
||||||
|
|
||||||
if not user:
|
if not user:
|
||||||
user = db.execute("select acc from lastfm where nick=lower(?)",
|
user = db.execute("select acc from lastfm where nick=lower(:nick)",
|
||||||
(nick,)).fetchone()
|
{'nick': nick}).fetchone()
|
||||||
if not user:
|
if not user:
|
||||||
notice(lastfm.__doc__)
|
notice(lastfm.__doc__)
|
||||||
return
|
return
|
||||||
|
@ -76,8 +76,8 @@ def lastfm(inp, nick='', db=None, bot=None, notice=None):
|
||||||
out += ending
|
out += ending
|
||||||
|
|
||||||
if inp and not dontsave:
|
if inp and not dontsave:
|
||||||
db.execute("insert or replace into lastfm(nick, acc) values (?,?)",
|
db.execute("insert or replace into lastfm(nick, acc) values "
|
||||||
(nick.lower(), user))
|
"(:nick, :account)", {'nick': nick.lower(), 'account': user})
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
return out
|
return out
|
||||||
|
|
|
@ -36,3 +36,5 @@ def pre(inp):
|
||||||
size = ''
|
size = ''
|
||||||
|
|
||||||
return '{} - {}{} - {} ({} ago)'.format(section, name, size, date_string, since)
|
return '{} - {}{} - {} ({} ago)'.format(section, name, size, date_string, since)
|
||||||
|
|
||||||
|
print pre("top gear")
|
||||||
|
|
|
@ -23,8 +23,7 @@ def db_init(db):
|
||||||
|
|
||||||
def get_tells(db, user_to):
|
def get_tells(db, user_to):
|
||||||
return db.execute("select user_from, message, time, chan from tell where"
|
return db.execute("select user_from, message, time, chan from tell where"
|
||||||
" user_to=lower(:user) order by time",
|
" user_to=lower(:user) order by time", {'user': user_to}).fetchall()
|
||||||
{'user': user_to}).fetchall()
|
|
||||||
|
|
||||||
|
|
||||||
@hook.singlethread
|
@hook.singlethread
|
||||||
|
|
Reference in a new issue