proc

package
v1.0.1-0...-ec039c9 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package proc provided the primary blocking loop updating from sources and making feeds

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanText

func CleanText(inp string, max int) string

CleanText removes html tags and shrinks result

func CropText

func CropText(inp string, max int) string

CropText shrinks the provided string, removing HTML tags in case it's exceeding the limit

Types

type BoltDB

type BoltDB struct {
	DB *bolt.DB
}

BoltDB store

func (BoltDB) Load

func (b BoltDB) Load(fmFeed string, max int, skipJunk bool) ([]feed.Item, error)

Load from bold for given feed, up to max

func (BoltDB) Save

func (b BoltDB) Save(fmFeed string, item feed.Item) (bool, error)

Save to bolt, skip if found

type DurationService

type DurationService interface {
	File(fname string) int
}

DurationService is the interface for reading duration from files

type Processor

type Processor struct {
	Conf          *config.Conf
	Store         *BoltDB
	TelegramNotif TelegramNotif
	TwitterNotif  TwitterNotif
}

Processor is a feed reader and store writer

func (*Processor) Do

func (p *Processor) Do(ctx context.Context) error

Do activate loop of goroutine for each feed, concurrency limited by p.Conf.Concurrent

type TelegramClient

type TelegramClient struct {
	Bot             *tb.Bot
	Timeout         time.Duration
	DurationService DurationService
	TelegramSender  TelegramSender
}

TelegramClient client

func NewTelegramClient

func NewTelegramClient(token, apiURL string, timeout time.Duration, ds DurationService, tgs TelegramSender) (*TelegramClient, error)

NewTelegramClient init telegram client

func (TelegramClient) Send

func (client TelegramClient) Send(channelID string, item feed.Item) (err error)

Send message, skip if telegram token empty

type TelegramNotif

type TelegramNotif interface {
	Send(chanID string, item feed.Item) error
}

TelegramNotif is interface to send messages to telegram

type TelegramSender

type TelegramSender interface {
	Send(tb.Audio, *tb.Bot, tb.Recipient, *tb.SendOptions) (*tb.Message, error)
}

TelegramSender is the interface for sending messages to telegram

type TelegramSenderImpl

type TelegramSenderImpl struct{}

TelegramSenderImpl is a TelegramSender implementation that sends messages to Telegram for real

func (*TelegramSenderImpl) Send

func (tg *TelegramSenderImpl) Send(audio tb.Audio, bot *tb.Bot, rcp tb.Recipient, opts *tb.SendOptions) (*tb.Message, error)

Send sends a message to Telegram

type TweetPoster

type TweetPoster interface {
	PostTweet(msg string, v url.Values) (tweet anaconda.Tweet, err error)
}

TweetPoster is the interface for posting Tweets to Twitter

type TwitterAuth

type TwitterAuth struct {
	ConsumerKey, ConsumerSecret string
	AccessToken, AccessSecret   string
}

TwitterAuth contains keys and secrets for twitter API

type TwitterClient

type TwitterClient struct {
	TwitterAuth
	// contains filtered or unexported fields
}

TwitterClient implements basic publisher of rss item to twitter

func NewTwitterClient

func NewTwitterClient(auth TwitterAuth, formatter func(feed.Item) string, twitterSender TweetPoster) *TwitterClient

NewTwitterClient makes twitter notifier

func (*TwitterClient) Send

func (t *TwitterClient) Send(item feed.Item) error

Send formatted item to twitter

type TwitterNotif

type TwitterNotif interface {
	Send(item feed.Item) error
}

TwitterNotif is interface to send message to twitter

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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