diff --git a/pgbotlib/cron.py b/pgbotlib/cron.py index b4c06b6..01cdb25 100644 --- a/pgbotlib/cron.py +++ b/pgbotlib/cron.py @@ -1,5 +1,6 @@ import asyncio import random +import sys import aiocron import telethon @@ -16,7 +17,12 @@ class Cron: client: telethon.TelegramClient, responder: pgbotlib.response.Responder) -> None: schedule_conf = config.get('schedule', pgbotlib.defaults.SCHEDULE) - self.tz = config.get('timezone', pgbotlib.defaults.TZ) + local_tz = config.get('timezone', pgbotlib.defaults.TZ) + try: + self.tz = pytz.timezone(local_tz) + except pytz.exceptions.UnknownTimeZoneError as e: + sys.stderr.write(e) + self.tz = pytz.utc with open(schedule_conf, 'r', encoding='utf-8') as data: self.sched = yaml.safe_load(data.read()) self.responder = responder