multiple discord senders

This commit is contained in:
2026-01-20 20:58:18 +01:00
parent 76933a04d8
commit 53e6eecb3f
9 changed files with 100 additions and 69 deletions

View File

@@ -7,16 +7,10 @@ import (
"net/http"
)
// Entry represents a single fetched item.
type Entry struct {
Title string
URL string
}
// Fetcher is the interface for a fetcher.
type Fetcher interface {
Name() string
Fetch() []Entry
Fetch() []Message
}
// BaseFetcher contains common fields for all fetchers.
@@ -27,10 +21,14 @@ type BaseFetcher struct {
ContentLimit int
}
// TryCreateEntry checks the cache and creates an Entry if the value has changed.
func (b *BaseFetcher) TryCreateEntry(cacheKey, cacheValue, title, url string) *Entry {
// TryCreateMessage checks the cache and creates a Message if the value has changed.
func (b *BaseFetcher) TryCreateMessage(channel, cacheKey, cacheValue, title, url string) *Message {
if b.Cache.TryUpdate(cacheKey, cacheValue) {
return &Entry{Title: title, URL: url}
return &Message{
Channel: channel,
Title: title,
URL: url,
}
}
return nil
}