- Fix 'string(d)' int-to-rune conversion in rpg_test.go by using fmt.Sprintf - Fix ComputeDailyTotals dayStart logic: initial state should be StateWorking when dayStart > 0, correctly counting work from dayStart to first out event - Update README project structure to reflect new domain/handler/repo layout - Implement missing achievements: rpg_pioneer (on RPG enable) and salary_setter (on first rate set) - Add tryUnlockAchievement helper to Handler
112 lines
3.5 KiB
Go
112 lines
3.5 KiB
Go
package handler
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/go-telegram/bot/models"
|
|
)
|
|
|
|
func mainKeyboard() models.InlineKeyboardMarkup {
|
|
return 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: "History", CallbackData: "history"},
|
|
},
|
|
{
|
|
{Text: "RPG", CallbackData: "rpg"},
|
|
{Text: "League", CallbackData: "league"},
|
|
{Text: "Burnout", CallbackData: "burnout"},
|
|
},
|
|
{
|
|
{Text: "Salary", CallbackData: "salary"},
|
|
{Text: "Settings", CallbackData: "settings"},
|
|
},
|
|
},
|
|
}
|
|
}
|
|
|
|
func backKeyboard() models.InlineKeyboardMarkup {
|
|
return models.InlineKeyboardMarkup{
|
|
InlineKeyboard: [][]models.InlineKeyboardButton{
|
|
{{Text: "Back to Menu", CallbackData: "back_menu"}},
|
|
},
|
|
}
|
|
}
|
|
|
|
func settingsBackKeyboard() models.InlineKeyboardMarkup {
|
|
return models.InlineKeyboardMarkup{
|
|
InlineKeyboard: [][]models.InlineKeyboardButton{
|
|
{{Text: "Back to Settings", CallbackData: "back_settings"}},
|
|
},
|
|
}
|
|
}
|
|
|
|
// buildYearPicker returns a 12-year grid keyboard centered on centerYear.
|
|
func buildYearPicker(cbPrefix, backData, navSuffix string, centerYear int) models.InlineKeyboardMarkup {
|
|
blockStart := centerYear - 6
|
|
kbRows := [][]models.InlineKeyboardButton{
|
|
{
|
|
{Text: "<", CallbackData: fmt.Sprintf("%syears_%d%s", cbPrefix, blockStart-12, navSuffix)},
|
|
{Text: fmt.Sprintf("%d", centerYear), CallbackData: "noop"},
|
|
{Text: ">", CallbackData: fmt.Sprintf("%syears_%d%s", cbPrefix, blockStart+12, navSuffix)},
|
|
},
|
|
}
|
|
for i := 0; i < 12; i += 4 {
|
|
row := []models.InlineKeyboardButton{}
|
|
for j := i; j < i+4; j++ {
|
|
y := blockStart + j
|
|
row = append(row, models.InlineKeyboardButton{
|
|
Text: fmt.Sprintf("%d", y), CallbackData: fmt.Sprintf("%syear_%d", cbPrefix, y),
|
|
})
|
|
}
|
|
kbRows = append(kbRows, row)
|
|
}
|
|
if backData != "" {
|
|
kbRows = append(kbRows, []models.InlineKeyboardButton{
|
|
{Text: "Back", CallbackData: backData},
|
|
})
|
|
}
|
|
return models.InlineKeyboardMarkup{InlineKeyboard: kbRows}
|
|
}
|
|
|
|
// buildHourPickerKeyboard creates the 24-hour grid for time selection.
|
|
func buildHourPickerKeyboard(cb func(int) string, backData string) models.InlineKeyboardMarkup {
|
|
kbRows := [][]models.InlineKeyboardButton{}
|
|
hourRow := []models.InlineKeyboardButton{}
|
|
for hh := 0; hh < 24; hh++ {
|
|
hourRow = append(hourRow, models.InlineKeyboardButton{
|
|
Text: fmt.Sprintf("%02d", hh), CallbackData: cb(hh),
|
|
})
|
|
if len(hourRow) == 6 || hh == 23 {
|
|
kbRows = append(kbRows, hourRow)
|
|
hourRow = nil
|
|
}
|
|
}
|
|
kbRows = append(kbRows, []models.InlineKeyboardButton{{Text: "Back", CallbackData: backData}})
|
|
return models.InlineKeyboardMarkup{InlineKeyboard: kbRows}
|
|
}
|
|
|
|
// buildMinutePickerKeyboard creates the 15-min interval row for minute selection.
|
|
func buildMinutePickerKeyboard(cb func(int) string, backData string) models.InlineKeyboardMarkup {
|
|
kbRows := [][]models.InlineKeyboardButton{}
|
|
minRow := []models.InlineKeyboardButton{}
|
|
for _, mm := range []int{0, 10, 20, 30, 40, 50} {
|
|
minRow = append(minRow, models.InlineKeyboardButton{
|
|
Text: fmt.Sprintf("%02d", mm), CallbackData: cb(mm),
|
|
})
|
|
}
|
|
kbRows = append(kbRows, minRow)
|
|
kbRows = append(kbRows, []models.InlineKeyboardButton{{Text: "Back", CallbackData: backData}})
|
|
return models.InlineKeyboardMarkup{InlineKeyboard: kbRows}
|
|
}
|