mirror of
https://github.com/Adam-Ant/ClockworkAprilFools2017
synced 2024-12-20 11:04:35 +00:00
Initial version of website and python script for teamspeak integration
This commit is contained in:
parent
5175d05afa
commit
56592b9764
3
website/.gitignore
vendored
Normal file
3
website/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
bin/
|
||||
include/
|
||||
lib/
|
BIN
website/static/bg.jpg
Normal file
BIN
website/static/bg.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.4 KiB |
6
website/static/progressbar.js
Normal file
6
website/static/progressbar.js
Normal file
File diff suppressed because one or more lines are too long
8
website/templates/buy.html
Normal file
8
website/templates/buy.html
Normal file
@ -0,0 +1,8 @@
|
||||
<html>
|
||||
<body>
|
||||
<form method="post">
|
||||
Username: <input type="text" name="username">
|
||||
<button type="submit">Get me that juicy Plus!</button>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
4
website/templates/index.html
Normal file
4
website/templates/index.html
Normal file
@ -0,0 +1,4 @@
|
||||
<html>
|
||||
<body>
|
||||
<h1>Welcome to this clockwork gaming debug page!</h1>
|
||||
<a href="/activate">Click Here</a> to activate your membership!
|
58
website/templates/wait.html
Normal file
58
website/templates/wait.html
Normal file
@ -0,0 +1,58 @@
|
||||
|
||||
<meta http-equiv="refresh" content="31; url=/activate">
|
||||
<script src="/static/progressbar.js"></script>
|
||||
<link href="https://fonts.googleapis.com/css?family=Raleway:400,300,600,800,900" rel="stylesheet" type="text/css">
|
||||
|
||||
<style>
|
||||
body {
|
||||
background-image: url("/static/bg.jpg");
|
||||
background-repeat: repeat;
|
||||
}
|
||||
|
||||
#container{
|
||||
width: 300px;
|
||||
margin: 0 auto;
|
||||
top: 55%;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
<div id="container" class="container"></div>
|
||||
|
||||
|
||||
|
||||
|
||||
<script>
|
||||
// progressbar.js@1.0.0 version is used
|
||||
// Docs: http://progressbarjs.readthedocs.org/en/1.0.0/
|
||||
|
||||
var bar = new ProgressBar.SemiCircle(container, {
|
||||
strokeWidth: 30,
|
||||
color: '#FBDB0C',
|
||||
trailColor: '#000000',
|
||||
trailWidth: 2,
|
||||
easing: 'easeInOut',
|
||||
duration: 30000,
|
||||
svgStyle: null,
|
||||
text: {
|
||||
value: '',
|
||||
alignToBottom: false
|
||||
},
|
||||
from: {color: '#000000'},
|
||||
to: {color: '#ED6A5A'},
|
||||
// Set default step function for all animate calls
|
||||
step: (state, bar) => {
|
||||
var value = Math.round(bar.value() * 100);
|
||||
if (value === 0) {
|
||||
bar.setText('Please Wait...');
|
||||
} else {
|
||||
bar.setText(value);
|
||||
}
|
||||
}
|
||||
});
|
||||
bar.text.style.fontFamily = '"Raleway", Helvetica, sans-serif';
|
||||
bar.text.style.fontSize = '2rem';
|
||||
|
||||
bar.animate(1.0); // Number from 0.0 to 1.0
|
||||
|
||||
</script>
|
64
website/webinterface.py
Normal file
64
website/webinterface.py
Normal file
@ -0,0 +1,64 @@
|
||||
from flask import Flask, render_template, request, session, redirect, url_for
|
||||
from os import urandom as rand
|
||||
import pprint
|
||||
import ts3
|
||||
|
||||
pp = pprint.PrettyPrinter(indent=4)
|
||||
|
||||
|
||||
|
||||
app = Flask(__name__)
|
||||
app.secret_key = rand(24)
|
||||
|
||||
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')
|
||||
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)
|
||||
return True
|
||||
except:
|
||||
print("ERROR")
|
||||
|
||||
@app.route("/")
|
||||
def index():
|
||||
return render_template("index.html")
|
||||
|
||||
@app.route("/collectsunlight")
|
||||
def wait():
|
||||
return render_template("wait.html")
|
||||
|
||||
@app.route("/activate")
|
||||
def activate():
|
||||
if "username" in session:
|
||||
if teamspeakClientAdd(session['username']):
|
||||
return redirect(url_for('index'))
|
||||
else:
|
||||
return "Adam fucked up! go nag him"
|
||||
else:
|
||||
return redirect(url_for("buy"))
|
||||
|
||||
|
||||
@app.route("/buy", methods=['GET', 'POST'])
|
||||
def buy():
|
||||
if request.method == 'POST':
|
||||
session['username'] = request.form['username']
|
||||
return redirect(url_for("wait"))
|
||||
return render_template("buy.html")
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(host='0.0.0.0')
|
||||
|
Loading…
Reference in New Issue
Block a user