From a96419f324d7ba7884e0a33b5cc0568e1d99df93 Mon Sep 17 00:00:00 2001 From: db123 Date: Thu, 25 Jun 2026 09:55:53 +0330 Subject: [PATCH] feat: add /settings command and document /history for UI-command parity - Add /settings command handler with inline settings keyboard - Add /history to README commands table - Update /help command list - Remove unused Leagu.go old reference --- README.md | 2 ++ internal/handler/handler.go | 2 ++ internal/handler/settings.go | 12 ++++++++++++ 3 files changed, 16 insertions(+) diff --git a/README.md b/README.md index abeb359..ff740d6 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,7 @@ Categorize your work sessions (e.g., Remote, Onsite, Meeting). The current work | Command | Action | | --------------------------- | ----------------------------------------------------------- | | `/start` | Show inline menu | +| `/settings` | Open settings menu | | `/clockin` | Record clock-in | | `/clockout` | Record clock-out | | `/worktype` | Change current work type | @@ -101,6 +102,7 @@ Categorize your work sessions (e.g., Remote, Onsite, Meeting). The current work | `/dayoff` | Toggle today as day off | | `/export [YYYY-MM]` | Export monthly report (optional `YYYY-MM` in your calendar) | | `/summary [YYYY-MM]` | Show monthly summary (optional `YYYY-MM`) | +| `/history` | View calendar history (inline menu also) | | `/edit YYYY-MM-DD` | View/edit events for a specific date | | `/note [DATE] HH:MM ` | Set note for an event at a specific time | | `/settimezone ` | Set timezone (e.g. `Asia/Tehran`) | diff --git a/internal/handler/handler.go b/internal/handler/handler.go index 2ec94cf..cedb89c 100644 --- a/internal/handler/handler.go +++ b/internal/handler/handler.go @@ -148,6 +148,8 @@ func (h *Handler) routeCommand(ctx context.Context, msg *models.Message, user *d switch cmd { case "/start": h.handleStart(ctx, msg, user) + case "/settings": + h.handleSettings(ctx, msg, user) case "/help": h.handleHelp(ctx, msg) case "/clockin": diff --git a/internal/handler/settings.go b/internal/handler/settings.go index 1f19708..53377e0 100644 --- a/internal/handler/settings.go +++ b/internal/handler/settings.go @@ -21,9 +21,21 @@ func (h *Handler) handleStart(ctx context.Context, msg *models.Message, user *do h.sendWithKB(ctx, msg.Chat.ID, h.buildStatusText(user), kb) } +func (h *Handler) handleSettings(ctx context.Context, msg *models.Message, user *domain.User) { + st, err := h.Repo.GetOrCreateSettings(user.ID) + if err != nil { + h.sendText(ctx, msg.Chat.ID, "Error loading settings") + return + } + bt := h.getTodayBreakThreshold(user) + text, kb := h.buildSettingsKeyboard(user, st, bt) + h.sendWithKB(ctx, msg.Chat.ID, text, kb) +} + func (h *Handler) handleHelp(ctx context.Context, msg *models.Message) { text := `Commands: /start - Show main menu +/settings - Open settings /clockin - Clock in /clockout - Clock out /worktype - Select work type