Compare commits
No commits in common. "922e770405d2cdd4d7410d37788e2132a41d3448" and "f066e01d21faa908ada387541f7b68c7896bcbb6" have entirely different histories.
922e770405
...
f066e01d21
53
main.go
53
main.go
|
@ -15,15 +15,8 @@ import (
|
|||
"valera/db"
|
||||
)
|
||||
|
||||
var (
|
||||
workoutTypes = []string{
|
||||
"Отжимания",
|
||||
"Пресс",
|
||||
}
|
||||
)
|
||||
|
||||
const (
|
||||
version = "v1.4.0"
|
||||
version = "v1.3.0"
|
||||
)
|
||||
|
||||
type Opts struct {
|
||||
|
@ -159,16 +152,14 @@ func run() {
|
|||
log.Println(err)
|
||||
continue
|
||||
}
|
||||
|
||||
isWorkout := false
|
||||
for _, workoutType := range workoutTypes {
|
||||
if userInfoDTO.GetStatus() == db.UserState(workoutType) {
|
||||
switch userInfoDTO.GetStatus() {
|
||||
case db.UserStateGo:
|
||||
count, err := strconv.Atoi(text)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
continue
|
||||
}
|
||||
if err := dataBase.AddWorkout(chatID, db.NewWorkout(workoutType, count, username)); err != nil {
|
||||
if err := dataBase.AddWorkout(chatID, db.NewWorkout("Отжимания", count, username)); err != nil {
|
||||
log.Println(err)
|
||||
continue
|
||||
}
|
||||
|
@ -176,26 +167,12 @@ func run() {
|
|||
if count <= 0 {
|
||||
msgText = "Плохо, хочешь быть толстым и не красивым?"
|
||||
}
|
||||
_, _ = bot.Send(tgbot.NewMessage(chatID, msgText))
|
||||
msg := tgbot.NewMessage(chatID, msgText)
|
||||
msg.ReplyMarkup = tgbot.NewRemoveKeyboard(false)
|
||||
_, _ = bot.Send(msg)
|
||||
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)
|
||||
|
@ -247,12 +224,16 @@ func run() {
|
|||
}
|
||||
|
||||
func sendGoToChat(bot *tgbot.BotAPI, dataBase *db.DB, chatID int64) {
|
||||
msg := tgbot.NewMessage(chatID, "Давай немного разомнемся, выбирай:")
|
||||
row := tgbot.NewKeyboardButtonRow()
|
||||
for _, workoutType := range workoutTypes {
|
||||
row = append(row, tgbot.NewKeyboardButton(workoutType))
|
||||
}
|
||||
msg.ReplyMarkup = tgbot.NewReplyKeyboard(row)
|
||||
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"),
|
||||
),
|
||||
)
|
||||
if _, err := bot.Send(msg); err == nil {
|
||||
if err := dataBase.SetStatusToChat(chatID, db.UserStateGo); err != nil {
|
||||
log.Println(err)
|
||||
|
|
Loading…
Reference in New Issue