feed

package
v0.0.0-...-f2b64ca Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2021 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BroadCastConfig

type BroadCastConfig struct {

	// DB is used to query users to broadcast
	DB *gorm.DB

	// MemDB is used to store chat id
	MemDB *buntdb.DB

	// WorkerCount is used in concurrent broadcast
	WorkerCount int

	// FeedChannel is where feed item comes from
	FeedChannel <-chan *models.Feed

	// Bot is the bot which broadcaster broadcast to
	Bot *telebot.Bot

	// Logger is used to log events
	Logger log.Logger

	// Template is a string used to render text
	Template string

	// Telegraph is the config of telegraph module
	Telegraph *telegraph.Config
}

BroadCastConfig is used to config a broadcaster

type BroadCaster

type BroadCaster interface {
	Start()
	Stop()
}

BroadCaster receive item from channel and broadcast it to any user subscribe to it

func NewBroadcaster

func NewBroadcaster(c *BroadCastConfig) (BroadCaster, error)

NewBroadcaster generates new Broadcaster instance from config

type Poller

type Poller interface {
	Start() error
	Stop() error
	AddSource(s *models.Source) error
	RemoveSource(s *models.Source) error
	FetchTitle(url string) (string, error)
}

Poller get feed item from source and send it into feedChannel if it is new

func NewPoller

func NewPoller(c *PollerConfig) (Poller, error)

NewPoller creates a Poller according to the Config

type PollerConfig

type PollerConfig struct {
	SourcePool  []*models.Source
	DB          *buntdb.DB
	FeedChannel chan<- *models.Feed
	Logger      log.Logger
}

PollerConfig is the configuration needed to create a Poller

Jump to

Keyboard shortcuts

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