good- and blacklist configuration works now! <3
This commit is contained in:
parent
8a7c2f0110
commit
87302faf9e
|
@ -116,6 +116,8 @@ def confirm_account(encoded_jwt):
|
||||||
with open(os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "blacklists", "nbg_blacklist"),
|
with open(os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "blacklists", "nbg_blacklist"),
|
||||||
"r") as f:
|
"r") as f:
|
||||||
default_blacklist = f.read()
|
default_blacklist = f.read()
|
||||||
|
print(default_goodlist) # debug
|
||||||
|
print(default_blacklist) # debug
|
||||||
db.cur.execute("INSERT INTO trigger_bad(user_id, words) VALUES(?, ?);", (get_user_id(email), default_blacklist))
|
db.cur.execute("INSERT INTO trigger_bad(user_id, words) VALUES(?, ?);", (get_user_id(email), default_blacklist))
|
||||||
db.conn.commit()
|
db.conn.commit()
|
||||||
bottle.response.set_cookie("account", email, secret, path="/")
|
bottle.response.set_cookie("account", email, secret, path="/")
|
||||||
|
@ -137,26 +139,29 @@ def manage_bot():
|
||||||
db.cur.execute("SELECT enabled FROM user WHERE email = ?;", (email,))
|
db.cur.execute("SELECT enabled FROM user WHERE email = ?;", (email,))
|
||||||
enabled = db.cur.fetchone()[0]
|
enabled = db.cur.fetchone()[0]
|
||||||
# Set Enable Status with a Cookie
|
# Set Enable Status with a Cookie
|
||||||
|
resp = bottle.static_file("../static/bot.html", root='../static')
|
||||||
if enabled:
|
if enabled:
|
||||||
bottle.response.set_cookie("enabled", "True")
|
resp.set_cookie("enabled", "True")
|
||||||
else:
|
else:
|
||||||
bottle.response.set_cookie("enabled", "False")
|
resp.set_cookie("enabled", "False")
|
||||||
|
|
||||||
# Get goodlist from db
|
# Get goodlist from db
|
||||||
db.cur.execute("SELECT words FROM trigger_good WHERE user_id=?;", (user_id,))
|
db.cur.execute("SELECT words FROM trigger_good WHERE user_id=?;", (user_id,))
|
||||||
words = db.cur.fetchone()[0]
|
words = db.cur.fetchone()[0]
|
||||||
# Deliver goodlist with a Cookie
|
# Deliver goodlist with a Cookie
|
||||||
print("setting goodlist cookies?")
|
print("setting goodlist cookies?")
|
||||||
bottle.response.set_cookie("goodlist", words, path="/settings")
|
resp.set_cookie("goodlist", words, path="/settings")
|
||||||
|
print(words) # debug
|
||||||
|
|
||||||
# Get blacklist from db
|
# Get blacklist from db
|
||||||
db.cur.execute("SELECT words FROM trigger_bad WHERE user_id=?;", (user_id,))
|
db.cur.execute("SELECT words FROM trigger_bad WHERE user_id=?;", (user_id,))
|
||||||
words = db.cur.fetchone()[0]
|
words = db.cur.fetchone()[0]
|
||||||
# Deliver badlist with a Cookie
|
# Deliver badlist with a Cookie
|
||||||
print("setting blacklist cookies?")
|
print("setting blacklist cookies?")
|
||||||
bottle.response.set_cookie("blacklist", words, path="/settings")
|
resp.set_cookie("blacklist", words, path="/settings")
|
||||||
|
print(words) # debug
|
||||||
|
|
||||||
return bottle.static_file("../static/bot.html", root='../static')
|
return resp
|
||||||
else:
|
else:
|
||||||
bottle.abort(401, "Wrong username or passphrase. Try again!")
|
bottle.abort(401, "Wrong username or passphrase. Try again!")
|
||||||
|
|
||||||
|
@ -176,7 +181,7 @@ def update_goodlist():
|
||||||
"""
|
"""
|
||||||
# get new goodlist
|
# get new goodlist
|
||||||
words = bottle.request.forms.get("goodlist")
|
words = bottle.request.forms.get("goodlist")
|
||||||
user_id = get_user_id(bottle.cookie_decode("account", secret))
|
user_id = get_user_id(bottle.request.get_cookie("account", secret=secret))
|
||||||
# write new goodlist to db
|
# write new goodlist to db
|
||||||
db.cur.execute("UPDATE trigger_good SET words = ? WHERE user_id = ?;", (words, user_id, ))
|
db.cur.execute("UPDATE trigger_good SET words = ? WHERE user_id = ?;", (words, user_id, ))
|
||||||
db.conn.commit()
|
db.conn.commit()
|
||||||
|
@ -193,9 +198,7 @@ def update_blacklist():
|
||||||
# get new blacklist
|
# get new blacklist
|
||||||
words = bottle.request.forms.get("blacklist")
|
words = bottle.request.forms.get("blacklist")
|
||||||
# get user_id
|
# get user_id
|
||||||
email = bottle.cookie_decode("account", secret)
|
user_id = get_user_id(bottle.request.get_cookie("account", secret=secret))
|
||||||
db.cur.execute("SELECT id FROM user WHERE email = ?", (email, ))
|
|
||||||
user_id = db.cur.fetchone()
|
|
||||||
# write new goodlist to db
|
# write new goodlist to db
|
||||||
db.cur.execute("UPDATE trigger_bad SET words = ? WHERE user_id = ?;", (words, user_id, ))
|
db.cur.execute("UPDATE trigger_bad SET words = ? WHERE user_id = ?;", (words, user_id, ))
|
||||||
db.conn.commit()
|
db.conn.commit()
|
||||||
|
|
|
@ -82,7 +82,7 @@ input[type=text], input[type=password] {
|
||||||
padding: 2em;
|
padding: 2em;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
float: center;
|
float: center;
|
||||||
width: 240px;
|
width: 540px;
|
||||||
height: 30px;
|
height: 30px;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
}
|
}
|
|
@ -25,11 +25,15 @@ function getCookie(cname) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function listformat(list) {
|
||||||
|
list = list.replace(/\"/g, '')
|
||||||
|
list = list.split('\\012');
|
||||||
|
return list.join('\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
document.getElementById("enablebutton").innerHTML = enableButton();
|
document.getElementById("enablebutton").innerHTML = enableButton();
|
||||||
|
|
||||||
// document.getElementById("goodlist").innerHTML = getCookie("goodlist");
|
document.getElementById("goodlist").innerHTML = listformat(getCookie("goodlist"));
|
||||||
|
|
||||||
alert(getCookie("goodlist"))
|
document.getElementById("blacklist").innerHTML = listformat(getCookie("blacklist"));
|
||||||
alert(getCookie("blacklist"))
|
|
||||||
|
|
||||||
// document.getElementById("blacklist").innerHTML = getCookie("blacklist");
|
|
Loading…
Reference in a new issue