diff --git a/publish_meetups/routines/__init__.py b/publish_meetups/routines/__init__.py index 64cba3d..f2f866c 100644 --- a/publish_meetups/routines/__init__.py +++ b/publish_meetups/routines/__init__.py @@ -5,7 +5,7 @@ from pathlib import Path import requests from ics import Calendar, Event -from ..utils import config, error, prompt, ICS_FILE +from ..utils import config, error, prompt, ICS_FILE, date from ..feeds import * @@ -69,8 +69,19 @@ class Routine: @staticmethod def get_event_string(event: Event) -> str: - return f"" + event_config = config.get_field("messages", {}).get(event.name, {}) + if not len(event_config): + return "" + + message = event_config.get("message", "") + + data = date.event_formatting_values(event, "de") + + for key, value in data.items(): + message = message.replace(f"{{{key}}}", value) + return message.strip() def run(self): pass + diff --git a/publish_meetups/routines/development.py b/publish_meetups/routines/development.py index c1da829..e7df689 100644 --- a/publish_meetups/routines/development.py +++ b/publish_meetups/routines/development.py @@ -10,10 +10,5 @@ class Development(Routine): calendar = self.get_ics() for event in calendar.events: - print(event.name, date.event_formatting_values(event, "de")) - break - - event_description = f""" - Wir treffen uns {event.begin.humanize(locale="de")} zum {event.name}.""" - print(event_description.strip()) - print() + print(f"Event: {event.name}") + print(self.get_event_string(event)) diff --git a/publish_meetups/utils/config.py b/publish_meetups/utils/config.py index efa4d4c..9d3e131 100644 --- a/publish_meetups/utils/config.py +++ b/publish_meetups/utils/config.py @@ -7,13 +7,22 @@ from . import PROGRAM_DATA_DIR, PROGRAM_NAME logger = logging.getLogger("config") _config: dict = { + "ics_url": "", + + "locale": "en", + "date_format": "%Y-%m-%d %H:%M:%S", + "time_format": "%H:%M", + "time_format_full_hour": "%H", + + "weekday_translations": {}, + "months_translations": {}, + "active_feeds": [ "mastodon", "twitter", ], - "weekday_translations": {}, - "months_translations": {}, - "ics_url": "", + + "mastodon": {}, "twitter": {}, "lemmy": {},