refactoring

This commit is contained in:
2026-01-19 16:55:33 +01:00
parent 197a01440c
commit 64750ef1c2
5 changed files with 83 additions and 63 deletions

View File

@@ -11,10 +11,6 @@ import (
"github.com/joho/godotenv"
)
type Fetcher interface {
Fetch() string
}
func Runner() {
if err := godotenv.Load(); err != nil {
log.Println("Warning: .env file not found, using environment variables")
@@ -42,13 +38,12 @@ func Runner() {
discord := DiscordSender{Config: config}
var fetchers []Fetcher
for _, repo := range config.GiteaRepos {
if repo == "" {
continue
}
giteaURL := fmt.Sprintf("%s/api/v1/repos/%s/commits", config.GiteaBaseURL, strings.TrimSpace(repo))
fetchers = append(fetchers, &GiteaFetcher{URL: giteaURL, Token: config.GiteaToken, Cache: &cache})
}
fetchers = append(fetchers, &GiteaFetcher{
BaseURL: config.GiteaBaseURL,
Token: config.GiteaToken,
Repos: config.GiteaRepos,
Cache: &cache,
})
fetchers = append(fetchers, &WikiFetcher{Config: config, Cache: &cache})
fetchers = append(fetchers, &RedmineFetcher{Config: config, Cache: &cache})
@@ -57,8 +52,11 @@ func Runner() {
fmt.Println("Update")
for _, f := range fetchers {
if msg := f.Fetch(); msg != "" {
discord.Send(msg)
if msg := f.Fetch(); len(msg) > 0 {
for _, m := range msg {
fmt.Println("Sending:", m)
discord.Send(m)
}
}
}