Skip to content

feat: send periodic flood adverts at a configurable interval - #15

Merged
sg merged 1 commit into
mainfrom
feat/advert-interval
Jun 14, 2026
Merged

sg merged 1 commit into
mainfrom
feat/advert-interval

Conversation

@sg

@sg sg commented Jun 14, 2026

Copy link
Copy Markdown
Owner

Summary

Adds a periodic flood-advert feature: the bot sends a flood advertisement every N hours (0 = disabled). The interval is seeded from mcbot.conf on first run, then stored in the database (bot_meta) and managed at runtime — changes persist across restarts and take effect within ~60s without a restart. Settable via !adm advert interval <hours> and the web Manage→Radio screen.

Behavior

  • !adm advert interval 3 → flood advert every 3 hours; !adm advert interval 0 disables; bare !adm advert interval shows the current value.
  • The first periodic advert is one full interval out (setting it won't trigger an immediate flood while tuning).
  • Any flood advert (manual !adm advert flood, web button, or periodic) resets the clock, so the guarantee is "≥ N hours between flood adverts."

Changes

  • mcbot.py — Config.advert_interval_hours ([bot], default 0) + parse; MCBot state, _load_advert_interval() (DB-authoritative, seeds from config when the key is absent), set_advert_interval() (memory + DB, resets schedule), send_advert() anchors the schedule on flood, and a periodic_advert task (60s poll, registered for shutdown).
  • management.py — radio_advert_interval() (read) + radio_set_advert_interval() (validate 0–168h, persist, audit radio.advert_interval).
  • commands/adm.py — !adm advert interval <hours> subcommand + help text.
  • webapi/routers/dbadmin.py — GET/POST /api/radio/advert-interval.
  • web-ui/src/views/Manage.vue — interval input + Apply in the Radio Advert section, auto-loaded on tab open; static assets rebuilt.
  • mcbot.conf.example — documents advert_interval_hours as the first-run seed.
  • tests/test_advert_interval.py — seed-from-config, DB-authoritative-over-config, set-persists/reset, mgmt validation + audit, flood-advert anchoring.

Testing

tests/test_advert_interval.py passes; existing suites (logging, repeat-tracking, eviction, decode-advert) still pass; py_compile clean; npm run build clean.

@sg
sg merged commit 624f725 into main Jun 14, 2026
1 check passed
@sg
sg deleted the feat/advert-interval branch June 14, 2026 02:53
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