diff --git a/cast.py b/cast.py index b89bf362..1fb1dbfd 100644 --- a/cast.py +++ b/cast.py @@ -1,8 +1,9 @@ import random import math +import db -def cast(spell_name: str, target_name: str, platform: str) -> str: +def cast(spell_name: str, target_name: str, platform: str, halloween_callback=None) -> str: spell = spell_name.capitalize() # Seed the rng with the spell name # so that spells always deal the same damage @@ -38,6 +39,14 @@ def cast(spell_name: str, target_name: str, platform: str) -> str: total *= crit else: crit_msg = "" + # HALLOWEEN + if total >= 800: + halloween_callback() + return "❇️ Ho lanciato {spell} su " \ + f"{target_name}.\n" \ + f"{crit_msg}" \ + f"...ma non succede nulla." + # END if platform == "telegram": if dmg_dice == 10 and dmg_max == 100 and dmg_mod == 20: return f"❇️‼️ Ho lanciato {spell} su " \ diff --git a/db.py b/db.py index d2f27b97..202299f7 100644 --- a/db.py +++ b/db.py @@ -993,6 +993,15 @@ class Halloween(Base): 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() + 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/ohciaovedochestaileggendoilmiostato.py b/ohciaovedochestaileggendoilmiostato.py index 8722a723..6b766355 100644 --- a/ohciaovedochestaileggendoilmiostato.py +++ b/ohciaovedochestaileggendoilmiostato.py @@ -1,16 +1,9 @@ -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 Flask, render_template, request, abort, redirect, url_for 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__) diff --git a/static/endgame.ogg b/static/endgame.ogg new file mode 100644 index 00000000..7b3efb1b Binary files /dev/null and b/static/endgame.ogg differ diff --git a/static/owl.less b/static/owl.less index 55a517ca..b5f8d320 100644 --- a/static/owl.less +++ b/static/owl.less @@ -4,6 +4,12 @@ body { box-sizing: border-box; } +#time-left { + font-family: monospace; + font-size: 110px; + color: grey; +} + .container { max-width: 900px; margin-left: auto; diff --git a/statsupdate.py b/statsupdate.py index e184d6af..5211e069 100644 --- a/statsupdate.py +++ b/statsupdate.py @@ -68,8 +68,8 @@ def new_lol_rank(item: db.LeagueOfLegends): def process(): while True: - logger.info("Pausing for 30 minutes.") - time.sleep(1800) + #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()) diff --git a/telegrambot.py b/telegrambot.py index 562572f4..b982ddc3 100644 --- a/telegrambot.py +++ b/telegrambot.py @@ -124,14 +124,30 @@ 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() - bot.send_message(update.message.chat.id, cast.cast(spell_name=spell, + # END + bot.send_message(update.message.chat.id, cast.cast(spell_name=spell, halloween_callback=callback, 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," diff --git a/templates/ohciaodinuovo.html b/templates/ohciaodinuovo.html index 88649621..fdae32d2 100644 --- a/templates/ohciaodinuovo.html +++ b/templates/ohciaodinuovo.html @@ -11,6 +11,7 @@