rssfeed

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package rssfeed runs in parallel to rssbot. It polls an RSS feed URL and sends formatted output to the IRC bot.

This file provides a simple, ordered cache with a limited length for RSS feed items.

Package rssfeed runs in parallel to rssbot. It polls an RSS feed URL and sends formatted output to the IRC bot.

This file handles polling of an individual RSS feed.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	Items  ItemMap
	Order  []string
	Length int
	// contains filtered or unexported fields
}

Cache contains saved feed items we don't want to display again.

func NewCache

func NewCache(length int) *Cache

NewCache creates a new, empty cache.

func (*Cache) Clean

func (c *Cache) Clean()

Clean removes old items from the cache.

func (*Cache) Exists

func (c *Cache) Exists(title string) bool

Exists checks whether an item exists in the cache.

func (*Cache) Save

func (c *Cache) Save(item *gofeed.Item)

Save saves items to the cache.

type ItemMap

type ItemMap map[string]*gofeed.Item

ItemMap is a map containing items by their title.

type Poller

type Poller struct {
	Bot    *rssbot.Bot
	Cache  *Cache
	Config *util.RSSConfig
	Logger *logrus.Logger
	Parser *gofeed.Parser

	// If true, the poller is on its first run and shouldn't announce the last
	// items from the feed.
	FirstRun bool
}

Poller contains details for polling RSS feeds.

func NewPoller

func NewPoller(config *util.RSSConfig, bot *rssbot.Bot, logger *logrus.Logger) *Poller

NewPoller sets up a new web poller for scraping the given RSS feed.

func (*Poller) Poll

func (p *Poller) Poll()

Poll polls the feed for new items. The user-provided delay is converted into minutes, and the poller waits that long between tries.

Jump to

Keyboard shortcuts

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