From 09ac37569f8b5ab4dc9a57ac923372aeacddecfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Ml=C3=A1dek?= Date: Sat, 12 Jun 2021 22:02:30 +0200 Subject: [PATCH] specify cal urls im env vars --- bot.py | 6 +++++- config.py | 5 ----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/bot.py b/bot.py index 1168de0..35792d5 100644 --- a/bot.py +++ b/bot.py @@ -99,10 +99,14 @@ async def main(): except FileNotFoundError: state = {"notified": [], "notified_soon": []} + urls = os.getenv("PISS_URLS", "").split(",") + if not urls: + raise RuntimeError("No PISS_URLS specified!") + while True: calendars = [] async with aiohttp.ClientSession() as session: - for url in config.URLS: + for url in urls: logging.debug(f"Requesting {url}...") async with session.get(url) as resp: calendars.append(Calendar(await resp.text())) diff --git a/config.py b/config.py index 1b320b5..e7e5fb3 100644 --- a/config.py +++ b/config.py @@ -3,11 +3,6 @@ class Config: TG_API_KEY = None TG_CHAT_ID = None AVATAR_URL = 'https://gitlab.com/sdbs_cz/piss-bot/-/raw/master/piss.jpg' - URLS = [ - 'https://sdbs.cz/wp-content/themes/sdbs/file-download.php?type=in', - 'https://sdbs.cz/wp-content/themes/sdbs/file-download.php?type=out', - 'http://cloud.sdbs.cz/remote.php/dav/public-calendars/R5kWLqcrDFaQYE2e?export' - ] EVENT_TEMPLATE = "
".join(( "{title}", "{date} {location}",