mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 19:44:20 +00:00
spooky stuffs
This commit is contained in:
parent
4537b0494f
commit
6be872ed85
15 changed files with 313 additions and 116 deletions
15
db.py
15
db.py
|
@ -2,10 +2,9 @@ import datetime
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import typing
|
import typing
|
||||||
|
|
||||||
import coloredlogs
|
import coloredlogs
|
||||||
from sqlalchemy.ext.declarative import declarative_base
|
from sqlalchemy.ext.declarative import declarative_base
|
||||||
from sqlalchemy.orm import sessionmaker, relationship, joinedload
|
from sqlalchemy.orm import sessionmaker, relationship
|
||||||
from sqlalchemy.ext.hybrid import hybrid_property
|
from sqlalchemy.ext.hybrid import hybrid_property
|
||||||
from sqlalchemy import Column, BigInteger, Integer, String, DateTime, ForeignKey, Float, Enum, create_engine, UniqueConstraint, PrimaryKeyConstraint, Boolean, or_, LargeBinary, Text, Date, func, desc
|
from sqlalchemy import Column, BigInteger, Integer, String, DateTime, ForeignKey, Float, Enum, create_engine, UniqueConstraint, PrimaryKeyConstraint, Boolean, or_, LargeBinary, Text, Date, func, desc
|
||||||
import requests
|
import requests
|
||||||
|
@ -31,6 +30,7 @@ logger = logging.getLogger(__name__)
|
||||||
os.environ["COLOREDLOGS_LOG_FORMAT"] = "%(asctime)s %(levelname)s %(name)s %(message)s"
|
os.environ["COLOREDLOGS_LOG_FORMAT"] = "%(asctime)s %(levelname)s %(name)s %(message)s"
|
||||||
coloredlogs.install(level="DEBUG", logger=logger)
|
coloredlogs.install(level="DEBUG", logger=logger)
|
||||||
|
|
||||||
|
|
||||||
class Royal(Base):
|
class Royal(Base):
|
||||||
__tablename__ = "royals"
|
__tablename__ = "royals"
|
||||||
|
|
||||||
|
@ -964,22 +964,17 @@ class Halloween(Base):
|
||||||
return count
|
return count
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def event_started() -> bool:
|
def puzzle_status() -> typing.Tuple[bool, typing.List[bool]]:
|
||||||
session = Session()
|
|
||||||
halloweens = session.query(Halloween).all()
|
|
||||||
return bool(halloweens)
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def puzzle_status() -> typing.List[bool]:
|
|
||||||
session = Session()
|
session = Session()
|
||||||
halloweens = session.query(Halloween).all()
|
halloweens = session.query(Halloween).all()
|
||||||
session.close()
|
session.close()
|
||||||
|
started = bool(halloweens)
|
||||||
completed = [False for _ in range(10)]
|
completed = [False for _ in range(10)]
|
||||||
for h in halloweens:
|
for h in halloweens:
|
||||||
for i in range(10):
|
for i in range(10):
|
||||||
if h[i+1]:
|
if h[i+1]:
|
||||||
completed[i] = True
|
completed[i] = True
|
||||||
return completed
|
return started, completed
|
||||||
|
|
||||||
# If run as script, create all the tables in the db
|
# If run as script, create all the tables in the db
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
82
ohciaovedochestaileggendoilmiostato.py
Normal file
82
ohciaovedochestaileggendoilmiostato.py
Normal file
|
@ -0,0 +1,82 @@
|
||||||
|
import secrets
|
||||||
|
from flask import Flask, render_template, request, abort, redirect, url_for, Markup, escape, jsonify
|
||||||
|
from flask import session as fl_session
|
||||||
|
from flask import g as fl_g
|
||||||
|
import db
|
||||||
|
import bcrypt
|
||||||
|
import configparser
|
||||||
|
import markdown2
|
||||||
|
import datetime
|
||||||
|
import telegram
|
||||||
|
import query_discord_music
|
||||||
|
import random
|
||||||
|
import re
|
||||||
|
from raven.contrib.flask import Sentry
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
app.jinja_env.trim_blocks = True
|
||||||
|
app.jinja_env.lstrip_blocks = True
|
||||||
|
|
||||||
|
config = configparser.ConfigParser()
|
||||||
|
config.read("config.ini")
|
||||||
|
|
||||||
|
app.secret_key = config["Flask"]["secret_key"]
|
||||||
|
|
||||||
|
telegram_bot = telegram.Bot(config["Telegram"]["bot_token"])
|
||||||
|
|
||||||
|
sentry = Sentry(app, dsn=config["Sentry"]["token"])
|
||||||
|
|
||||||
|
|
||||||
|
@app.before_request
|
||||||
|
def pre_request():
|
||||||
|
fl_g.event_started, fl_g.event_progress = db.Halloween.puzzle_status()
|
||||||
|
fl_g.time_left = datetime.datetime.fromtimestamp(1540999800) - datetime.datetime.now()
|
||||||
|
fl_g.display_on_main_site = (fl_g.time_left < datetime.timedelta(days=7)) or __debug__
|
||||||
|
fl_g.css = "spoopy.less" if (fl_g.event_started or __debug__) else "nryg.less"
|
||||||
|
fl_g.rygconf = config
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/")
|
||||||
|
def page_owlcaptain():
|
||||||
|
return render_template("ohciaodinuovo.html")
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/voiceofevil", methods=["POST"])
|
||||||
|
def page_voiceofevil():
|
||||||
|
if request.form.get("solution", "") != "1":
|
||||||
|
abort(400)
|
||||||
|
return
|
||||||
|
db_session = db.Session()
|
||||||
|
halloween = db_session.query(db.Halloween).filter_by(royal_id=fl_session["user_id"]).one_or_none()
|
||||||
|
if halloween is None:
|
||||||
|
abort(403)
|
||||||
|
return
|
||||||
|
halloween[3] = True
|
||||||
|
db_session.commit()
|
||||||
|
return redirect(url_for("page_owlcaptain"))
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/mansion", methods=["POST"])
|
||||||
|
def page_mansion():
|
||||||
|
if request.form.get("solution", "") != "bobooboooboooo":
|
||||||
|
abort(400)
|
||||||
|
return
|
||||||
|
db_session = db.Session()
|
||||||
|
halloween = db_session.query(db.Halloween).filter_by(royal_id=fl_session["user_id"]).one_or_none()
|
||||||
|
if halloween is None:
|
||||||
|
abort(403)
|
||||||
|
return
|
||||||
|
halloween[5] = True
|
||||||
|
db_session.commit()
|
||||||
|
return redirect(url_for("page_owlcaptain"))
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/whatpumpkin", methods=["POST"])
|
||||||
|
def page_whatpumpkin():
|
||||||
|
abort(400)
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
app.run(debug=True, port=1235)
|
BIN
static/ee.ogg
BIN
static/ee.ogg
Binary file not shown.
|
@ -777,7 +777,7 @@ table {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ntry {
|
.entry {
|
||||||
display: grid;
|
display: grid;
|
||||||
|
|
||||||
.left {
|
.left {
|
||||||
|
|
0
static/owl.less
Normal file
0
static/owl.less
Normal file
Binary file not shown.
BIN
static/snesfile.zip
Normal file
BIN
static/snesfile.zip
Normal file
Binary file not shown.
|
@ -755,7 +755,7 @@ table {
|
||||||
padding: 18px;
|
padding: 18px;
|
||||||
grid-template-columns: 100%;
|
grid-template-columns: 100%;
|
||||||
|
|
||||||
.moons.game-score {
|
.mysterystatus.game-score {
|
||||||
font-size: 0;
|
font-size: 0;
|
||||||
|
|
||||||
i {
|
i {
|
||||||
|
@ -791,7 +791,7 @@ table {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ntry {
|
.entry {
|
||||||
display: grid;
|
display: grid;
|
||||||
|
|
||||||
.left {
|
.left {
|
||||||
|
@ -855,19 +855,15 @@ ntry {
|
||||||
}
|
}
|
||||||
|
|
||||||
.halloween {
|
.halloween {
|
||||||
.upper-box {
|
|
||||||
font-size: xx-large;
|
|
||||||
}
|
|
||||||
|
|
||||||
.lower-box {
|
.lower-box {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
|
||||||
.time-left {
|
.time-left {
|
||||||
font-size: 64px;
|
font-size: 64px;
|
||||||
font-family: monospace;
|
font-family: "Consolas", "Source Code Pro", monospace;
|
||||||
}
|
}
|
||||||
|
|
||||||
.moons {
|
.mysterystatus {
|
||||||
font-size: 64px;
|
font-size: 64px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -921,15 +917,13 @@ ntry {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.moons a {
|
.mysterystatus i {
|
||||||
color: @text-color;
|
&.todo {
|
||||||
|
color: rgba(255, 255, 0, 0.2);
|
||||||
&:hover {
|
|
||||||
color: @highlight-color;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.fas {
|
&.done {
|
||||||
color: yellow;
|
color: rgba(255, 255, 0, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -134,7 +134,8 @@ def cmd_cast(bot: Bot, update: Update):
|
||||||
|
|
||||||
@catch_and_report
|
@catch_and_report
|
||||||
def cmd_color(bot: Bot, update: Update):
|
def cmd_color(bot: Bot, update: Update):
|
||||||
bot.send_message(update.message.chat.id, "I am sorry, unknown error occured during working with your request, Admin were notified")
|
bot.send_message(update.message.chat.id, "I am sorry, unknown error occured during working with your request,"
|
||||||
|
" Admin were notified")
|
||||||
|
|
||||||
|
|
||||||
@catch_and_report
|
@catch_and_report
|
||||||
|
|
|
@ -7,7 +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">
|
||||||
<link href="{{ url_for('static', filename={{ g["css"] }}) }}" rel="stylesheet/less" type="text/css">
|
<link href="{{ url_for('static', filename=g.css) }}" rel="stylesheet/less" type="text/css">
|
||||||
<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>
|
||||||
|
@ -19,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="{{ g["rygconf"]['Telegram']['invite_link'] }}">Telegram</a>
|
<a href="{{ g.rygconf['Telegram']['invite_link'] }}">Telegram</a>
|
||||||
<a href="{{ g["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 %}
|
||||||
|
|
|
@ -10,16 +10,16 @@
|
||||||
|
|
||||||
{% block posthead %}
|
{% block posthead %}
|
||||||
<script>
|
<script>
|
||||||
function timer() {
|
function timer() {
|
||||||
let now = new Date().getTime();
|
let now = new Date().getTime();
|
||||||
let to = new Date("Oct 31, 2018 15:30:00").getTime();
|
let to = new Date("Oct 31, 2018 15:30:00").getTime();
|
||||||
let result = to - now;
|
let result = to - now;
|
||||||
document.getElementById("time-left").innerHTML = Math.floor(String((result / 3600000))) + "h "
|
document.getElementById("time-left").innerHTML = Math.floor(String((result / 3600000))) + "h "
|
||||||
+ Math.floor(String((result / 60000) % 60)) + "m "
|
+ Math.floor(String((result / 60000) % 60)) + "m "
|
||||||
+ Math.floor(String((result / 1000) % 60)) + "s";
|
+ Math.floor(String((result / 1000) % 60)) + "s";
|
||||||
}
|
}
|
||||||
|
|
||||||
setInterval(timer, 100);
|
setInterval(timer, 100);
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
@ -28,20 +28,20 @@
|
||||||
Royal Games
|
Royal Games
|
||||||
</h1>
|
</h1>
|
||||||
<div class="main-page">
|
<div class="main-page">
|
||||||
{% if g["css"] == "spoopy.less" %}
|
{% if g.time_left %}
|
||||||
<div class="halloween">
|
<div class="halloween">
|
||||||
<div class="box">
|
<div class="box">
|
||||||
<div class="upper-box">
|
<div class="upper-box">
|
||||||
Rituale di Halloween!
|
owlcaptain.tk
|
||||||
</div>
|
</div>
|
||||||
<div class="lower-box">
|
<div class="lower-box">
|
||||||
Lune raccolte:
|
Lune raccolte:
|
||||||
<div class="moons">
|
<div class="mysterystatus">
|
||||||
{% for index, star in halloween %}
|
{% for index, star in halloween %}
|
||||||
{% if star %}
|
{% if star %}
|
||||||
<a href="/ritual/{{ index }}" title="Luna {{ index }} ottenuta!"><i class="fas fa-moon"></i></a>
|
<i class="fas fa-moon done"></i>
|
||||||
{% else %}
|
{% else %}
|
||||||
<a href="/ritual/{{ index }}" title="Rituale {{ index }}"><i class="far fa-moon"></i></a>
|
<i class="far fa-moon todo"></i>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
@ -97,8 +97,8 @@
|
||||||
<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 rygconf["Events"]["halloween"] %}
|
{% if g.css == "spoopy.less" %}
|
||||||
<li><a href="/game/halloween">Rituale di Halloween</a></li>
|
<li><a href="/game/halloween">Halloween</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<li><a href="/game/tg">Telegram</a></li>
|
<li><a href="/game/tg">Telegram</a></li>
|
||||||
<li><a href="/game/discord">Discord</a></li>
|
<li><a href="/game/discord">Discord</a></li>
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
<div class="game-panel">
|
<div class="game-panel">
|
||||||
<div class="game-grid halloweenmini">
|
<div class="game-grid halloweenmini">
|
||||||
<div class="player">
|
<div class="player">
|
||||||
<span class="player-name">Rituale di Halloween</span>
|
<span class="player-name">{{ record.royal.username }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="game-title moons">
|
<div class="game-title mysterystatus">
|
||||||
Lune ottenute
|
Lune ottenute
|
||||||
</div>
|
</div>
|
||||||
<div class="game-score moons">
|
<div class="game-score mysterystatus">
|
||||||
{% for index in range(10) %}
|
{% for index in range(10) %}
|
||||||
{% if halloween[index] %}
|
{% if record[index + 1] %}
|
||||||
<a href="/ritual/{{ index + 1 }}" title="Luna {{ index + 1 }} ottenuta!"><i class="fas fa-moon"></i></a>
|
<i class="fas fa-moon done"></i>
|
||||||
{% else %}
|
{% else %}
|
||||||
<a href="/ritual/{{ index + 1 }}" title="Rituale {{ index + 1 }}"><i class="far fa-moon"></i></a>
|
<i class="far fa-moon todo"></i>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
|
154
templates/ohciaodinuovo.html
Normal file
154
templates/ohciaodinuovo.html
Normal file
|
@ -0,0 +1,154 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="it">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width">
|
||||||
|
<meta name="keywords" content="Royal Games, halloween, arg">
|
||||||
|
<title>a curse.</title>
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/less.js/3.0.2/less.min.js"></script>
|
||||||
|
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">
|
||||||
|
<script>
|
||||||
|
function timer() {
|
||||||
|
let now = new Date().getTime();
|
||||||
|
let to = new Date("Oct 31, 2018 15:30:00").getTime();
|
||||||
|
let result = to - now;
|
||||||
|
document.getElementById("time-left").innerHTML = Math.floor(String((result / 3600000))) + "h "
|
||||||
|
+ Math.floor(String((result / 60000) % 60)) + "m "
|
||||||
|
+ Math.floor(String((result / 1000) % 60)) + "s";
|
||||||
|
}
|
||||||
|
|
||||||
|
setInterval(timer, 100);
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<h1>
|
||||||
|
a curse.
|
||||||
|
</h1>
|
||||||
|
<div class="timer">
|
||||||
|
<span id="time-left"></span>
|
||||||
|
</div>
|
||||||
|
<div class="curse">
|
||||||
|
a curse lies in waiting for the night of the dead.<br>
|
||||||
|
you and your friends are in danger.<br>
|
||||||
|
stop it before it activates.<br>
|
||||||
|
<br>
|
||||||
|
i'm willing to help you.<br>
|
||||||
|
you will have to perform a ritual.<br>
|
||||||
|
here are the steps.<br>
|
||||||
|
<br>
|
||||||
|
you can perform them in any order, except for the final step.<br>
|
||||||
|
i'll reveal that when all others are complete, just to be safe.
|
||||||
|
</div>
|
||||||
|
<div class="subquests">
|
||||||
|
{% for quest in g.event_progress %}
|
||||||
|
<div class="quest {% if quest %}quest-clear{% endif %}" id="{{ loop.index }}">
|
||||||
|
<div class="progress">
|
||||||
|
{% if quest %}
|
||||||
|
<i class="fas fa-moon done"></i>
|
||||||
|
{% else %}
|
||||||
|
<i class="far fa-moon todo"></i>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
{% if loop.index == 1 %}
|
||||||
|
{# hecarim o chaos knight #}
|
||||||
|
<h2>
|
||||||
|
unleash the horsemen
|
||||||
|
</h2>
|
||||||
|
<div>
|
||||||
|
you'll need the help of the horsemen of the apocalypse to dispel the curse.<br>
|
||||||
|
lead Chaos to victory in the battle of the ancients, or the War from the shadow isles to victory on the rift, and you'll gain their support.
|
||||||
|
</div>
|
||||||
|
{% elif loop.index == 2 %}
|
||||||
|
{# la zucca di balu e max #}
|
||||||
|
<h2>
|
||||||
|
carve the ritual pumpkin
|
||||||
|
</h2>
|
||||||
|
<div>
|
||||||
|
prepare a pumpkin, and empty its inside.<br>
|
||||||
|
carve something on its exterior then put a light inside of it.<br>
|
||||||
|
when dusk has come, take a picture, and <a href="/whatpumpkin">post it to the owl captain</a>.
|
||||||
|
</div>
|
||||||
|
{% elif loop.index == 3 %}
|
||||||
|
{# https://osu.ppy.sh/beatmapsets/385#osu/2038 #}
|
||||||
|
<h2>
|
||||||
|
circle the sound
|
||||||
|
</h2>
|
||||||
|
<div>
|
||||||
|
find the 2038th sound of halloween.<br>
|
||||||
|
then, follow the circle pattern.<br>
|
||||||
|
<br>
|
||||||
|
it is rather dashing, isn't it?
|
||||||
|
</div>
|
||||||
|
{% elif loop.index == 4 %}
|
||||||
|
<h2>
|
||||||
|
uproot the evil
|
||||||
|
</h2>
|
||||||
|
<div>
|
||||||
|
listen to the sounds in here.<br>
|
||||||
|
do you hear the evil that stole your voice?<br>
|
||||||
|
answer it.
|
||||||
|
</div>
|
||||||
|
<form action="/voiceofevil" method="POST">
|
||||||
|
<input name="solution" type="text" placeholder="?">
|
||||||
|
<input type="submit" value="this is my answer!">
|
||||||
|
</form>
|
||||||
|
{% elif loop.index == 5 %}
|
||||||
|
<h2>
|
||||||
|
remove the ghosts
|
||||||
|
</h2>
|
||||||
|
<div>
|
||||||
|
during the ritual something strange might happen.<br>
|
||||||
|
in that case, the ghosts probably will be to blame.<br>
|
||||||
|
to be safe, i would remove them...<br>
|
||||||
|
<br>
|
||||||
|
who should you call?
|
||||||
|
</div>
|
||||||
|
{% elif loop.index == 6 %}
|
||||||
|
<h2>
|
||||||
|
conquer the mansion
|
||||||
|
</h2>
|
||||||
|
<div>
|
||||||
|
a mansion has appeared.<br>
|
||||||
|
prove yourself worthy, and find the words hidden deep inside.<br>
|
||||||
|
only then i can trust you to completely perform the ritual.
|
||||||
|
</div>
|
||||||
|
<form action="/mansion" method="POST">
|
||||||
|
<input name="solution" type="text" placeholder="?">
|
||||||
|
<input type="submit" value="this is my answer!">
|
||||||
|
</form>
|
||||||
|
{% elif loop.index == 7 %}
|
||||||
|
<h2>
|
||||||
|
|
||||||
|
</h2>
|
||||||
|
<div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
{% elif loop.index == 8 %}
|
||||||
|
<h2>
|
||||||
|
|
||||||
|
</h2>
|
||||||
|
<div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
{% elif loop.index == 9 %}
|
||||||
|
<h2>
|
||||||
|
|
||||||
|
</h2>
|
||||||
|
<div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
{% elif loop.index == 10 %}
|
||||||
|
<h2>
|
||||||
|
|
||||||
|
</h2>
|
||||||
|
<div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -1,29 +0,0 @@
|
||||||
{% extends 'base.html' %}
|
|
||||||
|
|
||||||
{% block pagetitle %}
|
|
||||||
Rituale {{ n }}
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block body %}
|
|
||||||
<h1>
|
|
||||||
Rituale {{ n }}
|
|
||||||
</h1>
|
|
||||||
<div class="ritual-page">
|
|
||||||
<div class="ritual-description">
|
|
||||||
{% if n == 1 %}
|
|
||||||
{% elif n == 2 %}
|
|
||||||
{% elif n == 3 %}
|
|
||||||
{% elif n == 4 %}
|
|
||||||
{% elif n == 5 %}
|
|
||||||
{% elif n == 6 %}
|
|
||||||
{% elif n == 7 %}
|
|
||||||
{% elif n == 8 %}
|
|
||||||
{% elif n == 9 %}
|
|
||||||
{% elif n == 10 %}
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
<form method="POST" action="/ritual/{{ n }}">
|
|
||||||
<input type="submit" value="Controlla">
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
|
70
webserver.py
70
webserver.py
|
@ -1,4 +1,5 @@
|
||||||
from flask import Flask, render_template, request, abort, redirect, url_for, Markup, escape
|
import secrets
|
||||||
|
from flask import Flask, render_template, request, abort, redirect, url_for, Markup, escape, jsonify
|
||||||
from flask import session as fl_session
|
from flask import session as fl_session
|
||||||
from flask import g as fl_g
|
from flask import g as fl_g
|
||||||
import db
|
import db
|
||||||
|
@ -84,7 +85,6 @@ def page_profile(name: str):
|
||||||
css = db_session.query(db.ProfileData).filter_by(royal=user).one_or_none()
|
css = db_session.query(db.ProfileData).filter_by(royal=user).one_or_none()
|
||||||
steam = db_session.query(db.Steam).filter_by(royal=user).one_or_none()
|
steam = db_session.query(db.Steam).filter_by(royal=user).one_or_none()
|
||||||
osu = db_session.query(db.Osu).filter_by(royal=user).one_or_none()
|
osu = db_session.query(db.Osu).filter_by(royal=user).one_or_none()
|
||||||
# rl = db_session.query(db.RocketLeague).join(db.Steam).filter_by(royal=user).one_or_none()
|
|
||||||
dota = db_session.query(db.Dota).join(db.Steam).filter_by(royal=user).one_or_none()
|
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()
|
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()
|
ow = db_session.query(db.Overwatch).filter_by(royal=user).one_or_none()
|
||||||
|
@ -333,6 +333,34 @@ def page_diario():
|
||||||
return render_template("diario.html", g=fl_g, entries=diario_entries)
|
return render_template("diario.html", g=fl_g, entries=diario_entries)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/api/token")
|
||||||
|
def page_token():
|
||||||
|
username = request.form.get("username", "")
|
||||||
|
password = request.form.get("password", "")
|
||||||
|
db_session = db.Session()
|
||||||
|
user = db_session.query(db.Royal).filter_by(username=username).one_or_none()
|
||||||
|
if user is None:
|
||||||
|
db_session.close()
|
||||||
|
abort(403)
|
||||||
|
return
|
||||||
|
if user.password is None:
|
||||||
|
db_session.close()
|
||||||
|
abort(403)
|
||||||
|
if bcrypt.checkpw(bytes(password, encoding="utf8"), user.password):
|
||||||
|
new_token = db.LoginToken(royal=user, token=secrets.token_urlsafe())
|
||||||
|
db_session.add(new_token)
|
||||||
|
db_session.commit()
|
||||||
|
db_session.close()
|
||||||
|
return jsonify({
|
||||||
|
"id": user.id,
|
||||||
|
"username": user.username,
|
||||||
|
"token": new_token.token
|
||||||
|
})
|
||||||
|
else:
|
||||||
|
abort(403)
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
@app.route("/spooky", methods=["POST"])
|
@app.route("/spooky", methods=["POST"])
|
||||||
def page_spooky():
|
def page_spooky():
|
||||||
if request.form.get("solution", "") != "1":
|
if request.form.get("solution", "") != "1":
|
||||||
|
@ -348,41 +376,13 @@ def page_spooky():
|
||||||
return redirect(url_for("page_main"))
|
return redirect(url_for("page_main"))
|
||||||
|
|
||||||
|
|
||||||
@app.route("/ritual/<int:n>", methods=["GET", "POST"])
|
|
||||||
def page_ritual(n: int):
|
|
||||||
user_id = fl_session.get("user_id")
|
|
||||||
if not user_id:
|
|
||||||
return redirect(url_for("page_login"))
|
|
||||||
if request.method == "GET":
|
|
||||||
return render_template("ritual.html", g=fl_g, n=n)
|
|
||||||
elif request.method == "POST":
|
|
||||||
if n == 1:
|
|
||||||
pass
|
|
||||||
elif n == 2:
|
|
||||||
pass
|
|
||||||
elif n == 3:
|
|
||||||
pass
|
|
||||||
elif n == 4:
|
|
||||||
pass
|
|
||||||
elif n == 5:
|
|
||||||
pass
|
|
||||||
elif n == 6:
|
|
||||||
pass
|
|
||||||
elif n == 7:
|
|
||||||
pass
|
|
||||||
elif n == 8:
|
|
||||||
pass
|
|
||||||
elif n == 9:
|
|
||||||
pass
|
|
||||||
elif n == 10:
|
|
||||||
pass
|
|
||||||
return redirect(url_for("page_ritual", n=n))
|
|
||||||
|
|
||||||
|
|
||||||
@app.before_request
|
@app.before_request
|
||||||
def pre_request():
|
def pre_request():
|
||||||
fl_g["css"] = "spoopy.less" if db.Halloween.event_started() else "nryg.less"
|
fl_g.event_started, fl_g.event_progress = db.Halloween.puzzle_status()
|
||||||
fl_g["rygconf"] = config
|
fl_g.time_left = datetime.datetime.fromtimestamp(1540999800) - datetime.datetime.now()
|
||||||
|
fl_g.display_on_main_site = (fl_g.time_left < datetime.timedelta(days=7)) or __debug__
|
||||||
|
fl_g.css = "spoopy.less" if (fl_g.event_started or __debug__) else "nryg.less"
|
||||||
|
fl_g.rygconf = config
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
Loading…
Reference in a new issue