1
0
mirror of https://github.com/Adam-Ant/ClockworkAprilFools2017 synced 2024-12-20 11:04:35 +00:00

Format webinterface.py

This commit is contained in:
Joe Groocock 2017-03-31 21:11:09 +01:00
parent e5f3d7c829
commit e41e5c48e8
Signed by untrusted user: frebib
GPG Key ID: E0B16BEACFBB6A86

View File

@ -5,43 +5,43 @@ import ts3
pp = pprint.PrettyPrinter(indent=4)
app = Flask(__name__)
app.secret_key = rand(24)
def teamspeakClientAdd(clientName):
def teamspeakClientAdd(clientName):
with ts3.query.TS3Connection('magic.adam-ant.co.uk', '10011') as ts3conn:
try:
ts3conn.login(client_login_name='serveradmin',client_login_password='DE0xWKTx')
ts3conn.login(client_login_name='serveradmin', client_login_password='DE0xWKTx')
except ts3.query.TS3QueryError as err:
print(err)
ts3conn.use(sid=1)
try:
clientdbid = ts3conn.clientdbfind(pattern=clientName)[0]['cldbid']
except ts3.query.TS3QueryError:
return False
try:
ts3conn.servergroupaddclient(sgid=9,cldbid=clientdbid)
ts3conn.servergroupaddclient(sgid=10,cldbid=clientdbid)
ts3conn.servergroupaddclient(sgid=11,cldbid=clientdbid)
ts3conn.servergroupaddclient(sgid=12,cldbid=clientdbid)
ts3conn.servergroupaddclient(sgid=9, cldbid=clientdbid)
ts3conn.servergroupaddclient(sgid=10, cldbid=clientdbid)
ts3conn.servergroupaddclient(sgid=11, cldbid=clientdbid)
ts3conn.servergroupaddclient(sgid=12, cldbid=clientdbid)
return True
except:
print("ERROR")
def teamspeakClientCheck(clientName):
with ts3.query.TS3Connection('magic.adam-ant.co.uk', '10011') as ts3conn:
try:
ts3conn.login(client_login_name='serveradmin',client_login_password='DE0xWKTx')
ts3conn.login(client_login_name='serveradmin', client_login_password='DE0xWKTx')
except ts3.query.TS3QueryError as err:
print(err)
ts3conn.use(sid=1)
try:
print('before')
client = ts3conn.clientfind(pattern=clientName)
@ -51,17 +51,17 @@ def teamspeakClientCheck(clientName):
except ts3.query.TS3QueryError as ts3err:
if ts3err.resp.error['id'] == '512':
session.pop('username', None)
flash("ERROR: Username not found. Type it carefully cos Clockwork PLUS! is gonna cost ya...","danger")
flash("ERROR: Username not found. Type it carefully cos Clockwork PLUS! is gonna cost ya...", "danger")
return redirect(url_for('index'))
return "Ooops! Tell Adam this: <br>" + ts3err.resp.error['msg']
if "9," in groups:
print("FeckOffMate!")
flash("ERROR: You already have Clockwork PLUS, ya dingus","danger")
flash("ERROR: You already have Clockwork PLUS, ya dingus", "danger")
session.pop('username', None)
return redirect(url_for('index'))
else:
return redirect(url_for("payment"))
@app.route("/")
def index():
@ -70,6 +70,7 @@ def index():
session.pop('username', None)
return render_template("index.html")
@app.route("/collectsunlight")
def wait():
if "username" in session:
@ -77,6 +78,7 @@ def wait():
else:
return redirect(url_for("buy"))
@app.route("/pay")
def payment():
if "username" in session:
@ -84,12 +86,13 @@ def payment():
else:
return redirect(url_for("buy"))
@app.route("/activate")
def activate():
if "username" in session:
if teamspeakClientAdd(session['username']):
session.pop('username', None)
flash("Success! You have been upgraded to Clockwork PLUS! Enjoy!","success")
flash("Success! You have been upgraded to Clockwork PLUS! Enjoy!", "success")
return redirect(url_for('index'))
else:
return "Adam fucked up! go nag him"
@ -104,6 +107,6 @@ def buy():
return teamspeakClientCheck(session['username'])
return render_template("buy.html")
if __name__ == '__main__':
app.run(host='0.0.0.0',debug=True)
if __name__ == '__main__':
app.run(host='0.0.0.0', debug=True)