This commit is contained in:
@@ -2,11 +2,12 @@ package clear_bot_state
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"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/states"
|
||||
)
|
||||
|
||||
var names = []string{
|
||||
|
||||
@@ -4,12 +4,13 @@ import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"valera/internal/db"
|
||||
"valera/internal/modules/times"
|
||||
"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{
|
||||
@@ -39,7 +40,7 @@ func (s *eatBotState) Do(text string, chatInfo *db.ChatInfo) error {
|
||||
log.Println(err)
|
||||
return nil
|
||||
}
|
||||
stat, err := s.dataBase.GetStatAfter(chatInfo.ChatID, times.GetStartDay())
|
||||
stat, err := s.dataBase.GetStatBetween(chatInfo.ChatID, times.GetStartDay(), times.GetNow())
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
return nil
|
||||
|
||||
@@ -4,13 +4,13 @@ import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"time"
|
||||
"valera/internal/db"
|
||||
"valera/internal/states"
|
||||
|
||||
"valera/internal/modules/times"
|
||||
|
||||
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{
|
||||
@@ -81,7 +81,7 @@ func (s *statBotState) GetHandler() (string, func(http.ResponseWriter, *http.Req
|
||||
|
||||
func (s *statBotState) sendStatToChatAfter(chatID int64, prefix string, t time.Time) error {
|
||||
msgText := prefix
|
||||
stat, err := s.dataBase.GetStatAfter(chatID, t)
|
||||
stat, err := s.dataBase.GetStatBetween(chatID, t, times.GetNow())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -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