From b89e1b196b50927b9e33b733721d6a01ec99679f Mon Sep 17 00:00:00 2001 From: chelsea Date: Tue, 11 Nov 2025 23:29:25 -0600 Subject: [PATCH] notify: force env topic --- AIInteraction.py | 1 - Notification.py | 14 +++++++++++--- README.md | 5 ++--- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/AIInteraction.py b/AIInteraction.py index d5b226b..16a6f2d 100644 --- a/AIInteraction.py +++ b/AIInteraction.py @@ -31,7 +31,6 @@ Principles: "action": "schedule_reminder", "reminder": { "message": "short friendly text", - "topic": "adhdbot-", "trigger": { "value": "ISO 8601 timestamp" } diff --git a/Notification.py b/Notification.py index ee4ed4b..f0a5682 100644 --- a/Notification.py +++ b/Notification.py @@ -35,9 +35,7 @@ class NotificationDispatcher: def sendReminder(userId: str, reminder: Dict[str, Any]): metadata = reminder.get("metadata") or {} actualUser = userId or reminder.get("user") or metadata.get("user") or "user" - topic = reminder.get("topic") or metadata.get("topic") - if not topic: - topic = ntfyTopicTemplate.format(userId=actualUser) + topic = NotificationDispatcher.buildTopic(actualUser) url = NotificationDispatcher.buildTopicUrl(topic) if not url: return @@ -76,6 +74,16 @@ class NotificationDispatcher: topicSlug = topic.lstrip("/") return f"{base}/{topicSlug}" + @staticmethod + def buildTopic(actualUser: str) -> str: + template = ntfyTopicTemplate or "" + if not template: + return "" + try: + return template.format(userId=actualUser) + except (KeyError, IndexError, ValueError): + return template + @staticmethod def buildHeaders(message_text: str) -> Dict[str, str]: headers = {"Title": NotificationDispatcher.buildTitleHeader(message_text)} diff --git a/README.md b/README.md index 87c862d..5c4da7a 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ ADHDbot is a FastAPI + Discord assistant that captures ADHD-friendly notes, brea ## At a glance - Opinionated system prompt + tooling contract wired through OpenRouter (Claude Haiku 4.5 by default). - FastAPI surface area for chat runs, notes, and persistent action items—served by Docker or a bare Python venv. -- Notification bridge that turns `schedule_reminder` JSON into ntfy pushes (bring your own topic + auth). +- Notification bridge that turns `schedule_reminder` JSON into ntfy pushes (single ntfy topic defined via env vars). - Hourly agentic workflow that summarizes memory + actions, then nudges the user via a dedicated prompt. - Static React console (`web_App.tsx`) for local demos: send prompts, review transcripts, and edit action items without curl. @@ -99,7 +99,7 @@ Environment variables of interest (see `.env.example`): - `PROMPT_CATEGORY`, `PROMPT_NAME`, `PROMPT_CONTEXT` – defaults for the `/run` endpoint. - `LOG_PROMPTS` (default `1`) – when truthy, every outgoing prompt is logged to stdout so you can audit the final instructions sent to the LLM. - `NTFY_BASE_URL` – when set (e.g., `https://ntfy.scorpi.us`), reminder payloads with `action: schedule_reminder` will be POSTed to ntfy. -- `NTFY_TOPIC_TEMPLATE` – optional format string for topics (default `adhdbot-{userId}`); override per reminder via `reminder.metadata.topic`. +- `NTFY_TOPIC_TEMPLATE` – format string for the ntfy topic slug (default `adhdbot-{userId}`); all reminders are forced through this template so every notification lands in the same subscribed channel. - `NTFY_AUTH_TOKEN` – optional bearer token if your ntfy server requires auth. - `AGENTIC_CATEGORY` / `AGENTIC_PROMPT_NAME` / `AGENTIC_MODE_HINT` – control which prompt handles the hourly agentic sweep (defaults: `agentic/hourly_review`, hint "Agentic review"). - `AGENTIC_NOTES_LIMIT` – how many of the most recent notes to include in the sweep payload (default `5`). @@ -121,7 +121,6 @@ When the assistant schedules a reminder it emits a single JSON block: "action": "schedule_reminder", "reminder": { "message": "short friendly text", - "topic": "adhdbot-", "trigger": { "value": "2025-11-11T02:41:42+00:00" }