feat: add inline keyboard, /start command, and callback handlers

- Show main menu with Clock In/Out, Report, Export, Remote, Day Off buttons
- Each action result includes a 'Back to Menu' button
- Handle callback queries alongside text commands
- Delete stale webhook before switching to polling
- Log i18n initialization error instead of silently ignoring it
This commit is contained in:
2026-06-23 21:42:52 +03:30
parent 0be03f7078
commit 4a5778afe5
3 changed files with 254 additions and 59 deletions

View File

@@ -33,7 +33,10 @@ func main() {
log.Fatal(err)
}
translator, _ := i18n.NewTranslator("en")
translator, err := i18n.NewTranslator("en")
if err != nil {
log.Fatal("i18n: ", err)
}
handler := bot.NewHandler(botAPI, dbStore, translator)
@@ -41,7 +44,10 @@ func main() {
if webhookURL != "" {
startWebhook(botAPI, handler, webhookURL)
} else {
// Fallback to longpolling
// Fallback to longpolling — remove any stale webhook first
if _, err := botAPI.Request(tgbotapi.DeleteWebhookConfig{}); err != nil {
log.Printf("DeleteWebhook: %v", err)
}
u := tgbotapi.NewUpdate(0)
u.Timeout = 30
updates := botAPI.GetUpdatesChan(u)
@@ -49,6 +55,9 @@ func main() {
if update.Message != nil {
handler.HandleMessage(update)
}
if update.CallbackQuery != nil {
handler.HandleCallback(update)
}
}
}
}