This commit is contained in:
@@ -6,11 +6,13 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
"valera/internal/db"
|
||||
"valera/internal/states"
|
||||
|
||||
tgbot "github.com/go-telegram-bot-api/telegram-bot-api"
|
||||
"golang.org/x/exp/slices"
|
||||
|
||||
"valera/internal/db"
|
||||
"valera/internal/modules/times"
|
||||
"valera/internal/states"
|
||||
)
|
||||
|
||||
var names = []string{
|
||||
@@ -44,7 +46,16 @@ func (s *weightBotState) Do(text string, chatInfo *db.ChatInfo) error {
|
||||
log.Println(err)
|
||||
return nil
|
||||
}
|
||||
_, _ = s.bot.Send(tgbot.NewMessage(chatInfo.ChatID, fmt.Sprintf("%vкг, записал.", weight)))
|
||||
stat, err := s.dataBase.GetStatBetween(chatInfo.ChatID, times.GetStartDayMinus(1), times.GetStartDay())
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
return nil
|
||||
}
|
||||
dWeight := 0.0
|
||||
if stat["Вес кг"] != 0 {
|
||||
dWeight = weight - stat["Вес кг"]
|
||||
}
|
||||
_, _ = s.bot.Send(tgbot.NewMessage(chatInfo.ChatID, fmt.Sprintf("%vкг, записал.\nИзменение веса: %vкг", weight, dWeight)))
|
||||
return s.dataBase.SetStatusToChat(chatInfo.ChatID, db.UserStateNone)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user