scraper

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithHistoryFromDate

func WithHistoryFromDate(historyFromDate time.Time) func(*TgScraper)

WithHistoryFromDate sets the date from which to start fetching history. Default is the date 2 days ago.

func WithUpdateDiscardTimeout

func WithUpdateDiscardTimeout(timeout time.Duration) func(*TgScraper)

WithUpdateDiscardTimeout sets the timeout for discarding updates if UpdateChan() is full. Default is 0, meaning updates won't be discarded, but the whole processing may be blocked if receiver is too slow.

Types

type AlertData

type AlertData struct {
	// contains filtered or unexported fields
}

AlertData holds the raid status information for all regions.

func (*AlertData) GetAll added in v0.1.3

func (r *AlertData) GetAll() []Status

GetAll retrieves the alert statuses for all regions

func (*AlertData) GetByRegion

func (r *AlertData) GetByRegion(id region.ID) (Status, error)

GetByRegion retrieves the alert status for a specific region. Returns an error if the region is invalid.

type Status

type Status struct {
	Region    region.ID
	Enabled   bool
	UpdatedAt time.Time
	IsHistory bool // if this is true UpdatedAt may be inaccurate (zero)
}

Status represents the alert status for a region.

type TgClient

type TgClient interface {
	GetChatHistory(req *client.GetChatHistoryRequest) (*client.Messages, error)
	GetListener() *client.Listener
}

type TgScraper

type TgScraper struct {
	// contains filtered or unexported fields
}

TgScraper is a struct that handles scraping alert status updates from a Telegram channel. It provides methods to run the scraper, retrieve alert data, and get real-time status updates.

func NewTgScraper

func NewTgScraper(client TgClient, opts ...func(*TgScraper)) *TgScraper

NewTgScraper creates a TgScraper with the given TgClient and optional settings.

func (*TgScraper) AlertData

func (r *TgScraper) AlertData() *AlertData

AlertData returns current alert statuses.

func (*TgScraper) Run

func (r *TgScraper) Run(ctx context.Context) error

Run starts the scraper.

func (*TgScraper) UpdatesChan

func (r *TgScraper) UpdatesChan() <-chan Status

UpdatesChan returns a channel with real-time status updates.

func (*TgScraper) WaitForHistory

func (r *TgScraper) WaitForHistory(ctx context.Context) error

WaitForHistory blocks until historical data has been fetched.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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