const ServiceType = "rssbot"
ServiceType of the RSS Bot service
type Service struct {
types.DefaultService
// Feeds is a map of feed URL to configuration options for this feed.
Feeds map[string]struct {
// Optional. The time to wait between polls. If this is less than minPollingIntervalSeconds, it is ignored.
PollIntervalMins int `json:"poll_interval_mins"`
// The list of rooms to send feed updates into. This cannot be empty.
Rooms []string `json:"rooms"`
// True if rss bot is unable to poll this feed. This is populated by Go-NEB. Use /getService to
// retrieve this value.
IsFailing bool `json:"is_failing"`
// The time of the last successful poll. This is populated by Go-NEB. Use /getService to retrieve
// this value.
FeedUpdatedTimestampSecs int64 `json:"last_updated_ts_secs"`
// Internal field. When we should poll again.
NextPollTimestampSecs int64
// Internal field. The most recently seen GUIDs. Sized to the number of items in the feed.
RecentGUIDs []string
} `json:"feeds"`
}
Service contains the Config fields for this service.
Example request:
{
feeds: {
"http://rss.cnn.com/rss/edition.rss": {
poll_interval_mins: 60,
rooms: ["!cBrPbzWazCtlkMNQSF:localhost"]
},
"https://www.wired.com/feed/": {
rooms: ["!qmElAGdFYCHoCJuaNt:localhost"]
}
}
}
func (s *Service) OnPoll(cli *matrix.Client) time.Time
OnPoll rechecks RSS feeds which are due to be polled.
In order for a feed to be polled, the current time must be greater than NextPollTimestampSecs. In order for an item on a feed to be sent to Matrix, the item's GUID must not exist in RecentGUIDs. The GUID for an item is created according to the following rules:
- If there is a GUID field, use it. - Else if there is a Link field, use it as the GUID. - Else if there is a Title field, use it as the GUID.
Returns a timestamp representing when this Service should have OnPoll called again.
func (s *Service) PostRegister(oldService types.Service)
PostRegister deletes this service if there are no feeds remaining.
func (s *Service) Register(oldService types.Service, client *matrix.Client) error
Register will check the liveness of each RSS feed given. If all feeds check out okay, no error is returned.