package bot import "strings" type Command string const ( CommandStart Command = "start" CommandHelp Command = "help" CommandFund Command = "fund" CommandWithdraw Command = "withdraw" CommandConfirm Command = "confirm" CommandCancel Command = "cancel" ) var supportedCommands = []Command{ CommandStart, CommandHelp, CommandFund, CommandWithdraw, CommandConfirm, CommandCancel, } func (c Command) Slash() string { name := strings.TrimSpace(string(c)) if name == "" { return "" } return "/" + name } func parseCommand(text string) Command { text = strings.TrimSpace(text) if !strings.HasPrefix(text, "/") { return "" } token := text if idx := strings.IndexAny(token, " \t\n\r"); idx >= 0 { token = token[:idx] } token = strings.TrimPrefix(token, "/") if idx := strings.Index(token, "@"); idx >= 0 { token = token[:idx] } return Command(strings.ToLower(strings.TrimSpace(token))) } func supportedCommandsMessage() string { lines := make([]string, 0, len(supportedCommands)+1) lines = append(lines, "Supported commands:") for _, cmd := range supportedCommands { lines = append(lines, cmd.Slash()) } return strings.Join(lines, "\n") } func confirmationCommandsMessage() string { return "Confirm operation?\n\n" + CommandConfirm.Slash() + "\n" + CommandCancel.Slash() } func helpMessage(accountCode string, currency string) string { accountCode = strings.TrimSpace(accountCode) currency = strings.ToUpper(strings.TrimSpace(currency)) if accountCode == "" { accountCode = "N/A" } if currency == "" { currency = "N/A" } lines := []string{ "Treasury bot help", "", "Attached account: " + accountCode + " (" + currency + ")", "", "How to use:", "1) Start funding with " + CommandFund.Slash() + " or withdrawal with " + CommandWithdraw.Slash(), "2) Enter amount as decimal, dot separator, no currency (example: 1250.75)", "3) Confirm with " + CommandConfirm.Slash() + " or abort with " + CommandCancel.Slash(), "", "After confirmation there is a cooldown window. You can cancel during it with " + CommandCancel.Slash() + ".", "You will receive a follow-up message with execution success or failure.", } return strings.Join(lines, "\n") }