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:
@@ -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 long‑polling
|
||||
// Fallback to long‑polling — 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user