Compare commits

..

2 Commits

Author SHA1 Message Date
Владимир Фёдоров 922e770405 add press
continuous-integration/drone/push Build is passing Details
2023-03-13 02:54:25 +07:00
Владимир Фёдоров 695ecef4fd add press 2023-03-13 02:54:19 +07:00
1 changed files with 45 additions and 26 deletions

53
main.go
View File

@ -15,8 +15,15 @@ import (
"valera/db"
)
var (
workoutTypes = []string{
"Отжимания",
"Пресс",
}
)
const (
version = "v1.3.0"
version = "v1.4.0"
)
type Opts struct {
@ -152,14 +159,16 @@ func run() {
log.Println(err)
continue
}
switch userInfoDTO.GetStatus() {
case db.UserStateGo:
isWorkout := false
for _, workoutType := range workoutTypes {
if userInfoDTO.GetStatus() == db.UserState(workoutType) {
count, err := strconv.Atoi(text)
if err != nil {
log.Println(err)
continue
}
if err := dataBase.AddWorkout(chatID, db.NewWorkout("Отжимания", count, username)); err != nil {
if err := dataBase.AddWorkout(chatID, db.NewWorkout(workoutType, count, username)); err != nil {
log.Println(err)
continue
}
@ -167,12 +176,26 @@ func run() {
if count <= 0 {
msgText = "Плохо, хочешь быть толстым и не красивым?"
}
msg := tgbot.NewMessage(chatID, msgText)
msg.ReplyMarkup = tgbot.NewRemoveKeyboard(false)
_, _ = bot.Send(msg)
_, _ = bot.Send(tgbot.NewMessage(chatID, msgText))
if err := dataBase.SetStatusToChat(chatID, db.UserStateNone); err != nil {
log.Println(err)
}
isWorkout = true
break
}
}
if isWorkout {
continue
}
switch userInfoDTO.GetStatus() {
case db.UserStateGo:
if err := dataBase.SetStatusToChat(chatID, db.UserState(text)); err != nil {
log.Println(err)
}
msg := tgbot.NewMessage(chatID, fmt.Sprintf("%s, отпишись сколько раз ты выполнил упражнение", text))
msg.ReplyMarkup = tgbot.NewRemoveKeyboard(false)
_, _ = bot.Send(msg)
continue
case db.UserStateEat:
count, err := strconv.Atoi(text)
@ -224,16 +247,12 @@ func run() {
}
func sendGoToChat(bot *tgbot.BotAPI, dataBase *db.DB, chatID int64) {
msg := tgbot.NewMessage(chatID, "Давай немного разомнемся, отжимания, отпишись сколько раз ты выполнил упражнение")
msg.ReplyMarkup = tgbot.NewReplyKeyboard(
tgbot.NewKeyboardButtonRow(
tgbot.NewKeyboardButton("1"),
tgbot.NewKeyboardButton("2"),
tgbot.NewKeyboardButton("3"),
tgbot.NewKeyboardButton("5"),
tgbot.NewKeyboardButton("8"),
),
)
msg := tgbot.NewMessage(chatID, "Давай немного разомнемся, выбирай:")
row := tgbot.NewKeyboardButtonRow()
for _, workoutType := range workoutTypes {
row = append(row, tgbot.NewKeyboardButton(workoutType))
}
msg.ReplyMarkup = tgbot.NewReplyKeyboard(row)
if _, err := bot.Send(msg); err == nil {
if err := dataBase.SetStatusToChat(chatID, db.UserStateGo); err != nil {
log.Println(err)