From 426ba8277f89478871f08a367e12651c5fb789c7 Mon Sep 17 00:00:00 2001 From: Sergey Melekhin Date: Sun, 24 Nov 2024 18:10:53 +0700 Subject: [PATCH] update tree year --- bot/skills/kozula.py | 8 +++++--- bot/skills/still.py | 3 ++- bot/skills/tree.py | 11 ++++++++++- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/bot/skills/kozula.py b/bot/skills/kozula.py index be4450b..aa2b153 100644 --- a/bot/skills/kozula.py +++ b/bot/skills/kozula.py @@ -40,9 +40,11 @@ def _get_usd_rate() -> Optional[float]: def kozula(update: Update, context: CallbackContext): usd_rate = _get_usd_rate() kozula_rates = [ - f"{round(KOZULA_RATE_USD * usd_rate, 2)}₽" - if usd_rate is not None - else "курс ₽ недоступен", + ( + f"{round(KOZULA_RATE_USD * usd_rate, 2)}₽" + if usd_rate is not None + else "курс ₽ недоступен" + ), f"${KOZULA_RATE_USD}", ] diff --git a/bot/skills/still.py b/bot/skills/still.py index e0ccd6f..894c0ee 100644 --- a/bot/skills/still.py +++ b/bot/skills/still.py @@ -35,5 +35,6 @@ def still(update: Update, context: CallbackContext): if text: context.bot.send_message( - chat_id, f"Вот бы сейчас {text} в {to_2k_year(datetime.now().year)} лул 😹😹😹" + chat_id, + f"Вот бы сейчас {text} в {to_2k_year(datetime.now().year)} лул 😹😹😹", ) diff --git a/bot/skills/tree.py b/bot/skills/tree.py index bb5235f..69c3b1b 100644 --- a/bot/skills/tree.py +++ b/bot/skills/tree.py @@ -1,5 +1,7 @@ import logging +from datetime import datetime + from telegram import Update from telegram.ext import Updater, CallbackContext @@ -7,7 +9,14 @@ logger = logging.getLogger(__name__) -AOC_LEADERBOARD_LINK = "https://adventofcode.com/2023/leaderboard/private/view/458538" +now = datetime.now() +year = now.year +if now.month < 12: + year -= 1 + +AOC_LEADERBOARD_LINK = ( + f"https://adventofcode.com/{year}/leaderboard/private/view/458538" +) def add_tree(upd: Updater, handlers_group: int):