Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Error ¶ added in v1.5.0
type Error struct {
// contains filtered or unexported fields
}
Error is the error type for the Journalist.
func (*Error) WithProvider ¶ added in v1.5.0
type Journalist ¶
type Journalist struct { Name string // Name of the journalist (for logging purposes) // contains filtered or unexported fields }
Journalist is the main struct that fetches the news from all providers and merges them into unified list.
func NewJournalist ¶
func NewJournalist(name string, providers []NewsProvider) *Journalist
NewJournalist creates a new Journalist instance.
func (*Journalist) FlagByKeys ¶
func (j *Journalist) FlagByKeys(flagKeys []string) *Journalist
FlagByKeys sets the keys that will "flag" news that contain them by setting News.IsSuspicious to true.
func (*Journalist) GetLatestNews ¶
GetLatestNews fetches the latest news (until date) from all providers and merges them into unified list.
func (*Journalist) Limit ¶
func (j *Journalist) Limit(limit int) *Journalist
Limit sets the limit of news to fetch from each provider.
type News ¶
type News struct { ID string // ID is the md5 hash of title + description Title string // Title is the title of the news Description string // Description is the description of the news Link string // Link is the link to the news Date time.Time // Date is the date of the news ProviderName string // ProviderName is the Name of the provider that fetched the news IsSuspicious bool // IsSuspicious is true if the news contains keywords that should be checked by human before publishing IsFiltered bool // IsFiltered is true if the news was filtered out by others service (e.g. Composer.Filter) }
type NewsList ¶
type NewsList []*News
func (NewsList) RemoveFlagged ¶ added in v1.7.0
RemoveFlagged returns a new NewsList without the flagged (IsFiltered, IsSuspicious) news.
func (NewsList) ToContentJSON ¶
ToContentJSON returns the JSON of the news content only: id, title, description.
type NewsProvider ¶
NewsProvider is the interface for the data fetcher (via RSS, API, etc.).
type RssProvider ¶
RssProvider is the RSS provider implementation.
func NewRssProvider ¶
func NewRssProvider(name, url string) *RssProvider
NewRssProvider creates a new RssProvider instance.