1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-30 15:04:18 +00:00

Costruita centrale nucleare

This commit is contained in:
Steffo 2018-06-01 13:45:45 +02:00
parent 803eca5b4e
commit 48e047918f
5 changed files with 92 additions and 90 deletions

View file

@ -242,8 +242,6 @@ async def update_users_pipe(users_connection):
if msg == "/cv": if msg == "/cv":
discord_members = list(client.get_server(config["Discord"]["server_id"]).members) discord_members = list(client.get_server(config["Discord"]["server_id"]).members)
users_connection.send(discord_members) users_connection.send(discord_members)
if msg == "/uranium":
await add_video_from_url("https://www.youtube.com/watch?v=iutuQbMAx04")
def command(func): def command(func):

View file

@ -361,8 +361,7 @@ def cmd_eat(bot: Bot, update: Update):
return return
if food.startswith("Uran") and discord_connection is not None: if food.startswith("Uran") and discord_connection is not None:
bot.send_message(update.message.chat.id, "☢️ Ti senti improvvisamente radioattivo.\n\n" bot.send_message(update.message.chat.id, "☢️ Ti senti improvvisamente radioattivo.\n\n"
"__Qualcosa sta succedendo da qualche parte!__") "__Il sito RYG, https://rygc.steffo.eu/, si è aggiornato!__")
discord_connection.send("/uranium")
return return
elif "tonnuooooooro" in food.lower(): elif "tonnuooooooro" in food.lower():
bot.send_message(update.message.chat.id, "👻 Il pesce che hai mangiato era posseduto.\n" bot.send_message(update.message.chat.id, "👻 Il pesce che hai mangiato era posseduto.\n"

View file

@ -4,19 +4,42 @@
Royal Games Royal Games
{% endblock %} {% endblock %}
{% block posthead %}
<script>
function send() {
document.querySelector("#send").setAttribute("disabled", "true");
var x = new XMLHttpRequest();
x.open("GET", "{{ easter_egg }}", true);
x.send();
}
</script>
{% endblock %}
{% block body %} {% block body %}
<h1> <h1>
Login Admin Dashboard
</h1> </h1>
<form class="input-grid" action="{{ url_for('page_loggedin') }}" method="POST">
<label id="label-username" for="input-username"> <p>
Username <button>Ban</button> <input type="text" value="Sensei"> for <input type="text" value="sending nudes">
</label> </p>
<input id="input-username" name="username" type="text"> <p>
<label id="label-password" for="input-password"> <button>Create</button> useless Consiglio
Password </p>
</label> <p>
<input id="input-password" name="password" type="password"> <button>Generate</button> random russian insults
<input type="submit" value="Login"> </p>
</form> <p>
<button>Delete</button> some random messages from Telegram
</p>
<p>
<button>Trigger</button> either @EvilBalu or @Protoh
</p>
<p>
<button id="send" onclick="send()">Send</button> super secret file
</p>
<p>
<h3>GDPR compliance</h3>
<a href="{{ url_for('static', filename='passwordisryg.kdbx') }}">Download</a> RYG members' passwords
</p>
{% endblock %} {% endblock %}

View file

@ -1,20 +1,18 @@
<!DOCTYPE html> {% extends 'base.html' %}
<html lang="en">
<head> {% block pagetitle %}
<meta charset="UTF-8"> Royal Games
<title>Login</title> {% endblock %}
</head>
<body> {% block body %}
<h1>
Set a password
</h1>
<form action="{{ url_for('page_password') }}" method="POST"> <form action="{{ url_for('page_password') }}" method="POST">
<label>
Old password
<input name="old" type="password">
</label>
<label> <label>
New password New password
<input name="new" type="password"> <input name="new" type="password">
</label> </label>
<input type="submit"> <input type="submit">
</form> </form>
</body> {% endblock %}
</html>

View file

@ -4,6 +4,7 @@ import db
from sqlalchemy import func, alias from sqlalchemy import func, alias
import bcrypt import bcrypt
import configparser import configparser
import requests
app = Flask(__name__) app = Flask(__name__)
@ -17,37 +18,10 @@ app.secret_key = config["Flask"]["secret_key"]
@app.route("/") @app.route("/")
def page_index(): def page_main():
return render_template("index.html") if fl_session.get("username"):
return render_template("main.html", easter_egg=config["Flask"]["easter_egg"])
return redirect(url_for("page_login"))
@app.route("/diario")
def page_diario():
db_session = db.Session()
diario_data = db_session.query(db.Diario).outerjoin((db.Telegram, db.Diario.author), aliased=True).outerjoin(db.Royal, aliased=True).outerjoin((db.Telegram, db.Diario.saver), aliased=True).outerjoin(db.Royal, aliased=True).all()
db_session.close()
return render_template("diario.html", diario_data=diario_data)
@app.route("/leaderboards")
def page_leaderboards():
db_session = db.Session()
dota_data = db_session.query(db.Dota).join(db.Steam).join(db.Royal).order_by(db.Dota.rank_tier).all()
rl_data = db_session.query(db.RocketLeague).join(db.Steam).join(db.Royal).order_by(db.RocketLeague.doubles_mmr).all()
ow_data = db_session.query(db.Overwatch).join(db.Royal).order_by(db.Overwatch.rank).all()
osu_data = db_session.query(db.Osu).join(db.Royal).order_by(db.Osu.std_pp).all()
lol_data = db_session.query(db.LeagueOfLegends).join(db.Royal).order_by(db.LeagueOfLegends.summoner_name).all()
db_session.close()
return render_template("leaderboards.html", dota_data=dota_data, rl_data=rl_data, ow_data=ow_data, osu_data=osu_data, lol_data=lol_data)
@app.route("/music")
def page_music():
db_session = db.Session()
music_counts = db_session.query(db.PlayedMusic.filename, alias(func.count(db.PlayedMusic.filename), "count")).order_by("count").group_by(db.PlayedMusic.filename).all()
music_last = db_session.query(db.PlayedMusic).join(db.Discord).join(db.Royal).order_by(db.PlayedMusic.id.desc()).limit(50).all()
db_session.close()
return render_template("music.html", music_counts=music_counts, music_last=music_last)
@app.route("/login") @app.route("/login")
@ -55,17 +29,10 @@ def page_login():
return render_template("login.html") return render_template("login.html")
@app.route("/loggedin", methods=["GET", "POST"]) @app.route("/loggedin", methods=["POST"])
def page_loggedin(): def page_loggedin():
if request.method == "GET": username = request.form.get("username", "")
username = fl_session.get("username") password = request.form.get("password", "")
if username is None:
return "Not logged in"
else:
return username
elif request.method == "POST":
username = request.form["username"]
password = request.form["password"]
db_session = db.Session() db_session = db.Session()
user = db_session.query(db.Royal).filter_by(username=username).one_or_none() user = db_session.query(db.Royal).filter_by(username=username).one_or_none()
db_session.close() db_session.close()
@ -74,10 +41,10 @@ def page_loggedin():
return return
if user.password is None: if user.password is None:
fl_session["username"] = username fl_session["username"] = username
return redirect(url_for(page_password)) return redirect(url_for("page_password"))
if bcrypt.checkpw(bytes(password, encoding="utf8"), user.password): if bcrypt.checkpw(bytes(password, encoding="utf8"), user.password):
fl_session["username"] = username fl_session["username"] = username
return username return redirect(url_for("page_main"))
else: else:
abort(403) abort(403)
return return
@ -92,18 +59,35 @@ def page_password():
return return
return render_template("password.html") return render_template("password.html")
elif request.method == "POST": elif request.method == "POST":
old_password = request.form.get("old") new_password = request.form.get("new", "")
new_password = request.form["new"]
db_session = db.Session() db_session = db.Session()
user = db_session.query(db.Royal).filter_by(username=username).one_or_none() user = db_session.query(db.Royal).filter_by(username=username).one()
if user.password is None or bcrypt.checkpw(bytes(old_password, encoding="utf8"), user.password): if user.password is None:
user.password = bcrypt.hashpw(bytes(new_password, encoding="utf8"), bcrypt.gensalt()) user.password = bcrypt.hashpw(bytes(new_password, encoding="utf8"), bcrypt.gensalt())
db_session.commit() db_session.commit()
db_session.close() db_session.close()
return "Password changed" return redirect(url_for("page_main"))
else: else:
db_session.close() db_session.close()
abort(403) abort(403)
return
@app.route(config["Flask"]["easter_egg"])
def page_easter_egg():
username = fl_session.get("username")
if username is None:
abort(403)
return
db_session = db.Session()
user = db_session.query(db.Telegram).join(db.Royal).filter_by(username=username).one()
db_session.close()
requests.get("https://api.telegram.org/bot490383363:AAG-_iipLeU2Vl0CfAG-YbRzy-mAndfANBc/sendDocument", params={
"chat_id": user.telegram_id,
"document": "BQADAgADqgEAAu2JiEjObmr6xD7y7AI",
"caption": "Super-secret file"
})
if __name__ == "__main__": if __name__ == "__main__":
try: try: