### Start Function Signature Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/tg-bot/logic-handlers Signature for the Start handler. ```go func (h *LogicHandlers) Start(b *gotgbot.Bot, ctx *ext.Context) error ``` -------------------------------- ### Run method Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/pkg/server The Run method starts the HTTP server and listens for incoming requests. ```go func (s *Server) Run() error ``` -------------------------------- ### Run method Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/tg-bot Run starts the bot's main loop. ```go func (b *Bot) Run() ``` -------------------------------- ### Get Function Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/config Function to retrieve the global configuration instance. ```go func Get() *Config ``` -------------------------------- ### Get Function Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/store Get executes a query to retrieve a single record. ```Go func Get(ctx context.Context, db Querier, dst interface{}, query string, args ...interface{}) error ``` -------------------------------- ### Callback keys for getting diet from AI Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/tg-bot/logic-handlers Defines specific callback keys used in the process of getting diet recommendations from AI, including meal and snack selections and order product confirmations. ```Go const ( GetDietFromAICbSelectMeals2 = "select_meals_2" GetDietFromAICbSelectMeals3 = "select_meals_3" GetDietFromAICbSelectSnacks0 = "select_snacks_0" GetDietFromAICbSelectSnacks1 = "select_snacks_1" GetDietFromAICbSelectSnacks2 = "select_snacks_2" GetDietFromAISelectOrderProductsYes = "select_order_products_y" GetDietFromAISelectOrderProductsNo = "select_order_products_n" ) ``` -------------------------------- ### GetDietParams Struct Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/model Represents parameters for getting diet information, including age, weight, height, gender, and physical activity. ```go type GetDietParams struct { Age int `json:"age"` Weight int `json:"weight"` Height int `json:"height"` Gender Gender `json:"gender"` PhysicalActivity PhysicalActivityLevel `json:"physical_activity"` MealsAndSnacksNumber } ``` -------------------------------- ### Constants for getting diet from AI Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/tg-bot/logic-handlers Defines callback keys for selecting meals and snacks when getting diet information from AI. ```Go const ( GetDietFromAISelectMeals = "select_meals" GetDietFromAISelectSnacks = "select_snacks" GetDietFromAISelectOrderProducts = "select_order_products" ) ``` -------------------------------- ### ChatBotDialogDataGetDietFromAI Struct Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/model Represents data for getting diet information from AI, including parameters and an optional order flag. ```go type ChatBotDialogDataGetDietFromAI struct { Params GetDietParams `json:"params"` NeedOrder *bool `json:"need_order,omitempty"` } ``` -------------------------------- ### New function Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/service Creates a new Service instance. ```go func New( storage *store.Storage, ) *Service ``` -------------------------------- ### New function Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/pkg/server The New function creates and returns a new Server instance. ```go func New(handler http.Handler, addres string) *Server ``` -------------------------------- ### New function Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/ai-api-client Constructor for the Client. ```go func New(apiKey string) *Client ``` -------------------------------- ### SignInUser method Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/service Handles user sign-in. ```go func (svc *Service) SignInUser( ctx context.Context, userToSignIn *model.UserToSignIn, ) (token string, err error) ``` -------------------------------- ### RegisterUser method Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/service Registers a new user. ```go func (svc *Service) RegisterUser( ctx context.Context, userToReg *model.UserToRegister, ) (*model.User, error) ``` -------------------------------- ### Execx Function Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/store Execx executes a query using a squirrel.Sqlizer. ```Go func Execx(ctx context.Context, db Executor, sqlizer sq.Sqlizer) (pgconn.CommandTag, error) ``` -------------------------------- ### StartGettingDiet Function Signature Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/tg-bot/logic-handlers Signature for the StartGettingDiet handler. ```go func (h *LogicHandlers) StartGettingDiet(b *gotgbot.Bot, ctx *ext.Context) error ``` -------------------------------- ### String Method for PhysicalActivityLevel Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/model String method for PhysicalActivityLevel. ```go func (i PhysicalActivityLevel) String() string ``` -------------------------------- ### Config Struct Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/config Main configuration structure for the application. ```go type Config struct { PgDSN string `mapstructure:"PG_DSN"` ServerAddress string `mapstructure:"SERVER_ADDRESS"` JWTToken `mapstructure:",squash" TelegramBot `mapstructure:",squash" AIConfig `mapstructure:",squash" } ``` -------------------------------- ### StartGettingDietFromAI Function Signature Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/tg-bot/logic-handlers Signature for the StartGettingDietFromAI handler. ```go func (h *LogicHandlers) StartGettingDietFromAI(b *gotgbot.Bot, ctx *ext.Context) error ``` -------------------------------- ### Constants Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/model UserCreatedBy values ```go const ( UserCreatedByChatbot = UserCreatedBy("chatbot") // Chatbot UserCreatedByAPI = UserCreatedBy("api") // API ) ``` -------------------------------- ### String Method for Gender Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/model String method for Gender. ```go func (i Gender) String() string ``` -------------------------------- ### UserToRegister Struct Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/model Defines the structure for user registration, including required fields like name, email, age, weight, height, gender, and password. It uses 'binding' tags for validation. ```go type UserToRegister struct { Name string `json:"name" binding:"required"` Email string `json:"email" binding:"required"` Phone string `json:"phone"` Age int `json:"age" binding:"required"` Weight int `json:"weight" binding:"required"` Height int `json:"height" binding:"required"` Gender Gender `json:"gender" binding:"required"` Password string `json:"password" binding:"required"` } ``` -------------------------------- ### New function Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/tg-bot New creates a new Bot instance. ```go func New( aiClient logic_handlers.AIClient, storage *store.Storage, ) (*Bot, error) ``` -------------------------------- ### StartUserRegistration Function Signature Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/tg-bot/logic-handlers Signature for the StartUserRegistration handler. ```go func (h *LogicHandlers) StartUserRegistration(b *gotgbot.Bot, ctx *ext.Context) (nextState error) ``` -------------------------------- ### Exec Function Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/store Exec executes a given SQL query. ```Go func Exec(ctx context.Context, db Executor, query string, args ...interface{}) (pgconn.CommandTag, error) ``` -------------------------------- ### UserToSignIn Struct Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/model Defines the structure for user sign-in, requiring email and password, with 'binding' tags for validation. ```go type UserToSignIn struct { Email string `json:"email" binding:"required"` Password string `json:"password" binding:"required"` } ``` -------------------------------- ### DescriptionRu Method for PhysicalActivityLevel Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/model Returns the Russian description for a PhysicalActivityLevel value. ```go func (l PhysicalActivityLevel) DescriptionRu() string ``` -------------------------------- ### Constants Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/model AIAPILogsSourceType values ```go const ( AIAPILogsSourceTypeChatbotDialog = AIAPILogsSourceType("chatbot_dialog") // ChatbotDialog ) ``` -------------------------------- ### Callback keys for user registration confirmation and gender/activity selection Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/tg-bot/logic-handlers Defines callback keys for user registration, specifically for gender selection (male/female), physical activity levels (low/medium/high), and confirmation (yes/no). ```Go const ( RegisterGenderCbMale = "gender_male" RegisterGenderCbFemale = "gender_female" RegisterPhysicalActivityCbLow = "physicalactivity_low" RegisterPhysicalActivityCbMedium = "physicalactivity_medium" RegisterPhysicalActivityCbHigh = "physicalactivity_high" RegisterConfirmCbYes = "сonfirm_yes" RegisterConfirmCbNo = "сonfirm_no" ) ``` -------------------------------- ### Constants Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/model PhysicalActivityLevel values ```go const ( PhysicalActivityLevelLow = PhysicalActivityLevel(1) // Low PhysicalActivityLevelMedium = PhysicalActivityLevel(2) // Medium PhysicalActivityLevelHigh = PhysicalActivityLevel(3) // High ) ``` -------------------------------- ### String Method for ChatBotDialogStatus Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/model String method for ChatBotDialogStatus. ```go func (i ChatBotDialogStatus) String() string ``` -------------------------------- ### Client struct Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/ai-api-client The Client struct definition. ```go type Client struct { // contains filtered or unexported fields } ``` -------------------------------- ### New Function Signature Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/store Signature for the New function, which initializes a Storage. ```go func New(ctx context.Context) (*Storage, error) ``` -------------------------------- ### Load Function Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/config Function to load configuration from file or environment variables. ```go func Load(path string) (err error) ``` -------------------------------- ### IsFilledForGetDiet Method Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/model A method on the User struct that checks if the user's data is sufficiently filled to retrieve diet information. ```go func (u User) IsFilledForGetDiet() bool ``` -------------------------------- ### Constants Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/model AuthDataSourceType values ```go const ( AuthDataSourceTypeUser = AuthDataSourceType("user") // User AuthDataSourceTypeNutritionist = AuthDataSourceType("nutritionist") // Nutritionist ) ``` -------------------------------- ### Service struct Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/service Represents the service with business logic. ```go type Service struct { // contains filtered or unexported fields } ``` -------------------------------- ### Constants Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/model ChatBotDialogStatus values ```go const ( ChatBotDialogStatusInitial = ChatBotDialogStatus(1) // Initial ChatBotDialogStatusInProgress = ChatBotDialogStatus(2) // InProgress ChatBotDialogStatusCanceled = ChatBotDialogStatus(3) // Canceled ChatBotDialogStatusCompleted = ChatBotDialogStatus(4) // Completed ) ``` -------------------------------- ### DbTable Method for Nutritionist Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/model Returns the database table name for the Nutritionist struct. ```go func (Nutritionist) DbTable() string ``` -------------------------------- ### Ptr Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/pkg/ptrconv Ptr returns pointer to value ```go func Ptr[T any](val T) *T ``` -------------------------------- ### func (AIAPILog) DbTable Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/model Method signature for DbTable on AIAPILog ```go func (AIAPILog) DbTable() string ``` -------------------------------- ### DbTable Method for ChatBotDialog Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/model Returns the database table name for the ChatBotDialog struct. ```go func (ChatBotDialog) DbTable() string ``` -------------------------------- ### func (AuthData) DbTable Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/model Method signature for DbTable on AuthData ```go func (AuthData) DbTable() string ``` -------------------------------- ### func HashPassword Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/model Function signature for HashPassword ```go func HashPassword(password string) (string, error) ``` -------------------------------- ### Select Function Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/store Select executes a query to retrieve multiple records. ```Go func Select(ctx context.Context, db pgxscan.Querier, dst interface{}, query string, args ...interface{}) error ``` -------------------------------- ### User Struct Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/model Defines the structure for a User, including personal details, physical attributes, and timestamps. It includes JSON and database tags for serialization and persistence. ```go type User struct { ID uuid.UUID `json:"id" db:"id"` Name string `json:"name" db:"name"` Email *string `json:"email" db:"email"` Phone *string `json:"phone" db:"phone"` TelegramID *int64 `json:"telegram_id" db:"telegram_id"` Age *int `json:"age" db:"age"` Weight *int `json:"weight" db:"weight"` Height *int `json:"height" db:"height"` Gender *Gender `json:"gender" db:"gender"` PhysicalActivity *PhysicalActivityLevel `json:"physical_activity_level" db:"physical_activity_level"` CreatedBy UserCreatedBy `json:"created_by" db:"created_by"` CreatedAt time.Time `json:"createdAt" db:"created_at"` UpdatedAt time.Time `json:"updatedAt" db:"updated_at"` } ``` -------------------------------- ### AIConfig Struct Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/config Configuration structure for AI settings. ```go type AIConfig struct { APIKey string `mapstructure:"API_KEY"` } ``` -------------------------------- ### func New Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/jwttoken New returns new JWT token for source_id, source_type ```go func New(sourceID uuid.UUID, sourceType model.AuthDataSourceType) (string, error) ``` -------------------------------- ### Getx Function Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/store Getx executes a query to retrieve a single record using a squirrel.Sqlizer. ```Go func Getx(ctx context.Context, db Querier, dst interface{}, sqlizer sq.Sqlizer) error ``` -------------------------------- ### func CheckPasswordHash Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/model Function signature for CheckPasswordHash ```go func CheckPasswordHash(hash, password string) bool ``` -------------------------------- ### type AuthData Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/model Struct definition for AuthData ```go type AuthData struct { SourceID uuid.UUID `db:"source_id"` SourceType AuthDataSourceType `db:"source_type"` Password string `db:"password"` CreatedAt time.Time `db:"created_at"` UpdatedAt time.Time `db:"updated_at"` } ``` -------------------------------- ### DescriptionRu Method for Gender Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/model Returns the Russian description for a Gender value. ```go func (g Gender) DescriptionRu() string ``` -------------------------------- ### Shutdown method Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/pkg/server The Shutdown method gracefully shuts down the HTTP server. ```go func (s *Server) Shutdown(ctx context.Context) error ``` -------------------------------- ### ChatBotDialogDataUserRegistration Struct Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/model Represents data for user registration, including name, age, weight, height, gender, and physical activity level. ```go type ChatBotDialogDataUserRegistration struct { Name *string `json:"name,omitempty"` Age *int `json:"age,omitempty"` Weight *int `json:"weight,omitempty"` Height *int `json:"height,omitempty"` Gender *Gender `json:"gender,omitempty"` PhysicalActivity *PhysicalActivityLevel `json:"physical_activity_level,omitempty"` } ``` -------------------------------- ### Constants Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/model Gender values ```go const ( GenderMale = Gender(1) // Male GenderFemale = Gender(2) // Female ) ``` -------------------------------- ### DbTable Method Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/model A method on the User struct that returns the corresponding database table name. ```go func (User) DbTable() string ``` -------------------------------- ### JWTToken Struct Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/config Configuration structure for JWT token settings. ```go type JWTToken struct { Lifitime time.Duration `mapstructure:"TOKEN_LIFETIME"` Issuer string `mapstructure:"TOKEN_ISSUER"` Secret string `mapstructure:"TOKEN_SECRET"` } ``` -------------------------------- ### Constants Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/model NutritionistCreatedBy values ```go const ( NutritionistCreatedByChatbot = NutritionistCreatedBy("chatbot") // Chatbot NutritionistCreatedByAPI = NutritionistCreatedBy("api") // API ) ``` -------------------------------- ### ChatBotDialog Struct Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/model Defines the structure for a chatbot dialog, including user ID, kind, status, data, and timestamps. ```go type ChatBotDialog struct { ID uuid.UUID `db:"id"` UserTelegramID int64 `db:"user_telegram_id"` Kind ChatBotDialogKind `db:"kind"` Status ChatBotDialogStatus `db:"status"` DataJSON string `db:"data"` CreatedAt time.Time `db:"created_at"` UpdatedAt time.Time `db:"updated_at"` } ``` -------------------------------- ### IsFilled Method for ChatBotDialogDataUserRegistration Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/model Returns true if all fields in ChatBotDialogDataUserRegistration are filled. ```go func (data *ChatBotDialogDataUserRegistration) IsFilled() bool ``` -------------------------------- ### Executor Interface Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/store Executor defines an interface for executing SQL queries. ```Go type Executor interface { Exec(ctx context.Context, sql string, arguments ...any) (pgconn.CommandTag, error) } ``` -------------------------------- ### Querier Interface Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/store Querier defines an interface for executing SQL queries and returning pgx.Rows. ```Go type Querier interface { Query(ctx context.Context, query string, args ...interface{}) (pgx.Rows, error) } ``` -------------------------------- ### SendRequest function Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/ai-api-client Sends a request to the ChatGPT API and returns the response. ```go func (c *Client) SendRequest(ctx context.Context, prompt string) (string, error) ``` -------------------------------- ### CreateUser Function Signature Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/store Signature for the CreateUser method, used to create user records. ```go func (s *Storage) CreateUser(ctx context.Context, record *model.User) error ``` -------------------------------- ### Selectx Function Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/store Selectx executes a query to retrieve multiple records using a squirrel.Sqlizer. ```Go func Selectx(ctx context.Context, db pgxscan.Querier, dst interface{}, sqlizer sq.Sqlizer) error ``` -------------------------------- ### Storage Struct Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/store Storage is a struct that holds the storage implementation details. ```Go type Storage struct { // contains filtered or unexported fields } ``` -------------------------------- ### New LogicHandlers constructor Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/tg-bot/logic-handlers Constructor function for creating a new instance of LogicHandlers. ```Go func New( aiClient AIClient, storage *store.Storage, ) *LogicHandlers ``` -------------------------------- ### SelectOrderProducts Function Signature Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/tg-bot/logic-handlers Signature for the SelectOrderProducts handler. ```go func (h *LogicHandlers) SelectOrderProducts(b *gotgbot.Bot, ctx *ext.Context) error ``` -------------------------------- ### Stop method Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/tg-bot Stop gracefully shuts down the bot. ```go func (b *Bot) Stop() error ``` -------------------------------- ### ChatBotDialogKind Constants Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/model Defines constants for ChatBotDialogKind, including UserRegistration and GetDietFromAI. ```go const ( ChatBotDialogKindUserRegistration ChatBotDialogKind = "UserRegistration" // UserRegistration ChatBotDialogKindGetDietFromAI ChatBotDialogKind = "GetDietFromAI" // GetDietFromAI ) ``` -------------------------------- ### type AIAPILog Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/model Struct definition for AIAPILog ```go type AIAPILog struct { ID uuid.UUID `db:"id"` Prompt string `db:"prompt"` Response *string `db:"response"` UserID uuid.UUID `db:"user_id"` SourceID uuid.UUID `db:"source_id"` SourceType AIAPILogsSourceType `db:"source_type"` CreatedAt time.Time `db:"created_at"` UpdatedAt time.Time `db:"updated_at"` } ``` -------------------------------- ### FromJSON Method for ChatBotDialogDataUserRegistration Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/model Unmarshals data from a JSON string into a ChatBotDialogDataUserRegistration struct. ```go func (data *ChatBotDialogDataUserRegistration) FromJSON(s string) error ``` -------------------------------- ### SelectOrderProductsNo Function Signature Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/tg-bot/logic-handlers Signature for the SelectOrderProductsNo handler. ```go func (h *LogicHandlers) SelectOrderProductsNo(b *gotgbot.Bot, ctx *ext.Context) (nextState error) ``` -------------------------------- ### FromJSON Method for ChatBotDialogDataGetDietFromAI Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/model Unmarshals data from a JSON string into a ChatBotDialogDataGetDietFromAI struct. ```go func (data *ChatBotDialogDataGetDietFromAI) FromJSON(s string) error ``` -------------------------------- ### MealsAndSnacksNumber Struct Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/model Represents the number of meals and snacks per day. ```go type MealsAndSnacksNumber struct { MealsNumberPerDay int `json:"meals"` SnacksNumberPerDay int `json:"snacks"` } ``` -------------------------------- ### ToJSON Method for ChatBotDialogDataUserRegistration Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/model Marshals ChatBotDialogDataUserRegistration data to a JSON string. ```go func (data *ChatBotDialogDataUserRegistration) ToJSON() string ``` -------------------------------- ### type AIAPILogsSourceType Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/model Type definition for AIAPILogsSourceType ```go type AIAPILogsSourceType string ``` -------------------------------- ### AIClient interface Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/tg-bot/logic-handlers Defines the interface for an AI client, which must implement a SendRequest method to send prompts and receive responses. ```Go type AIClient interface { SendRequest(ctx context.Context, prompt string) (resp string, err error) } ``` -------------------------------- ### ErrWrongPassword variable Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/service Defines the error for a wrong password. ```go var ( ErrWrongPassword = errors.Errorf("wrong password") ) ``` -------------------------------- ### RegisterUserPhysicalActivityMedium Function Signature Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/tg-bot/logic-handlers Signature for the RegisterUserPhysicalActivityMedium handler. ```go func (h *LogicHandlers) RegisterUserPhysicalActivityMedium(b *gotgbot.Bot, ctx *ext.Context) (nextState error) ``` -------------------------------- ### UserCreatedBy Type Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/model Defines a custom string type for the 'CreatedBy' field of the User. ```go type UserCreatedBy string ``` -------------------------------- ### ConfirmUserRegistrationNo Function Signature Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/tg-bot/logic-handlers Signature for the ConfirmUserRegistrationNo handler. ```go func (h *LogicHandlers) ConfirmUserRegistrationNo(b *gotgbot.Bot, ctx *ext.Context) (nextState error) ``` -------------------------------- ### New function signature Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/handler Signature for the New function, which constructs a new http.Handler with storage and service dependencies. ```go func New( storage *store.Storage, svc *service.Service, ) http.Handler ``` -------------------------------- ### RandomGenerator Variable Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/config Global variable for generating pseudorandom numbers. ```go var RandomGenerator *rand.Rand ``` -------------------------------- ### ToJSON Method for ChatBotDialogDataGetDietFromAI Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/model Marshals ChatBotDialogDataGetDietFromAI data to a JSON string. ```go func (data *ChatBotDialogDataGetDietFromAI) ToJSON() string ``` -------------------------------- ### SelectMeals3 Function Signature Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/tg-bot/logic-handlers Signature for the SelectMeals3 handler. ```go func (h *LogicHandlers) SelectMeals3(b *gotgbot.Bot, ctx *ext.Context) error ``` -------------------------------- ### Tx Type Definition Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/store Definition of the Tx type, which is an alias for pgx.Tx. ```go type Tx pgx.Tx ``` -------------------------------- ### TelegramBot Struct Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/config Configuration structure for Telegram bot settings, including webhook details. ```go type TelegramBot struct { // Token from Telegram Token string `mapstructure:"TG_BOT_TOKEN"` // Settings for webhook. If empty use polling WebhookDomain string `mapstructure:"TG_BOT_WEBHOOK_DOMAIN"` WebhookSecret string `mapstructure:"TG_BOT_WEBHOOK_SECRET"` WebhookAddress string `mapstructure:"TG_BOT_WEBHOOK_ADDRESS"` } ``` -------------------------------- ### Nutritionist Struct Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/model Represents a nutritionist, including their ID, name, contact information, age, gender, and creation details. ```go type Nutritionist struct { ID uuid.UUID `json:"id" db:"id"` Name string `json:"name" db:"name"` Email *string `json:"email" db:"email"` Phone *string `json:"phone" db:"phone"` TelegramID *int64 `json:"telegram_id" db:"telegram_id"` Age *int `json:"age" db:"age"` Gender *Gender `json:"gender" db:"gender"` Info *string `json:"info" db:"info"` CreatedBy NutritionistCreatedBy `json:"created_by" db:"created_by"` CreatedAt time.Time `json:"createdAt" db:"created_at"` UpdatedAt time.Time `json:"updatedAt" db:"updated_at"` } ``` -------------------------------- ### SelectOrderProductsYes Function Signature Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/tg-bot/logic-handlers Signature for the SelectOrderProductsYes handler. ```go func (h *LogicHandlers) SelectOrderProductsYes(b *gotgbot.Bot, ctx *ext.Context) (nextState error) ``` -------------------------------- ### type AuthDataSourceType Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/model Type definition for AuthDataSourceType ```go type AuthDataSourceType string ``` -------------------------------- ### Server struct Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/pkg/server The Server struct is an unexported type used to hold server-related data. ```go type Server struct { // contains filtered or unexported fields } ``` -------------------------------- ### RegisterUserWeight Function Signature Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/tg-bot/logic-handlers Signature for the RegisterUserWeight handler. ```go func (h *LogicHandlers) RegisterUserWeight(b *gotgbot.Bot, ctx *ext.Context) (nextState error) ``` -------------------------------- ### Handler states for user registration Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/tg-bot/logic-handlers Defines the handler states used during the user registration process, covering name, age, weight, height, gender, physical activity, and confirmation. ```Go const ( RegisterName = "name" RegisterAge = "age" RegisterWeight = "weight" RegisterHeight = "height" RegisterGender = "gender" RegisterPhysicalActivity = "physicalactivity" RegisterConfirm = "сonfirm" ) ``` -------------------------------- ### Detach Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/pkg/ctxutil Detach returns a context that keeps all the values of its parent context but detaches from the cancellation and error handling. ```go func Detach(ctx context.Context) context.Context ``` -------------------------------- ### SelectMeals2 Function Signature Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/tg-bot/logic-handlers Signature for the SelectMeals2 handler. ```go func (h *LogicHandlers) SelectMeals2(b *gotgbot.Bot, ctx *ext.Context) error ``` -------------------------------- ### RegisterUserGenderFemale Function Signature Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/tg-bot/logic-handlers Signature for the RegisterUserGenderFemale handler. ```go func (h *LogicHandlers) RegisterUserGenderFemale(b *gotgbot.Bot, ctx *ext.Context) (nextState error) ``` -------------------------------- ### RegisterUserPhysicalActivityLow Function Signature Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/tg-bot/logic-handlers Signature for the RegisterUserPhysicalActivityLow handler. ```go func (h *LogicHandlers) RegisterUserPhysicalActivityLow(b *gotgbot.Bot, ctx *ext.Context) (nextState error) ``` -------------------------------- ### NutritionistCreatedBy Type Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/model Defines the type for the Nutritionist CreatedBy field. ```go type NutritionistCreatedBy string ``` -------------------------------- ### CreateAIAPILog Function Signature Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/store Signature for the CreateAIAPILog method, used to create AI API logs. ```go func (s *Storage) CreateAIAPILog(ctx context.Context, record *model.AIAPILog) error ``` -------------------------------- ### RegisterUserName Function Signature Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/tg-bot/logic-handlers Signature for the RegisterUserName handler. ```go func (h *LogicHandlers) RegisterUserName(b *gotgbot.Bot, ctx *ext.Context) (nextState error) ``` -------------------------------- ### type Claims Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/jwttoken Claims has key fields from token ```go type Claims struct { SourceID uuid.UUID SourceType model.AuthDataSourceType } ``` -------------------------------- ### RegisterUserGenderMale Function Signature Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/tg-bot/logic-handlers Signature for the RegisterUserGenderMale handler. ```go func (h *LogicHandlers) RegisterUserGenderMale(b *gotgbot.Bot, ctx *ext.Context) (nextState error) ``` -------------------------------- ### RegisterUserHeight Function Signature Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/tg-bot/logic-handlers Signature for the RegisterUserHeight handler. ```go func (h *LogicHandlers) RegisterUserHeight(b *gotgbot.Bot, ctx *ext.Context) (nextState error) ``` -------------------------------- ### CancelGettingDiet Function Signature Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/tg-bot/logic-handlers Signature for the CancelGettingDiet handler. ```go func (h *LogicHandlers) CancelGettingDiet(b *gotgbot.Bot, ctx *ext.Context) error ``` -------------------------------- ### ChatBotDialogKind Type Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/model Defines the type for ChatBotDialog kind. ```go type ChatBotDialogKind string ``` -------------------------------- ### CreateNutritionist Function Signature Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/store Signature for the CreateNutritionist method, used to create nutritionist records. ```go func (s *Storage) CreateNutritionist(ctx context.Context, record *model.Nutritionist) error ``` -------------------------------- ### CreateUserTx Function Signature Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/store Signature for the CreateUserTx method, used to create user records within a transaction. ```go func (s *Storage) CreateUserTx(ctx context.Context, tx Tx, record *model.User) error ``` -------------------------------- ### RegisterUserPhysicalActivityHigh Function Signature Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/tg-bot/logic-handlers Signature for the RegisterUserPhysicalActivityHigh handler. ```go func (h *LogicHandlers) RegisterUserPhysicalActivityHigh(b *gotgbot.Bot, ctx *ext.Context) (nextState error) ``` -------------------------------- ### ConfirmUserRegistrationYes Function Signature Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/tg-bot/logic-handlers Signature for the ConfirmUserRegistrationYes handler. ```go func (h *LogicHandlers) ConfirmUserRegistrationYes(b *gotgbot.Bot, ctx *ext.Context) (nextState error) ``` -------------------------------- ### Gender Type Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/model Defines the type for a person's gender. ```go type Gender int32 ``` -------------------------------- ### RegisterUserAge Function Signature Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/tg-bot/logic-handlers Signature for the RegisterUserAge handler. ```go func (h *LogicHandlers) RegisterUserAge(b *gotgbot.Bot, ctx *ext.Context) (nextState error) ``` -------------------------------- ### ChatBotDialogStatus Type Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/model Defines the type for ChatBotDialog status. ```go type ChatBotDialogStatus int32 ``` -------------------------------- ### PhysicalActivityLevel Type Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/model Defines the type for a person's physical activity level. ```go type PhysicalActivityLevel int32 ``` -------------------------------- ### CreateAuthDataTx Function Signature Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/store Signature for the CreateAuthDataTx method, used to create authentication data within a transaction. ```go func (s *Storage) CreateAuthDataTx(ctx context.Context, tx Tx, record *model.AuthData) error ``` -------------------------------- ### SelectSnacks1 Function Signature Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/tg-bot/logic-handlers Signature for the SelectSnacks1 handler. ```go func (h *LogicHandlers) SelectSnacks1(b *gotgbot.Bot, ctx *ext.Context) error ``` -------------------------------- ### SelectSnacks0 Function Signature Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/tg-bot/logic-handlers Signature for the SelectSnacks0 handler. ```go func (h *LogicHandlers) SelectSnacks0(b *gotgbot.Bot, ctx *ext.Context) error ``` -------------------------------- ### Close Function Signature Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/store Signature for the Close method of the Storage type. ```go func (s *Storage) Close() ``` -------------------------------- ### SelectSnacks2 Function Signature Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/tg-bot/logic-handlers Signature for the SelectSnacks2 handler. ```go func (h *LogicHandlers) SelectSnacks2(b *gotgbot.Bot, ctx *ext.Context) error ``` -------------------------------- ### CORS function signature Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/handler Signature for the CORS function, which likely wraps an http.Handler to add CORS headers. ```go func CORS(h http.Handler) http.Handler ``` -------------------------------- ### CreateChatBotDialog Function Signature Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/store Signature for the CreateChatBotDialog method, used to create chatbot dialog records. ```go func (s *Storage) CreateChatBotDialog(ctx context.Context, record *model.ChatBotDialog) error ``` -------------------------------- ### LogicHandlers struct Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/tg-bot/logic-handlers Represents the structure for logic handlers, which orchestrates the bot's core functionalities. ```Go type LogicHandlers struct { // contains filtered or unexported fields } ``` -------------------------------- ### GetUserByEmail Function Signature Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/store Signature for the GetUserByEmail method, used to retrieve a user by email. ```go func (s *Storage) GetUserByEmail(ctx context.Context, email string) (*model.User, error) ``` -------------------------------- ### WithTx Function Signature Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/store Signature for the WithTx method, used to execute a function within a transaction with custom options. ```go func (s *Storage) WithTx(ctx context.Context, options pgx.TxOptions, fn func(tx Tx) error) (err error) ``` -------------------------------- ### ErrNotFound Variable Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/store ErrNotFound is an error indicating that a record was not found. ```Go var ( // ErrNotFound is error that record not found ErrNotFound = errors.New("record not found") ) ``` -------------------------------- ### CancelUserRegistration Function Signature Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/tg-bot/logic-handlers Signature for the CancelUserRegistration handler. ```go func (h *LogicHandlers) CancelUserRegistration(b *gotgbot.Bot, ctx *ext.Context) error ``` -------------------------------- ### UpdateUser Function Signature Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/store Signature for the UpdateUser method, used to update user records. ```go func (s *Storage) UpdateUser(ctx context.Context, record *model.User) error ``` -------------------------------- ### Handler struct definition Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/handler Definition of the Handler struct, indicating it contains unexported fields. ```go type Handler struct { // contains filtered or unexported fields } ``` -------------------------------- ### GetAuthDataBySourceIDAndType Function Signature Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/store Signature for the GetAuthDataBySourceIDAndType method, used to retrieve authentication data. ```go func (s *Storage) GetAuthDataBySourceIDAndType( ctx context.Context, sourceID uuid.UUID, sourceType model.AuthDataSourceType, ) (*model.AuthData, error) ``` -------------------------------- ### func ParseAndValidate Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/jwttoken ParseAndValidate parses and validates JWT token ```go func ParseAndValidate(tokenString string) (*Claims, error) ``` -------------------------------- ### GetChatBotDialogByKeyFields Function Signature Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/store Signature for the GetChatBotDialogByKeyFields method, used to retrieve chatbot dialogs by key fields. ```go func (s *Storage) GetChatBotDialogByKeyFields( ctx context.Context, userTelegramID int64, kind model.ChatBotDialogKind, status model.ChatBotDialogStatus, ) (*model.ChatBotDialog, error) ``` -------------------------------- ### WithTransaction Function Signature Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/store Signature for the WithTransaction method, used to execute a function within a transaction. ```go func (s *Storage) WithTransaction(ctx context.Context, fn func(tx Tx) error) (err error) ``` -------------------------------- ### Bot struct Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/tg-bot The Bot struct contains filtered or unexported fields. ```go type Bot struct { // contains filtered or unexported fields } ``` -------------------------------- ### GetUserByID Function Signature Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/store Signature for the GetUserByID method, used to retrieve a user by ID. ```go func (s *Storage) GetUserByID(ctx context.Context, id uuid.UUID) (*model.User, error) ``` -------------------------------- ### UpdateAIAPILog Function Signature Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/store Signature for the UpdateAIAPILog method, used to update AI API logs. ```go func (s *Storage) UpdateAIAPILog(ctx context.Context, record *model.AIAPILog) error ``` -------------------------------- ### UpdateChatBotDialogStatusTx Function Signature Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/store Signature for the UpdateChatBotDialogStatusTx method, used to update the status of a chatbot dialog within a transaction. ```go func (s *Storage) UpdateChatBotDialogStatusTx(ctx context.Context, tx Tx, status model.ChatBotDialogStatus, id uuid.UUID) error ``` -------------------------------- ### UpdateNutritionist Function Signature Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/store Signature for the UpdateNutritionist method, used to update nutritionist records. ```go func (s *Storage) UpdateNutritionist(ctx context.Context, record *model.Nutritionist) error ``` -------------------------------- ### UpdateChatBotDialog Function Signature Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/store Signature for the UpdateChatBotDialog method, used to update chatbot dialog records. ```go func (s *Storage) UpdateChatBotDialog(ctx context.Context, record *model.ChatBotDialog) error ``` -------------------------------- ### GetNutritionistByID Function Signature Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/store Signature for the GetNutritionistByID method, used to retrieve a nutritionist by ID. ```go func (s *Storage) GetNutritionistByID(ctx context.Context, id uuid.UUID) (*model.Nutritionist, error) ``` -------------------------------- ### GetUserByTelegramID Function Signature Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/store Signature for the GetUserByTelegramID method, used to retrieve a user by Telegram ID. ```go func (s *Storage) GetUserByTelegramID(ctx context.Context, telegramID int64) (*model.User, error) ``` -------------------------------- ### UpdateAuthDataPassword Function Signature Source: https://pkg.go.dev/github.com/l-orlov/slim-fairy/bot/internal/store Signature for the UpdateAuthDataPassword method, used to update the password in authentication data. ```go func (s *Storage) UpdateAuthDataPassword(ctx context.Context, record *model.AuthData) error ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.