Deutsch und Cleanup der Kanäle
release-tag / release-image (push) Successful in 2m8s

This commit is contained in:
2026-05-29 21:48:19 +02:00
parent 4d49c0af83
commit 720708f9d3
5 changed files with 221 additions and 33 deletions
+17
View File
@@ -3,7 +3,9 @@ package main
import (
"log"
"os"
"strconv"
"strings"
"time"
)
type Config struct {
@@ -16,6 +18,7 @@ type Config struct {
AdminRoleIDs []string
TeamRoleIDs []string
DatabasePath string
ThreadDeleteAfter time.Duration
}
func loadConfig() Config {
@@ -29,6 +32,7 @@ func loadConfig() Config {
AdminRoleIDs: splitCSV(os.Getenv("DISCORD_ADMIN_ROLE_IDS")),
TeamRoleIDs: splitCSV(os.Getenv("DISCORD_TEAM_ROLE_IDS")),
DatabasePath: getenv("DATABASE_PATH", "orders.db"),
ThreadDeleteAfter: durationHoursEnv("THREAD_DELETE_AFTER_HOURS", 72),
}
if cfg.Token == "" || cfg.AppID == "" || cfg.InternalOrderChannelID == "" {
log.Fatal("Bitte DISCORD_TOKEN, DISCORD_APP_ID und DISCORD_INTERNAL_ORDER_CHANNEL_ID setzen")
@@ -56,3 +60,16 @@ func splitCSV(v string) []string {
}
return out
}
func durationHoursEnv(key string, fallbackHours int) time.Duration {
v := strings.TrimSpace(os.Getenv(key))
if v == "" {
return time.Duration(fallbackHours) * time.Hour
}
hours, err := strconv.Atoi(v)
if err != nil || hours < 0 {
log.Printf("WARNUNG: %s ist ungültig, verwende %d Stunden", key, fallbackHours)
return time.Duration(fallbackHours) * time.Hour
}
return time.Duration(hours) * time.Hour
}