You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
677 B
Go
37 lines
677 B
Go
5 years ago
|
package handlers
|
||
|
|
||
|
import (
|
||
|
"hugobot/feeds"
|
||
|
"hugobot/posts"
|
||
|
"log"
|
||
|
"time"
|
||
|
)
|
||
|
|
||
|
type JobHandler interface {
|
||
|
// Main handling function
|
||
|
Handle(feeds.Feed) error
|
||
|
}
|
||
|
|
||
|
type FormatHandler interface {
|
||
|
FetchSince(url string, time time.Time) ([]*posts.Post, error)
|
||
|
JobHandler // Also implements a job handler
|
||
|
}
|
||
|
|
||
|
func GetFormatHandler(feed feeds.Feed) FormatHandler {
|
||
|
|
||
|
var handler FormatHandler
|
||
|
|
||
|
switch feed.Format {
|
||
|
case feeds.FormatRSS:
|
||
|
handler = NewRSSHandler()
|
||
|
case feeds.FormatRFC:
|
||
|
handler = NewRFCHandler()
|
||
|
case feeds.FormatGHRelease:
|
||
|
handler = NewGHReleaseHandler()
|
||
|
default:
|
||
|
log.Printf("WARNING: No format handler for %s", feed.FormatString)
|
||
|
}
|
||
|
|
||
|
return handler
|
||
|
}
|