From 1df05801afbeccfd4914e92f1c9831d66860f5e5 Mon Sep 17 00:00:00 2001
From: Stefano Pigozzi
Date: Mon, 4 Jun 2018 11:58:27 +0200
Subject: [PATCH] Add profiles and osu! mini
---
static/nryg.less | 93 ++++++++++++++++++++++++++++++++++++++++
telegrambot.py | 6 +--
templates/main.html | 34 ++-------------
templates/minis/osu.html | 37 ++++++++++++++++
templates/profile.html | 14 ++++++
webserver.py | 28 ++++++------
6 files changed, 160 insertions(+), 52 deletions(-)
create mode 100644 templates/minis/osu.html
create mode 100644 templates/profile.html
diff --git a/static/nryg.less b/static/nryg.less
index d132cc3d..ac9fa9f0 100644
--- a/static/nryg.less
+++ b/static/nryg.less
@@ -36,3 +36,96 @@ input[type="text"], input[type="password"] {
grid-column: 2;
}
}
+
+.game-panel {
+ max-width: 400px;
+}
+
+.osu {
+ display: grid;
+ position: relative;
+ font-family: 'Exo 2', 'Helvetica Neue', 'Arial', sans-serif;
+ font-style: italic;
+ border: 8px solid #ffffff;
+ border-radius: 10px;
+ color: #ffffff;
+ padding: 10px;
+ grid-row-gap: 4px;
+
+ .background-image {
+ position: absolute;
+ width: 100%;
+ height: 100%;
+ left: 0;
+ top: 0;
+ background-image: url("https://osu.ppy.sh/images/layout/nav-backgrounds/triangles-combined.png");
+ z-index: -2;
+ }
+
+ .background-color {
+ position: absolute;
+ width: 100%;
+ height: 100%;
+ left: 0;
+ top: 0;
+ background-color: rgba(187, 17, 119, 0.9);
+ z-index: -1;
+ }
+
+ .player {
+ grid-row: 1;
+ grid-column-start: 1;
+ grid-column-end: 4;
+ font-size: large;
+
+ a {
+ text-decoration: none;
+ }
+
+ .player-image {
+ width: 32px;
+ height: 32px;
+ border-radius: 16px;
+ vertical-align: middle;
+ }
+
+ .player-name {
+ vertical-align: middle;
+ color: #ffffff;
+ }
+ }
+
+ .game-title {
+ grid-row: 2;
+ font-size: smaller;
+ font-style: normal;
+ }
+
+ .game-score {
+ grid-row: 3;
+ }
+
+ .standard {
+ grid-column: 1;
+ }
+
+ .taiko {
+ grid-column: 2;
+ }
+
+ .catch {
+ grid-column: 3;
+ }
+
+ .mania {
+ grid-column: 4;
+ }
+
+ .number {
+ font-size: large;
+ }
+
+ .pp {
+ font-size: x-small;
+ }
+}
\ No newline at end of file
diff --git a/telegrambot.py b/telegrambot.py
index 89c6b232..cb858ee5 100644
--- a/telegrambot.py
+++ b/telegrambot.py
@@ -359,11 +359,7 @@ def cmd_eat(bot: Bot, update: Update):
bot.send_message(update.message.chat.id, "⚠️ Non hai specificato cosa mangiare!\n"
"Sintassi corretta: `/food `")
return
- if food.startswith("Uran") and discord_connection is not None:
- bot.send_message(update.message.chat.id, "☢️ Ti senti improvvisamente radioattivo.\n\n"
- "__Il sito RYG, https://rygc.steffo.eu/, si è aggiornato!__")
- return
- elif "tonnuooooooro" in food.lower():
+ if "tonnuooooooro" in food.lower():
bot.send_message(update.message.chat.id, "👻 Il pesce che hai mangiato era posseduto.\n"
"Spooky!")
return
diff --git a/templates/main.html b/templates/main.html
index 21cfd9b6..d83e1b52 100644
--- a/templates/main.html
+++ b/templates/main.html
@@ -4,42 +4,14 @@
Royal Games
{% endblock %}
-{% block posthead %}
-
-{% endblock %}
-
{% block body %}
- Admin Dashboard
+ Royal Games
-
- Ban for
+ Benvenuto al sito web della Royal Games! E' ancora un po' triste e spoglio, ma spero che collaboriate a migliorarlo!
- Create useless Consiglio
-
-
- Generate random russian insults
-
-
- Delete some random messages from Telegram
-
-
- Trigger either @EvilBalu or @Protoh
-
-
- Send super secret file
-
-
-
GDPR compliance
- Download RYG members' passwords
+ Attualmente, sto sviluppando i profili RYG ! Clicca qui per vedere il tuo.
{% endblock %}
\ No newline at end of file
diff --git a/templates/minis/osu.html b/templates/minis/osu.html
new file mode 100644
index 00000000..285768d6
--- /dev/null
+++ b/templates/minis/osu.html
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+ osu!
+
+
+ {{ osu.std_pp | int }} pp
+
+
+ osu!taiko
+
+
+ {{ osu.taiko_pp | int }} pp
+
+
+ osu!catch
+
+
+ {{ osu.catch_pp | int }} pp
+
+
+ osu!mania
+
+
+ {{ osu.mania_pp | int }} pp
+
+
\ No newline at end of file
diff --git a/templates/profile.html b/templates/profile.html
new file mode 100644
index 00000000..204e44a4
--- /dev/null
+++ b/templates/profile.html
@@ -0,0 +1,14 @@
+{% extends 'base.html' %}
+
+{% block pagetitle %}
+ Royal Games
+{% endblock %}
+
+{% block body %}
+
+ Profilo di {{ royal.username }}
+
+ {% if osu %}
+ {% include "minis/osu.html" %}
+ {% endif %}
+{% endblock %}
\ No newline at end of file
diff --git a/webserver.py b/webserver.py
index 9e362ef9..290787a6 100644
--- a/webserver.py
+++ b/webserver.py
@@ -24,6 +24,18 @@ def page_main():
return redirect(url_for("page_login"))
+@app.route("/profile/")
+def page_profile(name: str):
+ db_session = db.Session()
+ user = db_session.query(db.Royal).filter_by(username=name).one_or_none()
+ if user is None:
+ db_session.close()
+ abort(404)
+ return
+ osu = db_session.query(db.Osu).filter_by(royal=user).one_or_none()
+ return render_template("profile.html", royal=user, osu=osu)
+
+
@app.route("/login")
def page_login():
return render_template("login.html")
@@ -73,22 +85,6 @@ def page_password():
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__":
try:
app.run(host="0.0.0.0", port=1234, debug=__debug__)