diff --git a/.env b/.env index d30cb7a..3901b31 100644 --- a/.env +++ b/.env @@ -1 +1,2 @@ BOT_TOKEN=8488665890:AAH7FY5I2xzHhfOdxlzb11ewl2I-MMTH2-o +TZ=Europe/Moscow diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c616d85 --- /dev/null +++ b/.gitignore @@ -0,0 +1,20 @@ +__pycache__/ +*.py[cod] +*.sqlite3 +*.log + +.venv/ +venv/ + +.env + +media/ +staticfiles/ + +db/ + +.vscode/ +.idea/ + +.pytest_cache/ +.mypy_cache/ diff --git a/__pycache__/main.cpython-313.pyc b/__pycache__/main.cpython-313.pyc index 0c4ca1d..8f2bc3e 100644 Binary files a/__pycache__/main.cpython-313.pyc and b/__pycache__/main.cpython-313.pyc differ diff --git a/main.py b/main.py index a1c5003..60d9723 100644 --- a/main.py +++ b/main.py @@ -13,9 +13,11 @@ from aiogram.types import BufferedInputFile, Message, BotCommand from aiogram.client.default import DefaultBotProperties from PIL import Image, ImageDraw, ImageFont from datetime import datetime, time, timedelta +from zoneinfo import ZoneInfo BASE_DIR = Path(__file__).parent FONT_PATH = BASE_DIR / "impact.ttf" +DEFAULT_TZ = os.getenv("TZ", "Europe/Moscow") TEMPLATES = { "1": { "path": BASE_DIR / "maket" / "1.png", @@ -88,7 +90,10 @@ SCHEDULE: dict[int, list[tuple[time, time, int | None]]] = { def minutes_until_break(now: datetime | None = None) -> str: - now = now or datetime.now() + if now is None: + now = datetime.now(ZoneInfo(DEFAULT_TZ)) + elif now.tzinfo is None: + now = now.replace(tzinfo=ZoneInfo(DEFAULT_TZ)) day = now.weekday() today_schedule = SCHEDULE.get(day, []) if not today_schedule: