implementing formatting text
This commit is contained in:
parent
6be934e374
commit
0c4c41ff84
@ -5,7 +5,7 @@ from pathlib import Path
|
|||||||
import requests
|
import requests
|
||||||
from ics import Calendar, Event
|
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 *
|
from ..feeds import *
|
||||||
|
|
||||||
|
|
||||||
@ -69,8 +69,19 @@ class Routine:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_event_string(event: Event) -> str:
|
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):
|
def run(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -10,10 +10,5 @@ class Development(Routine):
|
|||||||
calendar = self.get_ics()
|
calendar = self.get_ics()
|
||||||
|
|
||||||
for event in calendar.events:
|
for event in calendar.events:
|
||||||
print(event.name, date.event_formatting_values(event, "de"))
|
print(f"Event: {event.name}")
|
||||||
break
|
print(self.get_event_string(event))
|
||||||
|
|
||||||
event_description = f"""
|
|
||||||
Wir treffen uns {event.begin.humanize(locale="de")} zum {event.name}."""
|
|
||||||
print(event_description.strip())
|
|
||||||
print()
|
|
||||||
|
@ -7,13 +7,22 @@ from . import PROGRAM_DATA_DIR, PROGRAM_NAME
|
|||||||
|
|
||||||
logger = logging.getLogger("config")
|
logger = logging.getLogger("config")
|
||||||
_config: dict = {
|
_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": [
|
"active_feeds": [
|
||||||
"mastodon",
|
"mastodon",
|
||||||
"twitter",
|
"twitter",
|
||||||
],
|
],
|
||||||
"weekday_translations": {},
|
|
||||||
"months_translations": {},
|
|
||||||
"ics_url": "",
|
|
||||||
"mastodon": {},
|
"mastodon": {},
|
||||||
"twitter": {},
|
"twitter": {},
|
||||||
"lemmy": {},
|
"lemmy": {},
|
||||||
|
Loading…
Reference in New Issue
Block a user