rssbot

package
v0.0.0-...-f1068a2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 25, 2017 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package rssbot implements a Service capable of reading Atom/RSS feeds.

Index

Constants

View Source
const ServiceType = "rssbot"

ServiceType of the RSS Bot service

Variables

This section is empty.

Functions

This section is empty.

Types

type 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 (*Service) OnPoll

func (s *Service) OnPoll(cli *gomatrix.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 (*Service) PostRegister

func (s *Service) PostRegister(oldService types.Service)

PostRegister deletes this service if there are no feeds remaining.

func (*Service) Register

func (s *Service) Register(oldService types.Service, client *gomatrix.Client) error

Register will check the liveness of each RSS feed given. If all feeds check out okay, no error is returned.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL