Skip to content

Roundup scheduler rebuild + role mention + render fixes#109

Merged
retardgerman merged 13 commits into
devfrom
feature/roundup-scheduler-rebuild
May 3, 2026
Merged

Roundup scheduler rebuild + role mention + render fixes#109
retardgerman merged 13 commits into
devfrom
feature/roundup-scheduler-rebuild

Conversation

@retardgerman
Copy link
Copy Markdown
Contributor

Summary

Rebuild of the Weekly Roundup scheduler addressing v1.5.5 beta feedback (scheduler did not trigger even with TZ set; no observability into why). Also bundles the open render fixes and the optional role-mention feature request.

Scheduler

  • New bot/roundupScheduler.js owns the hourly tick loop and exposes evaluateTick(now) which returns { action: "post" | "skip", reason } with explicit reasons (not-enabled, no-channel, wrong-weekday, before-target-hour, already-posted-this-week, circuit-open). Every tick is logged at info level — no more silent scheduler.
  • Ticks chain setTimeout(msUntilNextHour) so they re-align across DST instead of drifting on a fixed setInterval.
  • bot/weeklyRoundup.js is now post-rendering only; scheduler/idempotency/circuit-breaker live in their own modules.
  • bot/roundupState.js extended with lastPostedAt + per-week failure list (3 failures → circuit opens). Legacy WEEKLY_ROUNDUP_LAST_POSTED_AT is silently migrated on first boot, wrapped in try/catch so a corrupt state file cannot crash the bot.
  • TZ handling: scheduler reads host-local getDay()/getHours(). Set TZ=Europe/Berlin (or your zone) in docker-compose.yml — single source of truth, replaces the unreleased WEEKLY_ROUNDUP_TZ field that never reached the dashboard.
  • One-shot warn on boot if WEEKLY_ROUNDUP_ENABLED=true but no channel configured, or if WEEKLY_ROUNDUP_ROLE_ID is set but malformed.

Render fixes (beta feedback)

  • Markdown escape no longer escapes ( / )Hoppers (2026) rendered as Hoppers \(2026\) because parens aren't markdown control chars inside masked-link labels.
  • Per-show de-dup: when an episode-group aggregate exists, individual Season rows and the bare Series row are dropped. When only Season rows exist, the bare Series row is dropped. One canonical representation per show.
  • Per-show season sort: rows for the same show are contiguous and ordered by season number ascending (bare-title sorts first), instead of arbitrary order driven by DateCreated.

Role mention

  • New optional config WEEKLY_ROUNDUP_ROLE_ID (dashboard field under Weekly Roundup). When set to a valid Discord role snowflake (17–20 digits), the post pings that role via <@&id> content + allowedMentions: { parse: ["roles"] } so it cannot escalate to @everyone. Skipped in test mode.

Documentation written with AI assistance; code changes verified manually.

Replace the Role-ID text input with a <select> populated from /api/discord-roles
when the bot is running. Keeps the same WEEKLY_ROUNDUP_ROLE_ID config field
(snowflake string), so server-side validation and the role-mention send path
are unchanged. Adds the missing config.weekly_roundup_role_{label,help,none}
keys to en/de/sv/template.
@retardgerman retardgerman merged commit 61c6ad1 into dev May 3, 2026
2 checks passed
@retardgerman retardgerman deleted the feature/roundup-scheduler-rebuild branch May 3, 2026 11:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant