fake discord feature
This commit is contained in:
@@ -10,6 +10,7 @@ type Config struct {
|
|||||||
GiteaToken string
|
GiteaToken string
|
||||||
GiteaBaseURL string
|
GiteaBaseURL string
|
||||||
GiteaRepos []string
|
GiteaRepos []string
|
||||||
Webhook string
|
DiscordWebhook string
|
||||||
|
DiscordFake bool
|
||||||
Interval time.Duration
|
Interval time.Duration
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ func getConfig() Config {
|
|||||||
GiteaToken: os.Getenv("GITEA_TOKEN"),
|
GiteaToken: os.Getenv("GITEA_TOKEN"),
|
||||||
GiteaBaseURL: os.Getenv("GITEA_BASE_URL"),
|
GiteaBaseURL: os.Getenv("GITEA_BASE_URL"),
|
||||||
GiteaRepos: strings.Split(os.Getenv("GITEA_REPOS"), ","),
|
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,
|
Interval: time.Duration(intervalMinutes) * time.Minute,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -79,6 +80,6 @@ func Runner() {
|
|||||||
|
|
||||||
cache.Save()
|
cache.Save()
|
||||||
|
|
||||||
time.Sleep(config.Interval)
|
time.Sleep(100)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,5 +12,8 @@ type DiscordSender struct {
|
|||||||
|
|
||||||
func (d DiscordSender) Send(msg string) {
|
func (d DiscordSender) Send(msg string) {
|
||||||
b, _ := json.Marshal(map[string]string{"content": msg})
|
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))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user