29 lines
481 B
Go
29 lines
481 B
Go
package config
|
|
|
|
import (
|
|
toml "github.com/BurntSushi/toml"
|
|
)
|
|
|
|
type TelegramConfig struct {
|
|
APIKey string `toml:"api_key"`
|
|
AdminID string `toml:"admin_id"`
|
|
}
|
|
|
|
type StorageConfig struct {
|
|
Type string `toml:"type"`
|
|
Path string `toml:"path"`
|
|
}
|
|
|
|
type Config struct {
|
|
Telegram TelegramConfig
|
|
Storage StorageConfig
|
|
}
|
|
|
|
func LoadConfig(path string) (*Config, error) {
|
|
var cfg Config
|
|
_, err := toml.DecodeFile(path, &cfg)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &cfg, nil
|
|
}
|