Commit Graph

5 Commits

Author SHA1 Message Date
Kamil 'Kamaś' Bruchal 5a10eda3e1 fix: only answer unknown /commands, not ordinary messages
The default handler fired for every update the command matchers didn't
claim, so plain chatter, service messages, media, and replies to the bot
all drew a "Nieznana komenda" response — spammy in group chats. Gate the
fallback on a leading bot_command entity so only real (unrecognized)
commands get the help reply.
2026-06-22 19:58:13 +02:00
Kamil 'Kamaś' Bruchal 41980e4f6f test: cover Telegram command handlers via httptest bot
Add tests for the previously-untested handlers (ktoSprzata, sync, unknown,
matchCommand, BotSendFunc, PublishCommands) using a real *bot.Bot pointed at
an httptest server that captures sendMessage replies. Covers the /sync
success, throttled, and failure paths plus the non-message fallback.
2026-06-19 19:04:04 +02:00
Kamil 'Kamaś' Bruchal 825331dce5 fix: match bot commands addressed with @botusername in groups
In group chats Telegram appends the bot addressee to the bot_command
entity (/sync@hs_dyzur_bot), and the library's MatchTypeCommand compares
the whole token verbatim, so commands never matched. Replace it with
custom MatchFuncs that read the bot_command entity span and strip any
@suffix before comparing the command name.
2026-06-19 02:48:29 +02:00
Kamil 'Kamaś' Bruchal 4f9cc6c359 feat: harden rota sync and throttle manual /sync
Resolve the current-year sheet tab per fetch instead of freezing it at
startup, so a long-running process follows the New Year rollover without a
restart. Guard against the regression this introduces: a successful fetch
that returns no duty weeks (e.g. a freshly created, empty next-year tab) now
keeps the last-good cache instead of clobbering it with empty data.

Surface a silently-stale cache — which is not a crash, so process-level
supervision can't catch it — by escalating to a loud error log once no sync
has succeeded for 6h (new Store.LastSynced accessor backs the check).

Throttle manual /sync to once per minute across the chat to avoid spamming
the Google Sheets API; the check-and-set is mutex-guarded since Telegram
dispatches each update in its own goroutine.

Update README accordingly.
2026-06-19 02:05:04 +02:00
Kamil 'Kamaś' Bruchal 74cb302f64 chore: track go.mod, go.sum, and missing test files
These were never committed (hidden by status.showUntrackedFiles=no): without
go.mod/go.sum a fresh clone would not build, and the source files committed in
abb38e3 were missing their accompanying tests.
2026-06-18 21:40:41 +02:00