@@ -26,7 +26,7 @@ func NewClearBotState(bot *tgbot.BotAPI, dataBase *db.DB) states.BotState {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *clearBotState) Do(text string, chatInfo *db.ChatInfo, username string) error {
|
||||
func (s *clearBotState) Do(text string, chatInfo *db.ChatInfo) error {
|
||||
if !slices.Contains(names, text) {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -27,14 +27,14 @@ func NewEatBotState(bot *tgbot.BotAPI, dataBase *db.DB) states.BotState {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *eatBotState) Do(text string, chatInfo *db.ChatInfo, username string) error {
|
||||
func (s *eatBotState) Do(text string, chatInfo *db.ChatInfo) error {
|
||||
if chatInfo.Status == string(db.UserStateEat) {
|
||||
count, err := calcCalories(text)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
return nil
|
||||
}
|
||||
if err := s.dataBase.AddCalories(chatInfo.ChatID, db.NewCalories(count, username)); err != nil {
|
||||
if err := s.dataBase.AddCalories(chatInfo.ChatID, db.NewCalories(count, chatInfo.Username)); err != nil {
|
||||
log.Println(err)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ func NewGoBotState(bot *tgbot.BotAPI, dataBase *db.DB) states.BotState {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *goBotState) Do(text string, chatInfo *db.ChatInfo, username string) error {
|
||||
func (s *goBotState) Do(text string, chatInfo *db.ChatInfo) error {
|
||||
if chatInfo.Status == string(db.UserStateGo) {
|
||||
if err := s.dataBase.SetStatusToChat(chatInfo.ChatID, db.UserState(text)); err != nil {
|
||||
log.Println(err)
|
||||
@@ -57,7 +57,7 @@ func (s *goBotState) Do(text string, chatInfo *db.ChatInfo, username string) err
|
||||
log.Println(err)
|
||||
continue
|
||||
}
|
||||
if err := s.dataBase.AddWorkout(chatInfo.ChatID, db.NewWorkout(workoutType, count, username)); err != nil {
|
||||
if err := s.dataBase.AddWorkout(chatInfo.ChatID, db.NewWorkout(workoutType, count, chatInfo.Username)); err != nil {
|
||||
log.Println(err)
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ func NewHelpBotState(bot *tgbot.BotAPI, dataBase *db.DB) states.BotState {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *helpBotState) Do(text string, chatInfo *db.ChatInfo, username string) error {
|
||||
func (s *helpBotState) Do(text string, chatInfo *db.ChatInfo) error {
|
||||
if !slices.Contains(names, text) {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -6,6 +6,6 @@ import (
|
||||
)
|
||||
|
||||
type BotState interface {
|
||||
Do(text string, chatInfo *db.ChatInfo, username string) error
|
||||
Do(text string, chatInfo *db.ChatInfo) error
|
||||
GetHandler() (string, func(http.ResponseWriter, *http.Request))
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ func NewPauseBotState(bot *tgbot.BotAPI, dataBase *db.DB) states.BotState {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *pauseBotState) Do(text string, chatInfo *db.ChatInfo, username string) error {
|
||||
func (s *pauseBotState) Do(text string, chatInfo *db.ChatInfo) error {
|
||||
if chatInfo.Status == string(db.UserStatePause) {
|
||||
duration, err := getDuration(text)
|
||||
if err != nil {
|
||||
|
||||
@@ -25,7 +25,7 @@ func NewPingBotState(bot *tgbot.BotAPI, dataBase *db.DB) states.BotState {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *pingBotState) Do(text string, chatInfo *db.ChatInfo, username string) error {
|
||||
func (s *pingBotState) Do(text string, chatInfo *db.ChatInfo) error {
|
||||
if !slices.Contains(names, text) {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ func NewStartBotState(bot *tgbot.BotAPI, dataBase *db.DB, version string) states
|
||||
}
|
||||
}
|
||||
|
||||
func (s *startBotState) Do(text string, chatInfo *db.ChatInfo, username string) error {
|
||||
func (s *startBotState) Do(text string, chatInfo *db.ChatInfo) error {
|
||||
if !slices.Contains(names, text) {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ func NewStatBotState(bot *tgbot.BotAPI, dataBase *db.DB) states.BotState {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *statBotState) Do(text string, chatInfo *db.ChatInfo, username string) error {
|
||||
func (s *statBotState) Do(text string, chatInfo *db.ChatInfo) error {
|
||||
if !slices.Contains(names, text) {
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user