multiple discord senders
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user