package lib

import (
	"log"
	"os"
	"strconv"
	"time"

	"github.com/joho/godotenv"
)

type Config struct {
	WikiBaseURL         string
	WikiToken           string
	WikiContentLimit    int
	RedmineBaseURL      string
	RedmineKey          string
	RedmineContentLimit int
	GiteaToken          string
	GiteaBaseURL        string
	GiteaRepos          []string
	GiteaContentLimit   int
	DiscordWebhook      string
	DiscordFake         bool
	Interval            time.Duration
}

func envToInteger(key string, defaultValue int) int {
	valueStr := os.Getenv(key)
	if valueStr == "" {
		return defaultValue
	}
	value, err := strconv.Atoi(valueStr)
	if err != nil {
		return defaultValue
	}
	return value

}

func loadEnv() {
	if err := godotenv.Load(); err != nil {
		log.Println("Warning: .env file not found, using environment variables")
	}
}
