add db
continuous-integration/drone/push Build is passing

This commit is contained in:
2023-03-11 17:17:30 +07:00
parent 954263fc0d
commit b6b017c9bb
5 changed files with 201 additions and 5 deletions
+15 -4
View File
@@ -8,14 +8,16 @@ import (
"io/ioutil"
"log"
"os"
"strconv"
"strings"
"valera/commands"
"valera/db"
)
const (
version = "v0.1.1"
version = "v1.0.0"
userStateNone = userState("None")
userStateGo = userState("Go")
userStateGo = userState("Go")
)
var (
@@ -89,7 +91,16 @@ func run() {
// username := update.Message.From.UserName
if state == userStateGo {
_, _ = bot.Send(tgbot.NewMessage(chatID, text))
count, err := strconv.Atoi(text)
if err != nil {
continue
}
if err := db.AddWorkoutInUser(chatID, db.NewWorkout("Отжимания", count)); err != nil {
continue
}
msg := tgbot.NewMessage(chatID, fmt.Sprintf("Отлично, %s, записал.", text))
msg.ReplyMarkup = tgbot.NewHideKeyboard(false)
_, _ = bot.Send(msg)
state = userStateNone
continue
}
@@ -103,7 +114,7 @@ func run() {
case commands.Ping:
_, _ = bot.Send(tgbot.NewMessage(chatID, "pong"))
case commands.Go:
msg := tgbot.NewMessage(chatID, "Давай немного разомнемся, отжимания")
msg := tgbot.NewMessage(chatID, "Давай немного разомнемся, отжимания, отпишись сколько раз ты выполнил упражнение")
msg.ReplyMarkup = tgbot.NewReplyKeyboard(
tgbot.NewKeyboardButtonRow(
tgbot.NewKeyboardButton("1"),