diff --git a/commands/command.go b/commands/command.go index 5c22c3b..55678a3 100644 --- a/commands/command.go +++ b/commands/command.go @@ -6,4 +6,5 @@ const ( Start = Command("/start") Help = Command("/help") Ping = Command("/ping") + Go = Command("/go") ) diff --git a/main.go b/main.go index 06db553..87b86cf 100644 --- a/main.go +++ b/main.go @@ -14,8 +14,16 @@ import ( const ( version = "v0.1.1" + userStateNone = userState("None") + userStateGo = userState("Go") ) +var ( + state = userStateNone +) + +type userState string + type Opts struct { Token string `short:"t" long:"token" description:"Telegram api token"` Name string `short:"n" long:"name" description:"Telegram bot name" default:"@body_weight_loss_bot"` @@ -78,16 +86,34 @@ func run() { text := update.Message.Text chatID := update.Message.Chat.ID -// username := update.Message.From.UserName + // username := update.Message.From.UserName + + if state == userStateGo { + _, _ = bot.Send(tgbot.NewMessage(chatID, text)) + state = userStateNone + continue + } command := commands.Command(strings.Replace(text, opts.Name, "", 1)) switch command { case commands.Start: _, _ = bot.Send(tgbot.NewMessage(chatID, fmt.Sprintf("Здорова, я Валера (%s), твой тренер (%d).", version, chatID))) case commands.Help: - _, _ = bot.Send(tgbot.NewMessage(chatID, "Вот что я умею:\n\n1) Ничего")) + _, _ = bot.Send(tgbot.NewMessage(chatID, "Вот что я умею:\n\n1) Предлагать размяться")) case commands.Ping: _, _ = bot.Send(tgbot.NewMessage(chatID, "pong")) + case commands.Go: + msg := tgbot.NewMessage(chatID, "Давай немного разомнемся, отжимания") + msg.ReplyMarkup = tgbot.NewReplyKeyboard( + tgbot.NewKeyboardButtonRow( + tgbot.NewKeyboardButton("1"), + tgbot.NewKeyboardButton("2"), + tgbot.NewKeyboardButton("3"), + ), + ) + if _, err = bot.Send(msg); err == nil { + state = userStateGo + } } } }