v0.4.3: include emby-cleaner recap in Sunday digest

The cleaner runs Sunday 4:20 AM and pings ntfy. The Sunday digest now
pulls the last 12h of messages from the emby-cleaner topic and appends
them to the daily summary. Configurable via ntfy_url +
emby_cleaner_topic in base-config.yaml.

Also drop the zoneinfo dependency in favour of a manual EST/EDT offset
calc (the maubot container ships without tzdata).
This commit is contained in:
Maddox 2026-04-28 19:14:24 -04:00
parent 7848d8e6ea
commit 59b8b99076
3 changed files with 54 additions and 2 deletions

View file

@ -28,6 +28,11 @@ sonarr_webhook_secret: ""
digest_enabled: true
digest_hour: 8 # local hour (Indianapolis), 0-23
# Sunday digest also pulls the emby-cleaner recap from ntfy.
# The cleaner runs Sunday 4:20 AM (cron on control); digest fires after.
ntfy_url: "https://ntfy.3ddbrewery.com"
emby_cleaner_topic: "emby-cleaner"
# --- Service endpoints ---
seerr:

View file

@ -1,6 +1,6 @@
maubot: 0.3.1
id: com.3ddbrewery.media
version: 0.4.2
version: 0.4.3
license: MIT
modules:
- media_bot

View file

@ -102,6 +102,8 @@ class Config(BaseProxyConfig):
helper.copy("sonarr_webhook_secret")
helper.copy("digest_enabled")
helper.copy("digest_hour")
helper.copy("ntfy_url")
helper.copy("emby_cleaner_topic")
helper.copy("seerr")
helper.copy("sonarr")
helper.copy("radarr")
@ -1258,7 +1260,9 @@ class MediaBot(Plugin):
s_q = sonarr_q if not isinstance(sonarr_q, Exception) else []
r_q = radarr_q if not isinstance(radarr_q, Exception) else []
today_str = _local_now().strftime("%A, %b %d")
local = _local_now()
is_sunday = local.weekday() == 6 # Mon=0..Sun=6
today_str = local.strftime("%A, %b %d")
lines = [f"**📰 Daily digest — {today_str}**", ""]
lines.append(f"**🆕 Recently added ({len(added)}):**")
for it in added[:8]:
@ -1277,7 +1281,50 @@ class MediaBot(Plugin):
lines.append(f"- *{t.get('name','?')}* — {_human_bytes(t.get('size') or 0)}")
lines.append("")
lines.append(f"**📥 Queued: {len(s_q)} TV · {len(r_q)} movies**")
if is_sunday:
cleaner_lines = await self._fetch_emby_cleaner_recap()
if cleaner_lines:
lines.append("")
lines.append("**🧹 Weekly cleanup (emby-cleaner):**")
lines.extend(cleaner_lines)
await self.client.send_message(
RoomID(room),
TextMessageEventContent(msgtype=MessageType.NOTICE, body="\n".join(lines)),
)
async def _fetch_emby_cleaner_recap(self) -> list[str]:
"""Pull the last 12h of messages from the emby-cleaner ntfy topic."""
ntfy = (self.config["ntfy_url"] or "").rstrip("/")
topic = self.config["emby_cleaner_topic"] or "emby-cleaner"
if not ntfy:
return []
url = f"{ntfy}/{topic}/json?poll=1&since=12h"
try:
async with self.session.get(url) as r:
if r.status >= 400:
self.log.info("ntfy fetch %s%s", url, r.status)
return []
text = await r.text()
except Exception as ex:
self.log.warning("ntfy fetch failed: %s", ex)
return []
out: list[str] = []
for raw in text.splitlines():
raw = raw.strip()
if not raw:
continue
try:
msg = __import__("json").loads(raw)
except Exception:
continue
title = msg.get("title") or ""
body = (msg.get("message") or "").strip()
if title:
out.append(f"- *{title}*")
for line in body.splitlines()[:6]:
line = line.strip()
if line:
out.append(f" {line}")
return out[:25]