mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-27 13:34:28 +00:00
cose da pcbalu
This commit is contained in:
parent
d81c23caed
commit
4537b0494f
7 changed files with 51 additions and 24 deletions
6
db.py
6
db.py
|
@ -963,6 +963,12 @@ class Halloween(Base):
|
||||||
count += 1
|
count += 1
|
||||||
return count
|
return count
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def event_started() -> bool:
|
||||||
|
session = Session()
|
||||||
|
halloweens = session.query(Halloween).all()
|
||||||
|
return bool(halloweens)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def puzzle_status() -> typing.List[bool]:
|
def puzzle_status() -> typing.List[bool]:
|
||||||
session = Session()
|
session = Session()
|
||||||
|
|
|
@ -858,7 +858,7 @@ class RoyalDiscordBot(discord.Client):
|
||||||
@requires_connected_voice_client
|
@requires_connected_voice_client
|
||||||
async def cmd_resume(self, channel: discord.TextChannel, author: discord.Member, params: typing.List[str]):
|
async def cmd_resume(self, channel: discord.TextChannel, author: discord.Member, params: typing.List[str]):
|
||||||
for voice_client in self.voice_clients:
|
for voice_client in self.voice_clients:
|
||||||
if voice_client.is_playing():
|
if voice_client.is_paused():
|
||||||
voice_client.resume()
|
voice_client.resume()
|
||||||
logger.debug(f"The audio stream was resumed.")
|
logger.debug(f"The audio stream was resumed.")
|
||||||
await channel.send(f"⏯ Riproduzione ripresa.")
|
await channel.send(f"⏯ Riproduzione ripresa.")
|
||||||
|
|
|
@ -37,3 +37,6 @@ client_id =
|
||||||
client_secret =
|
client_secret =
|
||||||
username =
|
username =
|
||||||
password =
|
password =
|
||||||
|
|
||||||
|
[Events]
|
||||||
|
halloween = 0
|
|
@ -7,11 +7,7 @@
|
||||||
{% block prehead %}{% endblock %}
|
{% block prehead %}{% endblock %}
|
||||||
<title>{% block pagetitle %}{% endblock %} - Royal Games</title>
|
<title>{% block pagetitle %}{% endblock %} - Royal Games</title>
|
||||||
<link href="{{ url_for('static', filename='pygments.css') }}" rel="stylesheet" type="text/css">
|
<link href="{{ url_for('static', filename='pygments.css') }}" rel="stylesheet" type="text/css">
|
||||||
{% if config["DEBUG"] %}
|
<link href="{{ url_for('static', filename={{ g["css"] }}) }}" rel="stylesheet/less" type="text/css">
|
||||||
<link href="{{ url_for('static', filename='spoopy.less') }}" rel="stylesheet/less" type="text/css">
|
|
||||||
{% else %}
|
|
||||||
<link href="{{ url_for('static', filename='nryg.less') }}" rel="stylesheet/less" type="text/css">
|
|
||||||
{% endif %}
|
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/less.js/3.0.2/less.min.js"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/less.js/3.0.2/less.min.js"></script>
|
||||||
{% block posthead %}{% endblock %}
|
{% block posthead %}{% endblock %}
|
||||||
</head>
|
</head>
|
||||||
|
@ -23,8 +19,8 @@
|
||||||
<a href="/">Home</a>
|
<a href="/">Home</a>
|
||||||
<span class="desktop-only">
|
<span class="desktop-only">
|
||||||
{% if session.get('username') is not none %}
|
{% if session.get('username') is not none %}
|
||||||
<a href="{{ rygconf['Telegram']['invite_link'] }}">Telegram</a>
|
<a href="{{ g["rygconf"]['Telegram']['invite_link'] }}">Telegram</a>
|
||||||
<a href="{{ rygconf['Discord']['invite_link'] }}">Discord</a>
|
<a href="{{ g["rygconf"]['Discord']['invite_link'] }}">Discord</a>
|
||||||
<a href="https://steamcommunity.com/groups/royalgamescastle">Steam</a>
|
<a href="https://steamcommunity.com/groups/royalgamescastle">Steam</a>
|
||||||
<a href="https://new.reddit.com/r/RoyalGames/">/r/RoyalGames</a>
|
<a href="https://new.reddit.com/r/RoyalGames/">/r/RoyalGames</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
Royal Games
|
Royal Games
|
||||||
</h1>
|
</h1>
|
||||||
<div class="main-page">
|
<div class="main-page">
|
||||||
{% if config["DEBUG"] %}
|
{% if g["css"] == "spoopy.less" %}
|
||||||
<div class="halloween">
|
<div class="halloween">
|
||||||
<div class="box">
|
<div class="box">
|
||||||
<div class="upper-box">
|
<div class="upper-box">
|
||||||
|
@ -97,7 +97,7 @@
|
||||||
<div class="lower-box">
|
<div class="lower-box">
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="/game/ryg">Royal Games</a></li>
|
<li><a href="/game/ryg">Royal Games</a></li>
|
||||||
{% if config["DEBUG"] %}
|
{% if rygconf["Events"]["halloween"] %}
|
||||||
<li><a href="/game/halloween">Rituale di Halloween</a></li>
|
<li><a href="/game/halloween">Rituale di Halloween</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<li><a href="/game/tg">Telegram</a></li>
|
<li><a href="/game/tg">Telegram</a></li>
|
||||||
|
|
50
webserver.py
50
webserver.py
|
@ -1,5 +1,6 @@
|
||||||
from flask import Flask, render_template, request, abort, redirect, url_for, Markup, escape
|
from flask import Flask, render_template, request, abort, redirect, url_for, Markup, escape
|
||||||
from flask import session as fl_session
|
from flask import session as fl_session
|
||||||
|
from flask import g as fl_g
|
||||||
import db
|
import db
|
||||||
import bcrypt
|
import bcrypt
|
||||||
import configparser
|
import configparser
|
||||||
|
@ -28,7 +29,7 @@ sentry = Sentry(app, dsn=config["Sentry"]["token"])
|
||||||
|
|
||||||
@app.errorhandler(400)
|
@app.errorhandler(400)
|
||||||
def error_400(_=None):
|
def error_400(_=None):
|
||||||
return render_template("400.html", rygconf=config)
|
return render_template("400.html", g=fl_g)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/400")
|
@app.route("/400")
|
||||||
|
@ -38,7 +39,7 @@ def page_400():
|
||||||
|
|
||||||
@app.errorhandler(403)
|
@app.errorhandler(403)
|
||||||
def error_403(_=None):
|
def error_403(_=None):
|
||||||
return render_template("403.html", rygconf=config)
|
return render_template("403.html", g=fl_g)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/403")
|
@app.route("/403")
|
||||||
|
@ -48,7 +49,7 @@ def page_403():
|
||||||
|
|
||||||
@app.errorhandler(500)
|
@app.errorhandler(500)
|
||||||
def error_500(_=None):
|
def error_500(_=None):
|
||||||
return render_template("500.html", rygconf=config)
|
return render_template("500.html", g=fl_g)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/500")
|
@app.route("/500")
|
||||||
|
@ -69,7 +70,7 @@ def page_main():
|
||||||
halloween = db.Halloween.puzzle_status()
|
halloween = db.Halloween.puzzle_status()
|
||||||
db_session.close()
|
db_session.close()
|
||||||
return render_template("main.html", royals=royals, wiki_pages=wiki_pages, entry=random_diario,
|
return render_template("main.html", royals=royals, wiki_pages=wiki_pages, entry=random_diario,
|
||||||
next_events=next_events, rygconf=config, escape=escape, halloween=enumerate(halloween))
|
next_events=next_events, g=fl_g, escape=escape, halloween=enumerate(halloween))
|
||||||
|
|
||||||
|
|
||||||
@app.route("/profile/<name>")
|
@app.route("/profile/<name>")
|
||||||
|
@ -98,13 +99,13 @@ def page_profile(name: str):
|
||||||
else:
|
else:
|
||||||
converted_bio = ""
|
converted_bio = ""
|
||||||
return render_template("profile.html", ryg=user, css=css, osu=osu, dota=dota, lol=lol, steam=steam, ow=ow,
|
return render_template("profile.html", ryg=user, css=css, osu=osu, dota=dota, lol=lol, steam=steam, ow=ow,
|
||||||
tg=tg, discord=discord, rygconf=config, bio=converted_bio, gamelog=gamelog,
|
tg=tg, discord=discord, g=fl_g, bio=converted_bio, gamelog=gamelog,
|
||||||
halloween=halloween)
|
halloween=halloween)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/login")
|
@app.route("/login")
|
||||||
def page_login():
|
def page_login():
|
||||||
return render_template("login.html", rygconf=config)
|
return render_template("login.html", g=fl_g)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/loggedin", methods=["POST"])
|
@app.route("/loggedin", methods=["POST"])
|
||||||
|
@ -146,7 +147,7 @@ def page_password():
|
||||||
if request.method == "GET":
|
if request.method == "GET":
|
||||||
if user_id is None:
|
if user_id is None:
|
||||||
return redirect(url_for("page_login"))
|
return redirect(url_for("page_login"))
|
||||||
return render_template("password.html", rygconf=config)
|
return render_template("password.html", g=fl_g)
|
||||||
elif request.method == "POST":
|
elif request.method == "POST":
|
||||||
new_password = request.form.get("new", "")
|
new_password = request.form.get("new", "")
|
||||||
db_session = db.Session()
|
db_session = db.Session()
|
||||||
|
@ -171,7 +172,7 @@ def page_editprofile():
|
||||||
profile_data = db_session.query(db.ProfileData).filter_by(royal_id=user_id).join(db.Royal).one_or_none()
|
profile_data = db_session.query(db.ProfileData).filter_by(royal_id=user_id).join(db.Royal).one_or_none()
|
||||||
if request.method == "GET":
|
if request.method == "GET":
|
||||||
db_session.close()
|
db_session.close()
|
||||||
return render_template("profileedit.html", data=profile_data, rygconf=config)
|
return render_template("profileedit.html", data=profile_data, g=fl_g)
|
||||||
elif request.method == "POST":
|
elif request.method == "POST":
|
||||||
css = request.form.get("css", "")
|
css = request.form.get("css", "")
|
||||||
bio = request.form.get("bio", "")
|
bio = request.form.get("bio", "")
|
||||||
|
@ -241,7 +242,7 @@ def page_game(name: str):
|
||||||
abort(404)
|
abort(404)
|
||||||
return
|
return
|
||||||
db_session.close()
|
db_session.close()
|
||||||
return render_template("game.html", minis=query, game_name=game_name, game_short_name=name, rygconf=config)
|
return render_template("game.html", minis=query, game_name=game_name, game_short_name=name, g=fl_g)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/wiki")
|
@app.route("/wiki")
|
||||||
|
@ -249,7 +250,7 @@ def page_wikihome():
|
||||||
db_session = db.Session()
|
db_session = db.Session()
|
||||||
wiki_pages = db_session.query(db.WikiEntry).order_by(db.WikiEntry.key).all()
|
wiki_pages = db_session.query(db.WikiEntry).order_by(db.WikiEntry.key).all()
|
||||||
db_session.close()
|
db_session.close()
|
||||||
return render_template("wikilist.html", wiki_pages=wiki_pages, rygconf=config)
|
return render_template("wikilist.html", wiki_pages=wiki_pages, g=fl_g)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/wiki/<key>", methods=["GET", "POST"])
|
@app.route("/wiki/<key>", methods=["GET", "POST"])
|
||||||
|
@ -261,7 +262,7 @@ def page_wiki(key: str):
|
||||||
.order_by(db.WikiLog.timestamp.desc()).first()
|
.order_by(db.WikiLog.timestamp.desc()).first()
|
||||||
db_session.close()
|
db_session.close()
|
||||||
if wiki_page is None:
|
if wiki_page is None:
|
||||||
return render_template("wikipage.html", key=key, rygconf=config)
|
return render_template("wikipage.html", key=key, g=fl_g)
|
||||||
# Embed YouTube videos
|
# Embed YouTube videos
|
||||||
converted_md = markdown2.markdown(wiki_page.content.replace("<", "<"),
|
converted_md = markdown2.markdown(wiki_page.content.replace("<", "<"),
|
||||||
extras=["spoiler", "tables", "smarty-pants", "fenced-code-blocks"])
|
extras=["spoiler", "tables", "smarty-pants", "fenced-code-blocks"])
|
||||||
|
@ -276,7 +277,7 @@ def page_wiki(key: str):
|
||||||
r' </iframe>'
|
r' </iframe>'
|
||||||
r'</div>', converted_md)
|
r'</div>', converted_md)
|
||||||
return render_template("wikipage.html", key=key, wiki_page=wiki_page, converted_md=Markup(converted_md),
|
return render_template("wikipage.html", key=key, wiki_page=wiki_page, converted_md=Markup(converted_md),
|
||||||
wiki_log=wiki_latest_edit, rygconf=config)
|
wiki_log=wiki_latest_edit, g=fl_g)
|
||||||
elif request.method == "POST":
|
elif request.method == "POST":
|
||||||
user_id = fl_session.get('user_id')
|
user_id = fl_session.get('user_id')
|
||||||
user = db_session.query(db.Royal).filter_by(id=user_id).one()
|
user = db_session.query(db.Royal).filter_by(id=user_id).one()
|
||||||
|
@ -329,7 +330,22 @@ def page_diario():
|
||||||
db_session = db.Session()
|
db_session = db.Session()
|
||||||
diario_entries = db_session.query(db.Diario).order_by(db.Diario.timestamp.desc()).all()
|
diario_entries = db_session.query(db.Diario).order_by(db.Diario.timestamp.desc()).all()
|
||||||
db_session.close()
|
db_session.close()
|
||||||
return render_template("diario.html", rygconf=config, entries=diario_entries)
|
return render_template("diario.html", g=fl_g, entries=diario_entries)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/spooky", methods=["POST"])
|
||||||
|
def page_spooky():
|
||||||
|
if request.form.get("solution", "") != "1":
|
||||||
|
return redirect("https://www.youtube.com/watch?v=dQw4w9WgXcQ")
|
||||||
|
user_id = fl_session.get("user_id")
|
||||||
|
if not user_id:
|
||||||
|
return redirect("https://www.youtube.com/watch?v=djV11Xbc914")
|
||||||
|
db_session = db.Session()
|
||||||
|
user = db_session.query(db.Royal).filter_by(id=user_id).one()
|
||||||
|
halloween = db.Halloween(royal=user, first_trigger=datetime.datetime.now())
|
||||||
|
db_session.add(halloween)
|
||||||
|
db_session.commit()
|
||||||
|
return redirect(url_for("page_main"))
|
||||||
|
|
||||||
|
|
||||||
@app.route("/ritual/<int:n>", methods=["GET", "POST"])
|
@app.route("/ritual/<int:n>", methods=["GET", "POST"])
|
||||||
|
@ -338,7 +354,7 @@ def page_ritual(n: int):
|
||||||
if not user_id:
|
if not user_id:
|
||||||
return redirect(url_for("page_login"))
|
return redirect(url_for("page_login"))
|
||||||
if request.method == "GET":
|
if request.method == "GET":
|
||||||
return render_template("ritual.html", rygconf=config, n=n)
|
return render_template("ritual.html", g=fl_g, n=n)
|
||||||
elif request.method == "POST":
|
elif request.method == "POST":
|
||||||
if n == 1:
|
if n == 1:
|
||||||
pass
|
pass
|
||||||
|
@ -363,6 +379,12 @@ def page_ritual(n: int):
|
||||||
return redirect(url_for("page_ritual", n=n))
|
return redirect(url_for("page_ritual", n=n))
|
||||||
|
|
||||||
|
|
||||||
|
@app.before_request
|
||||||
|
def pre_request():
|
||||||
|
fl_g["css"] = "spoopy.less" if db.Halloween.event_started() else "nryg.less"
|
||||||
|
fl_g["rygconf"] = config
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
try:
|
try:
|
||||||
app.run(host="0.0.0.0", port=1235, debug=__debug__)
|
app.run(host="0.0.0.0", port=1235, debug=__debug__)
|
||||||
|
|
Loading…
Reference in a new issue