fix timezone errors

This commit is contained in:
Von Random 2024-11-05 11:39:37 +02:00
parent d5e25f8da3
commit 624d286d8a

View file

@ -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