Files
keyhunter/.planning/phases/17-telegram-scheduler/17-03-SUMMARY.md
salvacybersec f49bf57942 docs(17-03): complete bot command handlers plan
- SUMMARY.md with implementation details and self-check passed
- STATE.md updated with progress, metrics, decisions
- Requirements TELE-01, TELE-02, TELE-03, TELE-04, TELE-06 marked complete
2026-04-06 17:36:39 +03:00

2.8 KiB

phase, plan, subsystem, tags, dependency_graph, tech_stack, key_files, decisions, metrics
phase plan subsystem tags dependency_graph tech_stack key_files decisions metrics
17 03 telegram-bot
telegram
bot
commands
telego
requires provides affects
engine
verifier
recon-engine
storage
providers
bot-command-handlers
serve-command
added patterns
github.com/mymmrac/telego@v1.8.0
telegohandler-command-predicates
context-based-handlers
created modified
pkg/bot/bot.go
pkg/bot/handlers.go
pkg/bot/source.go
pkg/bot/handlers_test.go
go.mod
go.sum
Handler signature uses telego Context (implements context.Context) for cancellation propagation
/key command enforced private-chat-only via chat.Type check; all other commands use masked keys only
Bot wraps existing engine/verifier/recon/storage/registry via Deps struct injection
duration completed
5min 2026-04-06

Phase 17 Plan 03: Bot Command Handlers Summary

Telegram bot command handlers for 8 commands using telego v1.8.0, wrapping existing scan/verify/recon/storage functionality.

Tasks Completed

Task Name Commit Files
1+2 Bot package + 8 command handlers 9ad5853 pkg/bot/bot.go, pkg/bot/handlers.go, pkg/bot/source.go, go.mod, go.sum
3 Unit tests for handlers 202473a pkg/bot/handlers_test.go

Implementation Details

Bot Package Structure

  • bot.go: Bot struct with Deps injection (engine, verifier, recon, storage, registry, encKey), RegisterHandlers method wiring telego BotHandler
  • handlers.go: 8 command handlers (/help, /scan, /verify, /recon, /status, /stats, /providers, /key) plus extractArg and storageToEngine helpers
  • source.go: selectBotSource for file/directory path resolution (subset of CLI source selection)

Command Security Model

  • /key <id>: Private chat only. Returns full unmasked key, refuses in group/supergroup chats
  • All other commands: Masked keys only. Never expose raw key material in group contexts
  • Scan results capped at 20 items with overflow indicator

Handler Registration

Commands registered via th.CommandEqual("name") predicates on the BotHandler. Each handler returns error but uses reply messages for user-facing errors rather than returning errors to telego.

Decisions Made

  1. Handler context: telego's *th.Context implements context.Context, used for timeout propagation in scan/recon operations
  2. /key private-only: Enforced via msg.Chat.Type == "private" check, returns denial message in groups
  3. Deps struct pattern: All dependencies injected via Deps struct to New() constructor, avoiding global state

Deviations from Plan

None - plan executed exactly as written.

Known Stubs

None. All 8 handlers are fully wired to real engine/verifier/recon/storage functionality.

Self-Check: PASSED