diff --git a/cast.py b/cast.py index 8a0f6569..3250b9f8 100644 --- a/cast.py +++ b/cast.py @@ -3,7 +3,7 @@ import math import db -def cast(spell_name: str, target_name: str, platform: str, halloween_callback=None) -> str: +def cast(spell_name: str, target_name: str, platform: str) -> str: spell = spell_name.capitalize() # Seed the rng with the spell name # so that spells always deal the same damage @@ -41,7 +41,6 @@ def cast(spell_name: str, target_name: str, platform: str, halloween_callback=No crit_msg = "" # HALLOWEEN if total >= 800: - halloween_callback() return f"❇️ Ho lanciato {spell} su " \ f"{target_name}.\n" \ f"{crit_msg}" \ diff --git a/db.py b/db.py index 9f2dc291..bfb4b4a8 100644 --- a/db.py +++ b/db.py @@ -966,47 +966,6 @@ class Halloween(Base): if h[i+1]: completed[i] = True return started, completed - - def update(self, session): - if self[1] is None: - # Dota last match - dota = session.query(Dota).join(Steam).join(Royal).filter_by(id=self.royal.id).one_or_none() - if dota is not None: - dota_id = Steam.to_steam_id_3(dota.steam_id) - r = requests.get(f"https://api.opendota.com/api/players/{dota_id}/recentMatches") - if r.status_code != 200: - raise RequestError("Error in the Halloween Dota check.") - j = r.json() - match = j[0] - if match["hero_id"] == 81 and (match["radiant_win"] ^ match["player_slot"] // 128): - logging.debug(f"{self.royal.username} has obtained Moon A via Dota.") - self[1] = datetime.datetime.now() - else: - logging.debug(f"{self.royal.username} hasn't passed the LoL challenge yet.") - # LoL last match - lol = session.query(LeagueOfLegends).join(Royal).filter_by(id=self.royal.id).one_or_none() - if lol is not None: - r = requests.get(f"https://euw1.api.riotgames.com/lol/match/v3/matchlists/by-account/{lol.account_id}" - f"?api_key={config['League of Legends']['riot_api_key']}") - if r.status_code != 200: - raise RequestError("Error in the Halloween LoL check.") - j = r.json() - match = j["matches"][0] - if match["champion"] == 120: - self[1] = datetime.datetime.now() - logging.debug(f"{self.royal.username} has obtained Moon A via LoL.") - else: - logging.debug(f"{self.royal.username} hasn't passed the LoL challenge yet.") - if self[3] is None: - # osu! sss - osu = session.query(Osu).join(Royal).filter_by(id=self.royal.id).one_or_none() - if osu is not None: - r = requests.get(f"https://osu.ppy.sh/api/get_scores" - f"?k={config['Osu!']['ppy_api_key']}&b=2038&u={osu.osu_id}") - j = r.json() - if len(j) > 0: - self[3] = datetime.datetime.now() - # If run as script, create all the tables in the db if __name__ == "__main__": diff --git a/discordbot.py b/discordbot.py index fc34d818..9423e31a 100644 --- a/discordbot.py +++ b/discordbot.py @@ -220,7 +220,7 @@ class SecretVideo(Video): # Check if the file has been downloaded if not self.downloaded: raise FileNotDownloadedError() - return discord.PCMVolumeTransformer(discord.FFmpegPCMAudio(f"./static/{self.file}", **ffmpeg_settings)) + return discord.PCMVolumeTransformer(discord.FFmpegPCMAudio(f"./opusfiles/{self.file}", **ffmpeg_settings)) def command(func): @@ -567,14 +567,6 @@ class RoyalDiscordBot(discord.Client): filename=now_playing.plain_text(), timestamp=datetime.datetime.now()) session.add(played_music) - # EASTER EGG, REMOVE LATER - if "ghostbusters" in now_playing.plain_text().lower(): - halloween = await loop.run_in_executor(executor, session.query(db.Halloween) - .filter_by(royal=enqueuer.royal) - .one_or_none) - if halloween is not None: - halloween[5] = datetime.datetime.now() - # END await loop.run_in_executor(executor, session.commit) await loop.run_in_executor(executor, session.close) except sqlalchemy.exc.OperationalError: @@ -706,7 +698,7 @@ class RoyalDiscordBot(discord.Client): if self.radio_messages: self.next_radio_message_in -= 1 if self.next_radio_message_in <= 0: - radio_message = random.sample(spooky_radio_messages if db.Halloween.puzzle_status()[0] else radio_messages, 1)[0] + radio_message = random.sample(radio_messages, 1)[0] self.next_radio_message_in = int(config["Discord"]["radio_messages_every"]) await self.add_video_from_url(radio_message) await channel.send(f"📻 Aggiunto un messaggio radio, disattiva con `!radiomessages off`.") diff --git a/owlcaptain.py b/owlcaptain.py deleted file mode 100644 index 9e0e65da..00000000 --- a/owlcaptain.py +++ /dev/null @@ -1,81 +0,0 @@ -from flask import Flask, render_template, request, abort, redirect, url_for -from flask import g as fl_g -import db -import configparser -import datetime -import telegram -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.all_moons_done = True - for moon in fl_g.event_progress: - if not moon: - fl_g.all_moons_done = False - 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("owlcaptain.html") - - -@app.route("/voiceofevil", methods=["POST"]) -def page_voiceofevil(): - if request.form.get("solution", "") != "1": - abort(400) - return - if "user_id" not in request.form: - abort(403) - return - db_session = db.Session() - halloween = db_session.query(db.Halloween).filter_by(royal_id=request.form["user_id"]).one_or_none() - if halloween is None: - abort(403) - return - halloween[4] = datetime.datetime.now() - 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=request.form["user_id"]).one_or_none() - if halloween is None: - abort(403) - return - halloween[6] = datetime.datetime.now() - db_session.commit() - return redirect(url_for("page_owlcaptain")) - - -@app.route("/whatpumpkin", methods=["POST"]) -def page_whatpumpkin(): - return redirect("https://t.me/Steffo") - - -if __name__ == "__main__": - app.run(debug=True, port=1234) diff --git a/stagismo.py b/stagismo.py index 36bc9ebf..1a1153d8 100644 --- a/stagismo.py +++ b/stagismo.py @@ -42,4 +42,4 @@ listona = ["della secca", "del seccatore", "del secchiello", "del secchio", "del "della scatola", "del supercalifragilistichespiralidoso", "del sale", "del salame", "di (Town of) Salem", "di Stronghold", "di SOMA", "dei Saints", "di S.T.A.L.K.E.R.", "di Sanctum", "dei Sims", "di Sid", "delle Skullgirls", "di Sonic", "di Spiral (Knights)", "di Spore", "di Starbound", "di SimCity", "di Sensei", - "di Ssssssssssssss... Boom! E' esploso il dizionario", "della scala", "di Sakura"] + "di Ssssssssssssss... Boom! E' esploso il dizionario", "della scala", "di Sakura", "di Suzie"] diff --git a/static/despair.ogg b/static/despair.ogg deleted file mode 100644 index 6647a060..00000000 Binary files a/static/despair.ogg and /dev/null differ diff --git a/static/endgame.ogg b/static/endgame.ogg deleted file mode 100644 index 7b3efb1b..00000000 Binary files a/static/endgame.ogg and /dev/null differ diff --git a/static/nryg.less b/static/nryg.less index 03c55118..85a6d68b 100644 --- a/static/nryg.less +++ b/static/nryg.less @@ -878,6 +878,16 @@ table { } } +.mysterystatus i { + &.todo { + color: rgba(255, 255, 0, 0.2); + } + + &.done { + color: rgba(255, 255, 0, 1); + } +} + #debug-mode { color: red; font-weight: bold; diff --git a/static/owl.less b/static/owl.less deleted file mode 100644 index 1fc1e6ef..00000000 --- a/static/owl.less +++ /dev/null @@ -1,63 +0,0 @@ -body { - background-color: black; - color: white; - box-sizing: border-box; -} - -#time-left { - font-family: monospace; - font-size: 110px; - color: grey; -} - -.container { - max-width: 900px; - margin-left: auto; - margin-right: auto; -} - -.quest { - display: grid; - grid-template-columns: 64px auto; - grid-column-gap: 12px; - margin-top: 36px; - margin-bottom: 36px; - - .progress { - grid-row-start: 1; - grid-row-end: 4; - grid-column: 1; - - i { - display: block; - padding-top: 8px; - font-size: 64px; - color: yellow; - - &.todo { - color: rgba(255, 255, 0, 0.2); - } - - &.done { - color: rgba(255, 255, 0, 1); - } - } - } - - h2 { - grid-row: 1; - grid-column: 2; - margin-top: 0; - margin-bottom: 4px; - } - - .description { - grid-row: 2; - grid-column: 2; - } - - form { - grid-row: 3; - grid-column: 2; - } -} \ No newline at end of file diff --git a/statsupdate.py b/statsupdate.py index 92ac335c..b8bd621f 100644 --- a/statsupdate.py +++ b/statsupdate.py @@ -72,9 +72,6 @@ def process(): logger.info("Pausing for 30 minutes.") time.sleep(1800) session = db.Session() - logger.info("Now updating Halloween data.") - update_block(session, session.query(db.Halloween).all()) - session.commit() logger.info("Now updating Steam data.") update_block(session, session.query(db.Steam).all()) session.commit() diff --git a/telegrambot.py b/telegrambot.py index b982ddc3..f08a077b 100644 --- a/telegrambot.py +++ b/telegrambot.py @@ -124,30 +124,15 @@ def cmd_cast(bot: Bot, update: Update): session = db.Session() # Find a target for the spell target = random.sample(session.query(db.Telegram).all(), 1)[0] - # HALLOWEEN - caster = session.query(db.Telegram).filter_by(telegram_id=update.message.from_user.id).join(db.Royal).one_or_none() - - def callback(): - if caster is None: - return - nsession = db.Session() - halloween = nsession.query(db.Halloween).filter_by(royal=caster.royal).one_or_none() - if halloween is not None: - halloween[7] = datetime.datetime.now() - nsession.commit() - nsession.close() # Close the session session.close() # END - bot.send_message(update.message.chat.id, cast.cast(spell_name=spell, halloween_callback=callback, + bot.send_message(update.message.chat.id, cast.cast(spell_name=spell, target_name=target.username if target.username is not None else target.first_name, platform="telegram"), parse_mode="HTML") - - - @catch_and_report 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," @@ -328,48 +313,6 @@ def on_callback_query(bot: Bot, update: Update): session.close() -@catch_and_report -def cmd_ban(bot: Bot, update: Update): - if datetime.date.today() != datetime.date(2019, 4, 1): - bot.send_message(update.message.chat.id, "⚠ Non è il giorno adatto per bannare persone!") - return - session = db.Session() - try: - last_bans = session.query(db.AprilFoolsBan).filter(db.AprilFoolsBan.datetime > (datetime.datetime.now() - datetime.timedelta(minutes=15))).all() - if len(last_bans) > 0: - bot.send_message(update.message.chat.id, "⚠ /ban è in cooldown.\n" - "Può essere usato solo 1 volta ogni 15 minuti!") - return - try: - arg = update.message.text.split(" ", 1)[1] - except IndexError: - bot.send_message(update.message.chat.id, "⚠ Devi specificare un bersaglio!") - return - target_user = session.query(db.Telegram).filter_by(username=arg).one_or_none() - if target_user is None: - bot.send_message(update.message.chat.id, "⚠ Il bersaglio specificato non esiste nel RYGdb.\n" - "Le possibilità sono due: non è un membro RYG, " - "oppure non si è ancora registrato e va bannato manualmente.") - return - if int(target_user.telegram_id) == 25167391: - bot.send_message(update.message.chat.id, "⚠ Il creatore della chat non può essere espulso.") - return - bannerino = db.AprilFoolsBan(from_user_id=update.message.from_user.id, to_user_id=target_user.telegram_id, datetime=datetime.datetime.now()) - session.add(bannerino) - session.commit() - bot.kick_chat_member(update.message.chat.id, target_user.telegram_id) - bot.unban_chat_member(update.message.chat.id, target_user.telegram_id) - try: - bot.send_message(target_user.telegram_id, "https://t.me/joinchat/AYAGH0TEav8WcbPVfNe75A") - except Exception: - pass - bot.send_message(update.message.chat.id, "🔨") - except Exception as e: - pass - finally: - session.close() - - @catch_and_report def cmd_eat(bot: Bot, update: Update): try: diff --git a/templates/main.html b/templates/main.html index 530cd615..5605cb7e 100644 --- a/templates/main.html +++ b/templates/main.html @@ -28,32 +28,6 @@ Royal Games
- {% if g.event_started %} -
-
-
- owlcaptain.tk -
-
- Lune raccolte: -
- {% for index, star in halloween %} - {% if star %} - - {% else %} - - {% endif %} - {% endfor %} -
-
- Tempo rimanente: -
- Loading... -
-
-
-
- {% endif %}
@@ -61,7 +35,7 @@
{% for event in next_events %} - {% include "/components/event.html" %} + {% include "components/event.html" %} {% endfor %}
diff --git a/templates/owlcaptain.html b/templates/owlcaptain.html deleted file mode 100644 index 0231a80a..00000000 --- a/templates/owlcaptain.html +++ /dev/null @@ -1,187 +0,0 @@ - - - - - - - a curse. - - - - - - -
-

- a curse. -

-
- -
-
- a curse lies in waiting for the night of the dead.
- you and your friends are in danger.
- stop it before it activates.
-
- i'm willing to help you.
- you will have to perform a ritual.
- here are the steps.
-
- you can perform them in any order, except for the final step.
- i'll reveal that when all others are complete, just to be safe. -
-
- {% if g.all_moons_done %} -
-
- -
-

- PERFORM THE RITUAL! -

-
- if you have enough moons, prepare for a journey to the unknown.
- when the time runs out, prepare for the ritual.
- you'll receive the location through a safe channel, please do not spread it. -
-
- {% endif %} - {% for quest in g.event_progress %} -
-
- {% if quest %} - - {% else %} - - {% endif %} -
- {% if loop.index == 1 %} - {# hecarim o chaos knight #} -

- unleash the horsemen -

-
- you'll need the help of the horsemen of the apocalypse to dispel the curse.
- lead Chaos to victory in the battle of the ancients, or summon War from the shadow isles on the rift, and you'll gain their support. -
- {% elif loop.index == 2 %} - {# la zucca di balu e max #} -

- carve the ritual pumpkin -

-
- prepare a pumpkin, and empty its inside.
- carve something on its exterior then put a light inside of it.
- when dusk has come, take a picture, and post it to the owl captain. -
- {% elif loop.index == 3 %} - {# https://osu.ppy.sh/beatmapsets/385#osu/2038 #} -

- circle the sound -

-
- find the 2038th sound of halloween.
- then, follow the circle pattern.
-
- it is rather dashing, isn't it? -
- {% elif loop.index == 4 %} - {# 1 #} -

- uproot the evil -

-
- listen to the sounds in here.
- do you hear the evil that stole your voice?
- answer it.
- - you might need a fiery fox. -
-
- - - -
- {% elif loop.index == 5 %} - {# ghostbusters #} -

- remove the ghosts -

-
- during the ritual something strange might happen.
- in that case, the ghosts probably will be to blame.
- to be safe, i would remove them...
-
- who should you call? -
- {% elif loop.index == 6 %} -

- conquer the mansion -

-
- a mansion has appeared.
- prove yourself worthy, and find the words hidden deep inside.
- only then i can trust you to completely perform the ritual. -
-
- - - -
- {% elif loop.index == 7 %} -

- fire the magic -

-
- the ritual requires very strong magic.
- gather all your power, and hit someone with all of it.
- this magic talisman will absorb it if it's strong enough.
- - the talisman is made of white marble, and has "800+" engraved on it. -
- {% endif %} -
- {% endfor %} -
-
- - \ No newline at end of file diff --git a/templates/wikipage.html b/templates/wikipage.html index 2bea45fe..5b4e22ca 100644 --- a/templates/wikipage.html +++ b/templates/wikipage.html @@ -6,16 +6,20 @@ {% endif %}