fake discord feature

This commit is contained in:
2026-01-19 23:16:28 +01:00
parent a89c320106
commit cbd2695a81
3 changed files with 9 additions and 4 deletions

View File

@@ -10,6 +10,7 @@ type Config struct {
GiteaToken string
GiteaBaseURL string
GiteaRepos []string
Webhook string
DiscordWebhook string
DiscordFake bool
Interval time.Duration
}

View File

@@ -24,7 +24,8 @@ func getConfig() Config {
GiteaToken: os.Getenv("GITEA_TOKEN"),
GiteaBaseURL: os.Getenv("GITEA_BASE_URL"),
GiteaRepos: strings.Split(os.Getenv("GITEA_REPOS"), ","),
Webhook: os.Getenv("DISCORD_WEBHOOK"),
DiscordWebhook: os.Getenv("DISCORD_WEBHOOK"),
DiscordFake: os.Getenv("DISCORD_FAKE") == "true",
Interval: time.Duration(intervalMinutes) * time.Minute,
}
}
@@ -79,6 +80,6 @@ func Runner() {
cache.Save()
time.Sleep(config.Interval)
time.Sleep(100)
}
}

View File

@@ -12,5 +12,8 @@ type DiscordSender struct {
func (d DiscordSender) Send(msg string) {
b, _ := json.Marshal(map[string]string{"content": msg})
http.Post(d.Config.Webhook, "application/json", bytes.NewBuffer(b))
if d.Config.DiscordFake {
return
}
http.Post(d.Config.DiscordWebhook, "application/json", bytes.NewBuffer(b))
}