package config

import (
	"github.com/BurntSushi/toml"
	"github.com/rs/zerolog/log"
	"os"
	"time"
)

type config struct {
	APIToken        string
	DebugMode       bool
	PrivilegedUsers []int64
	Shutup          map[int64]time.Time
	Balonlyl        struct {
		EnabledChats []int64
		BalonlylAT   string
		TriggerWords []string
	}
	GayPoints struct {
		EnabledChats []int64
		ModifyUsers  []int64
	}
	Download struct {
		Prefix string
		Yourls struct {
			APIPath   string
			Signature string
		}
	}
}

var BotConfig config

func LoadConfig() {

	configFile, err := os.ReadFile("config.toml")
	if err != nil {
		log.Panic().Err(err).Msg("rror opening config file")
	}

	_, err = toml.Decode(string(configFile), &BotConfig)
	if err != nil {
		log.Panic().Err(err).Msg("error decoding config file")
	}

	BotConfig.Shutup = make(map[int64]time.Time)

	log.Info().Msg("loaded config file")
	log.Debug().Interface("config", BotConfig).Msg("")

}