v0.6.2: Sunday cleanup recap as separate follow-up message
The Sunday emby-cleaner recap used to be appended to the same digest body and shared the (N/M) byte-length splitting. Now it ships as its own message after the main digest, keeping the daily-digest content focused on what's new and the cleanup recap on what was removed. Closes maubot-media#1. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
f8f89b794e
commit
87eef44d93
2 changed files with 21 additions and 16 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
maubot: 0.3.1
|
maubot: 0.3.1
|
||||||
id: com.3ddbrewery.media
|
id: com.3ddbrewery.media
|
||||||
version: 0.6.1
|
version: 0.6.2
|
||||||
license: MIT
|
license: MIT
|
||||||
modules:
|
modules:
|
||||||
- media_bot
|
- media_bot
|
||||||
|
|
|
||||||
|
|
@ -1659,8 +1659,8 @@ class MediaBot(Plugin):
|
||||||
|
|
||||||
Skips the Completed section entirely when every finished release is
|
Skips the Completed section entirely when every finished release is
|
||||||
already represented in Recently Added; skips Queued when both arrs are
|
already represented in Recently Added; skips Queued when both arrs are
|
||||||
empty; splits long bodies (e.g. Sunday cleanup recap) across numbered
|
empty. On Sundays, the emby-cleaner recap goes out as a separate
|
||||||
messages so Matrix clients don't truncate.
|
follow-up message so the main digest stays focused on what's new.
|
||||||
"""
|
"""
|
||||||
cutoff = datetime.now(timezone.utc).timestamp() - 86400
|
cutoff = datetime.now(timezone.utc).timestamp() - 86400
|
||||||
emby_uid = self._any_emby_uid("")
|
emby_uid = self._any_emby_uid("")
|
||||||
|
|
@ -1704,16 +1704,16 @@ class MediaBot(Plugin):
|
||||||
local = _local_now()
|
local = _local_now()
|
||||||
is_sunday = local.weekday() == 6 # Mon=0..Sun=6
|
is_sunday = local.weekday() == 6 # Mon=0..Sun=6
|
||||||
today_str = local.strftime("%A, %b %d")
|
today_str = local.strftime("%A, %b %d")
|
||||||
lines = [f"**📰 Daily digest — {today_str}**", ""]
|
digest_lines = [f"**📰 Daily digest — {today_str}**", ""]
|
||||||
lines.append(f"**🆕 Recently added ({len(added)}):**")
|
digest_lines.append(f"**🆕 Recently added ({len(added)}):**")
|
||||||
for it in added[:8]:
|
for it in added[:8]:
|
||||||
lines.append("- " + self._fmt_emby_item(it))
|
digest_lines.append("- " + self._fmt_emby_item(it))
|
||||||
if not added:
|
if not added:
|
||||||
lines.append("- (nothing in the last sweep)")
|
digest_lines.append("- (nothing in the last sweep)")
|
||||||
|
|
||||||
if nzb_unique or qbt_unique:
|
if nzb_unique or qbt_unique:
|
||||||
lines.append("")
|
digest_lines.append("")
|
||||||
lines.append(
|
digest_lines.append(
|
||||||
f"**✅ Also completed (not yet in {self._media_label()}): "
|
f"**✅ Also completed (not yet in {self._media_label()}): "
|
||||||
f"{len(nzb_unique) + len(qbt_unique)}** "
|
f"{len(nzb_unique) + len(qbt_unique)}** "
|
||||||
f"(NZBGet: {len(nzb_unique)} · qBt: {len(qbt_unique)})"
|
f"(NZBGet: {len(nzb_unique)} · qBt: {len(qbt_unique)})"
|
||||||
|
|
@ -1721,21 +1721,26 @@ class MediaBot(Plugin):
|
||||||
for h in nzb_unique[:5]:
|
for h in nzb_unique[:5]:
|
||||||
name = h.get("Name") or h.get("NZBName") or "?"
|
name = h.get("Name") or h.get("NZBName") or "?"
|
||||||
size_mb = h.get("FileSizeMB") or 0
|
size_mb = h.get("FileSizeMB") or 0
|
||||||
lines.append(f"- *{name}* — {size_mb / 1024:.1f} GB")
|
digest_lines.append(f"- *{name}* — {size_mb / 1024:.1f} GB")
|
||||||
for t in qbt_unique[:5]:
|
for t in qbt_unique[:5]:
|
||||||
lines.append(f"- *{t.get('name','?')}* — {_human_bytes(t.get('size') or 0)}")
|
digest_lines.append(f"- *{t.get('name','?')}* — {_human_bytes(t.get('size') or 0)}")
|
||||||
|
|
||||||
if s_q or r_q:
|
if s_q or r_q:
|
||||||
lines.append("")
|
digest_lines.append("")
|
||||||
lines.append(f"**📥 Queued: {len(s_q)} TV · {len(r_q)} movies**")
|
digest_lines.append(f"**📥 Queued: {len(s_q)} TV · {len(r_q)} movies**")
|
||||||
|
|
||||||
|
await self._send_chunked(room, digest_lines)
|
||||||
|
|
||||||
if is_sunday:
|
if is_sunday:
|
||||||
cleaner_lines = await self._fetch_emby_cleaner_recap()
|
cleaner_lines = await self._fetch_emby_cleaner_recap()
|
||||||
if cleaner_lines:
|
if cleaner_lines:
|
||||||
lines.append("")
|
cleanup_lines = ["**🧹 Weekly cleanup (emby-cleaner):**"]
|
||||||
lines.append("**🧹 Weekly cleanup (emby-cleaner):**")
|
cleanup_lines.extend(cleaner_lines)
|
||||||
lines.extend(cleaner_lines)
|
await self._send_chunked(room, cleanup_lines)
|
||||||
|
|
||||||
|
async def _send_chunked(self, room: str, lines: list[str]) -> None:
|
||||||
|
"""Pack `lines` into chunks ≤ 3000 chars and send them as separate
|
||||||
|
messages, prefixing with `(N/M)` only when more than one chunk."""
|
||||||
chunks = self._chunk_lines(lines)
|
chunks = self._chunk_lines(lines)
|
||||||
total = len(chunks)
|
total = len(chunks)
|
||||||
for idx, chunk in enumerate(chunks, 1):
|
for idx, chunk in enumerate(chunks, 1):
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue