<repo><f p="database\database.go"><![CDATA[package database
import (
 "FUCKYOULANGCHAIN/logger"
 "FUCKYOULANGCHAIN/models"
 "gorm.io/driver/sqlite"
 "gorm.io/gorm"
)
var DB *gorm.DB
func InitDB() {
 var err error
 DB, err = gorm.Open(sqlite.Open("bot.db"), &gorm.Config{})
 if err != nil {
 logger.Log.Fatalf("Failed to connect to database: %v", err)
 }
 err = DB.AutoMigrate(&models.ToDo{}, &models.ToDoItem{}, &models.User{}, &models.Reminder{})
 if err != nil {
 logger.Log.Fatalf("Failed to migrate database schema: %v", err)
 }
 logger.Log.Info("Database initialized successfully")
}]]></f><f p="config\config.go"><![CDATA[package config
import (
 "FUCKYOULANGCHAIN/logger"
 "os"
 "github.com/joho/godotenv"
 "github.com/kelseyhightower/envconfig"
)
type Config struct {
 TelegramAPIKey string `envconfig:"TELEGRAM_API_KEY" required:"true"`
 TelegramUserID string `envconfig:"TELEGRAM_USER_ID" required:"true"`
 AIProvider string `envconfig:"AI_PROVIDER" default:"googleai" required:"true"`
 OpenAIAPIKey string `envconfig:"OPENAI_API_KEY"`
 OpenAITextModel string `envconfig:"OPENAI_TEXT_MODEL" default:"gpt-3.5-turbo"`
 OpenAIVoiceModel string `envconfig:"OPENAI_VOICE_MODEL" default:"whisper-1"`
 GoogleAPIKey string `envconfig:"GOOGLE_API_KEY"`
 GoogleTextModel string `envconfig:"GOOGLE_TEXT_MODEL" default:"gemini-1.5-flash"`
 GoogleVoiceModel string `envconfig:"GOOGLE_VOICE_MODEL" default:"gemini-1.5-flash"`
}
var AppConfig Config
func LoadConfig() {
 if err := godotenv.Load(); err != nil && !os.IsNotExist(err) {
 logger.Log.Fatalf("Error loading .env file: %v", err)
 }
 err := envconfig.Process("", &AppConfig)
 if err != nil {
 logger.Log.Fatalf("Error loading config: %v", err)
 }
 logger.Log.Info("Configuration loaded successfully")
}]]></f><f p="handler\handler.go"><![CDATA[package handler
import (
 "context"
 "github.com/go-telegram/bot"
 "github.com/go-telegram/bot/models"
)
func DefaultHandler(ctx context.Context, b *bot.Bot, update *models.Update) {
 b.SendMessage(ctx, &bot.SendMessageParams{
 ChatID: update.Message.Chat.ID,
 Text: `
<b>COMMANDS</b> 
/timezone - Needed for reminder functionality
/newreminder - Create a reminder
/newnote - New note`,
 ParseMode: models.ParseModeHTML,
 })
}]]></f><f p="handler\middleware.go"><![CDATA[package handler
import (
 "FUCKYOULANGCHAIN/config"
 "FUCKYOULANGCHAIN/database"
 "FUCKYOULANGCHAIN/logger"
 "FUCKYOULANGCHAIN/models"
 "context"
 "strconv"
 "github.com/go-telegram/bot"
 tgmodels "github.com/go-telegram/bot/models"
)
func RegisterUserMiddleware(next bot.HandlerFunc) bot.HandlerFunc {
 return func(ctx context.Context, b *bot.Bot, update *tgmodels.Update) {
 userID := update.Message.From.ID
 var user models.User
 result := database.DB.First(&user, userID)
 if result.Error != nil {
 user = models.User{
 ID: userID,
 UserName: update.Message.From.Username,
 }
 database.DB.Create(&user)
 } else if user.Timezone == "" {
 database.DB.Save(&user)
 b.SendMessage(ctx, &bot.SendMessageParams{
 ChatID: update.Message.Chat.ID,
 Text: "Please send me your timezone in 'Area/City' format (e.g., 'Europe/London').",
 })
 }
 next(ctx, b, update)
 }
}
func OnlyAdminMiddleware(next bot.HandlerFunc) bot.HandlerFunc {
 return func(ctx context.Context, b *bot.Bot, update *tgmodels.Update) {
 userID := update.Message.From.ID
 adminID, _ := strconv.Atoi(config.AppConfig.TelegramUserID)
 if userID != int64(adminID) {
 logger.Log.Warnf("Bot accessed by non-admin: %d", userID)
 return
 }
 next(ctx, b, update)
 }
}]]></f><f p="logger\logger.go"><![CDATA[package logger
import (
 "io"
 "os"
 "github.com/sirupsen/logrus"
)
var Log *logrus.Logger
func Init() {
 Log = logrus.New()
 Log.SetOutput(os.Stdout)
 Log.SetLevel(logrus.InfoLevel)
 Log.SetFormatter(&logrus.TextFormatter{
 FullTimestamp: true,
 })
}
func SetOutput(w io.Writer) {
 Log.SetOutput(w)
}]]></f><f p="models\reminder.go"><![CDATA[package models
import "time"
type Reminder struct {
 ID int64 `gorm:"primaryKey" json:"id"`
 UserID int64 `json:"user_id"`
 Message string `json:"message"`
 ReminderTime time.Time `json:"reminder_time"` 
 CreatedAt time.Time `json:"created_at"`
 UpdatedAt time.Time `json:"updated_at"`
}]]></f><f p="models\response.go"><![CDATA[package models
type ResponseType int
const (
 ResponseText ResponseType = iota
 ResponseToDo
 ResponseReminder
 ResponseNote
)
type GenericResponse struct {
 Type ResponseType
 Text string 
 ToDo *ToDo 
 Reminder *Reminder
}]]></f><f p="models\todo.go"><![CDATA[package models
import "time"
type ToDo struct {
 ID int64 `gorm:"primaryKey" json:"id"`
 UserID int64 `json:"user_id"`
 Name string `json:"name"`
 Items []ToDoItem `gorm:"foreignKey:ToDoID" json:"items"`
 CreatedAt time.Time `json:"created_at"`
 UpdatedAt time.Time `json:"updated_at"`
}
type ToDoItem struct {
 ID int64 `gorm:"primaryKey" json:"id"`
 ToDoID int64 `json:"todo_id"`
 Name string `json:"name"`
 Completed bool `json:"completed"`
 CreatedAt time.Time `json:"created_at"`
 UpdatedAt time.Time `json:"updated_at"`
}]]></f><f p="models\user.go"><![CDATA[package models
type User struct {
 ID int64 `gorm:"primaryKey" json:"id"`
 UserName string `json:"username"`
 Timezone string `json:"timezone"`
}]]></f><f p="main.go"><![CDATA[package main
import (
 "FUCKYOULANGCHAIN/config"
 "FUCKYOULANGCHAIN/handler"
 "FUCKYOULANGCHAIN/logger"
 "context"
 "os"
 "os/signal"
 "github.com/go-telegram/bot"
)
func init() {
 logger.Init()
 config.LoadConfig()
}
func main() {
 ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt)
 defer cancel()
 opts := []bot.Option{
 bot.WithDefaultHandler(handler.DefaultHandler),
 bot.WithMiddlewares(handler.OnlyAdminMiddleware),
 }
 b, err := bot.New(config.AppConfig.TelegramAPIKey, opts...)
 if err != nil {
 logger.Log.Fatalf("Failed to create bot: %v", err)
 }
 b.Start(ctx)
}]]></f></repo>

Lets add here a state of user action, i.e when we do /timezone or we hit it due to registermiddleware, we record state in a  map with userid and based on that we know what the user response means and can act accordingly