feat: show Anonymous in league when name empty, add username to settings, show salary hint in summary
This commit is contained in:
@@ -298,6 +298,8 @@ func (h *Handler) HandleCallback(ctx context.Context, cb *models.CallbackQuery)
|
||||
h.leagueToggleCallback(ctx, chatID, msgID, cb.ID)
|
||||
case "reporttoggle":
|
||||
h.reportToggleCallback(ctx, chatID, msgID, cb.ID)
|
||||
case "username":
|
||||
h.usernameCallback(ctx, chatID, msgID, cb.ID)
|
||||
case "currency":
|
||||
h.currencyCallback(ctx, chatID, msgID, cb.ID)
|
||||
case "setrate":
|
||||
|
||||
@@ -40,6 +40,9 @@ func (h *Handler) buildLeagueText(orderBy LeagueSortOption) string {
|
||||
for i, e := range entries {
|
||||
rank := i + 1
|
||||
name := e.Username
|
||||
if name == "" {
|
||||
name = "Anonymous"
|
||||
}
|
||||
b.WriteString(fmt.Sprintf("%d %s\n", rank, name))
|
||||
b.WriteString(fmt.Sprintf(" XP:%d Lv:%d S:%d %.1fh\n", e.XP, e.Level, e.Streak, e.TotalHours))
|
||||
}
|
||||
|
||||
@@ -209,7 +209,10 @@ func (h *Handler) buildSettingsKeyboard(user *db.User, st *db.UserSettings, brea
|
||||
{Text: fmt.Sprintf("League: %s", leagueStatus), CallbackData: "leaguetoggle"},
|
||||
},
|
||||
{
|
||||
{Text: fmt.Sprintf("Username: %s", user.Username), CallbackData: "username"},
|
||||
{Text: fmt.Sprintf("Currency: %s", st.Currency), CallbackData: "currency"},
|
||||
},
|
||||
{
|
||||
{Text: fmt.Sprintf("Rate: %.2f", st.HourlyRate), CallbackData: "setrate"},
|
||||
},
|
||||
{{Text: "Back to Menu", CallbackData: "back_menu"}},
|
||||
@@ -217,6 +220,22 @@ func (h *Handler) buildSettingsKeyboard(user *db.User, st *db.UserSettings, brea
|
||||
return "Settings:", models.InlineKeyboardMarkup{InlineKeyboard: rows}
|
||||
}
|
||||
|
||||
// usernameCallback shows the current username and how to change it.
|
||||
func (h *Handler) usernameCallback(ctx context.Context, chatID int64, msgID int, callbackID string) {
|
||||
defer h.answerCb(ctx, callbackID)
|
||||
user, err := h.getOrCreateUser(chatID)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
text := fmt.Sprintf("Username: %s\n\nUse /setusername <name> to change it.", user.Username)
|
||||
kb := models.InlineKeyboardMarkup{
|
||||
InlineKeyboard: [][]models.InlineKeyboardButton{
|
||||
{{Text: "Back to Settings", CallbackData: "back_settings"}},
|
||||
},
|
||||
}
|
||||
h.editText(ctx, chatID, msgID, text, &kb)
|
||||
}
|
||||
|
||||
// accentCallback shows the accent color picker (inline edit).
|
||||
func (h *Handler) accentCallback(ctx context.Context, chatID int64, msgID int, callbackID string) {
|
||||
defer h.answerCb(ctx, callbackID)
|
||||
|
||||
@@ -114,6 +114,8 @@ func (h *Handler) buildMonthlySummary(user *db.User, calY, calM int, startStr, e
|
||||
est := computeMonthlySalary(days, h.DB, user.ID, st.HourlyRate, loc)
|
||||
b.WriteString(fmt.Sprintf("\nSalary: %s (%.1f hours, %d days)",
|
||||
est.formatSalary(st.Currency), est.WorkHours, est.WorkDays))
|
||||
} else {
|
||||
b.WriteString("\nSalary: No rate configured — use /setrate <amount>")
|
||||
}
|
||||
|
||||
b.WriteString("\n\nDetails:\n")
|
||||
|
||||
Reference in New Issue
Block a user