| from ..config import CALENDAR_ICS | |
| def run(params: dict) -> dict: | |
| if not CALENDAR_ICS.exists(): | |
| return {"status": "empty", "events": []} | |
| try: | |
| from icalendar import Calendar | |
| cal = Calendar.from_ical(CALENDAR_ICS.read_bytes()) | |
| events = [{"summary": str(c.get("SUMMARY", "")), | |
| "start": str(c.get("DTSTART", "").dt) if c.get("DTSTART") else ""} | |
| for c in cal.walk("VEVENT")] | |
| return {"status": "ok", "events": events[:20]} | |
| except Exception as e: | |
| return {"status": "error", "error": str(e)} | |