Compare commits

3 Commits

Author SHA1 Message Date
b0f0c587c9 main.go aktualisiert
All checks were successful
release-tag / release-image (push) Successful in 2m12s
build-binaries / build (, amd64, linux) (push) Has been skipped
build-binaries / build (, arm, 7, linux) (push) Has been skipped
build-binaries / build (, arm64, linux) (push) Has been skipped
build-binaries / build (.exe, amd64, windows) (push) Has been skipped
build-binaries / release (push) Has been skipped
2025-08-13 20:11:51 +00:00
fb62aaa7b8 Dockerfile aktualisiert
All checks were successful
release-tag / release-image (push) Successful in 2m0s
build-binaries / build (, amd64, linux) (push) Has been skipped
build-binaries / build (, arm, 7, linux) (push) Has been skipped
build-binaries / build (, arm64, linux) (push) Has been skipped
build-binaries / build (.exe, amd64, windows) (push) Has been skipped
build-binaries / release (push) Has been skipped
2025-08-13 18:16:31 +00:00
097ff306a9 Merge pull request 'Docker-Staging' (#1) from Docker-Staging into main
All checks were successful
release-tag / release-image (push) Successful in 2m6s
build-binaries / build (, amd64, linux) (push) Has been skipped
build-binaries / build (, arm, 7, linux) (push) Has been skipped
build-binaries / build (, arm64, linux) (push) Has been skipped
build-binaries / build (.exe, amd64, windows) (push) Has been skipped
build-binaries / release (push) Has been skipped
Reviewed-on: #1
2025-08-13 15:33:33 +00:00
2 changed files with 38 additions and 0 deletions

View File

@@ -30,5 +30,7 @@ ENV PRESENCE_GUILD_ID=0 \
TIMEOUT_MIN=1 \
DISCORD_TOKEN=0 \
TRANSLATIONS_FILE=/tempsrc/language.json
VOLUME /data
ENTRYPOINT ["/bin/vocalforge"]

36
main.go
View File

@@ -174,6 +174,19 @@ func initDB() {
addLanguageColumnIfNotExists()
ensureLobbyRuleTable()
_, _ = db.Exec(`
CREATE TABLE IF NOT EXISTS eventlog(
id INTEGER PRIMARY KEY AUTOINCREMENT,
guild_id TEXT NOT NULL,
type TEXT NOT NULL, -- z.B. 'vc_created' | 'vc_deleted' | 'member_moved'
channel_id TEXT,
user_id TEXT,
ts INTEGER NOT NULL, -- unix seconds
extra TEXT
);
CREATE INDEX IF NOT EXISTS idx_eventlog_guild_ts ON eventlog(guild_id, ts DESC);
`)
}
// Close DB connection
@@ -183,6 +196,21 @@ func closeDB() {
}
}
func logEvent(gid, typ, chID, userID string, extra any) {
if db == nil {
return
}
var extraJSON string
if extra != nil {
if b, err := json.Marshal(extra); err == nil {
extraJSON = string(b)
}
}
_, _ = db.Exec(`INSERT INTO eventlog(guild_id, type, channel_id, user_id, ts, extra)
VALUES(?,?,?,?,?,?)`,
gid, typ, chID, userID, time.Now().Unix(), extraJSON)
}
// Laden der Guild-Konfiguration mit Sprache
func loadGuildCfgs() error {
rows, err := db.Query("SELECT guild_id, lobby_name, category_name, timeout_min, language FROM guild_config")
@@ -500,6 +528,10 @@ func createPrivateVCAndMove(
})
if err != nil {
return nil, fmt.Errorf("VC-Anlage fehlgeschlagen: %w", err)
} else {
logEvent(guildID, "vc_created", newChan.ID, requesterID, map[string]any{
"name": newChan.Name, "timeout_min": timeoutMin,
})
}
// optionaler Move
@@ -532,6 +564,9 @@ func createPrivateVCAndMove(
if moveErr != nil {
log.Printf("Move endgültig fehlgeschlagen: %v", moveErr)
}
if moveErr == nil {
logEvent(guildID, "member_moved", newChan.ID, requesterID, nil)
}
}()
}
@@ -567,6 +602,7 @@ func watchAndCleanup(s *discordgo.Session, guildID, channelID string, timeout ti
if time.Since(lastActive) >= timeout {
_, _ = s.ChannelDelete(channelID)
log.Println(" Deleted channel for guildID: " + guildID + " with ID: " + channelID)
logEvent(guildID, "vc_deleted", channelID, "", nil)
return
}
}