diff --git a/discordbot.py b/discordbot.py index ae928cd0..bc78e423 100644 --- a/discordbot.py +++ b/discordbot.py @@ -8,7 +8,6 @@ import sys import db import youtube_dl import concurrent.futures -import stagismo import platform import typing import os @@ -17,8 +16,8 @@ import configparser import subprocess import async_timeout import raven -import cast import logging +import errors logging.basicConfig() @@ -472,6 +471,27 @@ async def cmd_dump_voice_player_error(channel: discord.Channel, author: discord. await client.send_message(channel, f"```\n{str(voice_player.error)}\n```") +@command +async def cmd_register(channel: discord.Channel, author: discord.Member, params: typing.List[str]): + session = await loop.run_in_executor(executor, db.Session()) + if len(params) < 1: + await client.send_message(channel, "⚠️ Non hai specificato un username!\n" + "Sintassi corretta: `!register `") + return + try: + d = db.Discord.create(session, + royal_username=params[0], + discord_user=author) + except errors.AlreadyExistingError: + await client.send_message(channel, + "⚠ Il tuo account Discord è già collegato a un account RYG " + "o l'account RYG che hai specificato è già collegato a un account Discord.") + return + session.add(d) + session.commit() + session.close() + await client.send_message(channel, "✅ Sincronizzazione completata!") + async def queue_predownload_videos(): while True: for index, video in enumerate(voice_queue[:int(config["YouTube"]["predownload_videos"])].copy()): @@ -551,7 +571,8 @@ commands = { "!q": cmd_queue, "!shuffle": cmd_shuffle, "!clear": cmd_clear, - "!dump_vp": cmd_dump_voice_player_error + "!dump_vp": cmd_dump_voice_player_error, + "!register": cmd_register } diff --git a/static/nryg.less b/static/nryg.less index d464eb12..57ea7029 100644 --- a/static/nryg.less +++ b/static/nryg.less @@ -20,15 +20,15 @@ h1, h2, h3, h4, h5, h6 { a { color: @link-color; text-decoration: none; -} -a:hover, a:active { - color: @link-color; - text-decoration: underline; -} + &:hover, &:active { + color: @link-color; + text-decoration: underline; + } -a:visited { - color: @visited-color; + &:visited { + color: @visited-color; + } } blockquote { @@ -162,8 +162,31 @@ nav { } } +@media (min-width:601px) { + .mobile-only { + display: none; + } +} + +@media (max-width:600px) { + .desktop-only { + display: none; + } +} + +//Dirtiest hack ever +.game-panels { + font-size: 0; + + .game-panel { + font-size: medium; + } +} + .game-panel { display: inline-block; + margin: 4px; + vertical-align: top; } .game-grid { @@ -171,7 +194,6 @@ nav { width: 360px; height: 100px; border-radius: 10px; - margin: 4px; position: relative; .game-title { @@ -199,18 +221,6 @@ nav { } } -@media (min-width:601px) { - .mobile-only { - display: none; - } -} - -@media (max-width:600px) { - .desktop-only { - display: none; - } -} - .osu { font-family: 'Exo 2', 'Helvetica Neue', 'Arial', sans-serif; font-style: italic; @@ -489,7 +499,7 @@ nav { } .ow { - padding: 15px; + padding: 16px; font-family: "FuturaNo2D", sans-serif; background-color: #371b00; border: 2px solid #ff9c00; @@ -579,6 +589,16 @@ nav { } } +.telegram { + background-color: #32afed; + color: white !important; + padding: 18px; + + .useless-stuff { + grid-column: 1; + } +} + .wiki { .wiki-log { diff --git a/templates/game.html b/templates/game.html index 7a7854b1..ce64767f 100644 --- a/templates/game.html +++ b/templates/game.html @@ -12,9 +12,11 @@

Royal Games su {{ game_name }}

- {% for mini in minis %} - {% with record = mini %} - {% include "minis/" + game_short_name + ".html" %} - {% endwith %} - {% endfor %} +
+ {% for mini in minis %} + {% with record = mini %} + {% include "minis/" + game_short_name + ".html" %} + {% endwith %} + {% endfor %} +
{% endblock %} \ No newline at end of file diff --git a/templates/minis/dota.html b/templates/minis/dota.html index 962f359d..9310e53a 100644 --- a/templates/minis/dota.html +++ b/templates/minis/dota.html @@ -33,4 +33,4 @@ {% endif %} - \ No newline at end of file + diff --git a/templates/minis/lol.html b/templates/minis/lol.html index 9ddc2d6e..7a550dcd 100644 --- a/templates/minis/lol.html +++ b/templates/minis/lol.html @@ -47,4 +47,4 @@ {% endif %} - \ No newline at end of file + diff --git a/templates/minis/osu.html b/templates/minis/osu.html index 67760e67..01a5783b 100644 --- a/templates/minis/osu.html +++ b/templates/minis/osu.html @@ -33,4 +33,4 @@ {{ record.mania_pp | int }}pp - \ No newline at end of file + diff --git a/templates/minis/ow.html b/templates/minis/ow.html index 71f98482..7957618c 100644 --- a/templates/minis/ow.html +++ b/templates/minis/ow.html @@ -30,4 +30,4 @@ {% endif %} - \ No newline at end of file + diff --git a/templates/minis/rl.html b/templates/minis/rl.html index a25d8318..a5a458fa 100644 --- a/templates/minis/rl.html +++ b/templates/minis/rl.html @@ -34,4 +34,4 @@ - \ No newline at end of file + diff --git a/templates/minis/ryg.html b/templates/minis/ryg.html index f45153cf..b733e1d7 100644 --- a/templates/minis/ryg.html +++ b/templates/minis/ryg.html @@ -13,4 +13,4 @@ {{ record.fiorygi }} - \ No newline at end of file + diff --git a/templates/minis/steam.html b/templates/minis/steam.html index 7d66557c..f357d653 100644 --- a/templates/minis/steam.html +++ b/templates/minis/steam.html @@ -42,4 +42,4 @@ {% endif %} - \ No newline at end of file + diff --git a/templates/minis/telegram.html b/templates/minis/telegram.html new file mode 100644 index 00000000..fc886747 --- /dev/null +++ b/templates/minis/telegram.html @@ -0,0 +1,12 @@ +
+
+
+ {% if record.username is none %} + {{ record.first_name }} + {% else %} + @{{ record.username }} + {% endif %} +
+
è su Telegram!
+
+
diff --git a/templates/profile.html b/templates/profile.html index d6942219..f7711a6e 100644 --- a/templates/profile.html +++ b/templates/profile.html @@ -22,37 +22,44 @@

Profilo di {{ ryg.username }} {% if session.get('user_id', '') == ryg.id %}Modifica{% endif %}

- {% with record = ryg %} - {% include "minis/ryg.html" %} - {% endwith %} - {% if steam %} - {% with record = steam %} - {% include "minis/steam.html" %} +
+ {% with record = ryg %} + {% include "minis/ryg.html" %} {% endwith %} - {% endif %} - {% if rl %} - {% with record = rl %} - {% include "minis/rl.html" %} - {% endwith %} - {% endif %} - {% if dota %} - {% with record = dota %} - {% include "minis/dota.html" %} - {% endwith %} - {% endif %} - {% if osu %} - {% with record = osu %} - {% include "minis/osu.html" %} - {% endwith %} - {% endif %} - {% if lol %} - {% with record = lol %} - {% include "minis/lol.html" %} - {% endwith %} - {% endif %} - {% if ow %} - {% with record = ow %} - {% include "minis/ow.html" %} - {% endwith %} - {% endif %} + {% if steam %} + {% with record = steam %} + {% include "minis/steam.html" %} + {% endwith %} + {% endif %} + {% if rl %} + {% with record = rl %} + {% include "minis/rl.html" %} + {% endwith %} + {% endif %} + {% if dota %} + {% with record = dota %} + {% include "minis/dota.html" %} + {% endwith %} + {% endif %} + {% if osu %} + {% with record = osu %} + {% include "minis/osu.html" %} + {% endwith %} + {% endif %} + {% if lol %} + {% with record = lol %} + {% include "minis/lol.html" %} + {% endwith %} + {% endif %} + {% if ow %} + {% with record = ow %} + {% include "minis/ow.html" %} + {% endwith %} + {% endif %} + {% if tg %} + {% with record = tg %} + {% include "minis/telegram.html" %} + {% endwith %} + {% endif %} +
{% endblock %} \ No newline at end of file diff --git a/webserver.py b/webserver.py index 4d9154e5..cfd43752 100644 --- a/webserver.py +++ b/webserver.py @@ -79,9 +79,10 @@ def page_profile(name: str): dota = db_session.query(db.Dota).join(db.Steam).filter_by(royal=user).one_or_none() lol = db_session.query(db.LeagueOfLegends).filter_by(royal=user).one_or_none() ow = db_session.query(db.Overwatch).filter_by(royal=user).one_or_none() + tg = db_session.query(db.Telegram).filter_by(royal=user).one_or_none() db_session.close() return render_template("profile.html", ryg=user, css=css, osu=osu, rl=rl, dota=dota, lol=lol, steam=steam, ow=ow, - config=config) + tg=tg, config=config) @app.route("/login")