fix: unsilence all error returns from SQL Exec, Bot API calls, and migrations
This commit is contained in:
@@ -7,7 +7,6 @@ import (
|
||||
"time"
|
||||
|
||||
bot "github.com/go-telegram/bot"
|
||||
"github.com/go-telegram/bot/models"
|
||||
|
||||
"worktimeBot/internal/db"
|
||||
)
|
||||
@@ -56,32 +55,9 @@ func (h *Handler) buildStatusText(chatID int64) string {
|
||||
|
||||
// backToMenu returns to the main menu from any sub-menu.
|
||||
func (h *Handler) backToMenu(ctx context.Context, chatID int64, msgID int, callbackID string) {
|
||||
defer h.Bot.AnswerCallbackQuery(ctx, &bot.AnswerCallbackQueryParams{CallbackQueryID: callbackID})
|
||||
text := h.buildStatusText(chatID)
|
||||
h.Bot.EditMessageText(ctx, &bot.EditMessageTextParams{
|
||||
ChatID: chatID,
|
||||
MessageID: msgID,
|
||||
Text: text,
|
||||
ReplyMarkup: &models.InlineKeyboardMarkup{
|
||||
InlineKeyboard: [][]models.InlineKeyboardButton{
|
||||
{
|
||||
{Text: "Clock In", CallbackData: "clockin"},
|
||||
{Text: "Clock Out", CallbackData: "clockout"},
|
||||
},
|
||||
{
|
||||
{Text: "Work Type", CallbackData: "worktype"},
|
||||
{Text: "Day Off", CallbackData: "dayoff"},
|
||||
},
|
||||
{
|
||||
{Text: "Report", CallbackData: "report"},
|
||||
{Text: "Export", CallbackData: "export"},
|
||||
},
|
||||
{
|
||||
{Text: "Settings", CallbackData: "settings"},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
defer h.answerCb(ctx, callbackID)
|
||||
kb := mainKeyboard()
|
||||
h.editText(ctx, chatID, msgID, h.buildStatusText(chatID), &kb)
|
||||
}
|
||||
|
||||
// buildDailyReport builds a formatted daily report string for a given user/day.
|
||||
@@ -164,6 +140,12 @@ func (h *Handler) SendDailyReport(ctx context.Context, userID int64, chatID int6
|
||||
return
|
||||
}
|
||||
text := h.buildDailyReport(user, day, events)
|
||||
h.Bot.SendMessage(ctx, &bot.SendMessageParams{ChatID: chatID, Text: text})
|
||||
h.DB.MarkReportSent(user.ID, today)
|
||||
_, err = h.Bot.SendMessage(ctx, &bot.SendMessageParams{ChatID: chatID, Text: text})
|
||||
if err != nil {
|
||||
slog.Error("daily report: send message failed", "chat_id", chatID, "error", err)
|
||||
return
|
||||
}
|
||||
if err := h.DB.MarkReportSent(user.ID, today); err != nil {
|
||||
slog.Error("daily report: mark sent failed", "chat_id", chatID, "error", err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user