.機能追加、DBバグ修正

This commit is contained in:
2026-01-05 11:27:37 +09:00
parent 7d3da1bf2e
commit b2fbb472df
19 changed files with 1619 additions and 56 deletions

View File

@@ -17,6 +17,10 @@ type DatabaseConfig struct {
Name string
}
type NotificationConfig struct {
TelegramBotToken string
}
type Config struct {
Port string
SessionSecret string
@@ -29,6 +33,7 @@ type Config struct {
RateLimitWindow int
TrustedProxies []string
Database DatabaseConfig
Notification NotificationConfig
}
func Load(configPath string) *Config {
@@ -123,6 +128,12 @@ func Load(configPath string) *Config {
cfg.TrustedProxies = []string{proxies}
}
}
// Notification section
section = iniFile.Section("notification")
if section.HasKey("telegram_bot_token") {
cfg.Notification.TelegramBotToken = section.Key("telegram_bot_token").String()
}
} else {
log.Println("config.ini not found, using environment variables or defaults")
}
@@ -169,6 +180,9 @@ func Load(configPath string) *Config {
if trustedProxies := os.Getenv("TRUSTED_PROXIES"); trustedProxies != "" {
cfg.TrustedProxies = []string{trustedProxies}
}
if telegramToken := os.Getenv("TELEGRAM_BOT_TOKEN"); telegramToken != "" {
cfg.Notification.TelegramBotToken = telegramToken
}
if cfg.SessionSecret == "" {
log.Fatal("FATAL: Session secret is not set. Please set it in config.ini ([session] secret) or via SESSION_SECRET environment variable.")