event

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2021 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Type           Type
	WebsiteName    string
	Message        string
	ProductID      string
	URL            string
	Date           time.Time
	ToTelegramChat []string
	Attributes     map[string]string
}

Event represents a poll event

func New

func New(eventType Type, websiteName string, opts ...Options) *Event

New generates a new event with the given options

type Options

type Options func(*Event)

Options represents an option to add to the event

func WithAttributes

func WithAttributes(attrs map[string]string) Options

WithAttributes adds map of attributes to the event

func WithCustomDate

func WithCustomDate(date time.Time) Options

WithCustomDate adds a date to the event

func WithCustomMessage

func WithCustomMessage(msg string) Options

WithCustomMessage adds a message to the event

func WithProductID

func WithProductID(id string) Options

WithProductID adds the product ID to the event

func WithTelegramNotification

func WithTelegramNotification(IDs ...string) Options

WithTelegramNotification adds a chat that must be notified with telegram

func WithURL

func WithURL(url string) Options

WithURL adds a URL to the event

type Type

type Type string

Type is the event type that this event represents

const (
	// EventGeneral is a general notification
	EventGeneral Type = "general"
	// EventUnexpected means that something unexpected happened to the poller
	EventUnexpected Type = "unexpected"
	// EventError means that an error happened during polling
	EventError Type = "error"
	// EventUnavailable means that the product is not available
	EventUnavailable Type = "unavailable"
	// EventSuccess means that a product is available
	EventSuccess Type = "available"
	// EventProbable means that a product is probably available
	EventProbable Type = "probable"
)

Jump to

Keyboard shortcuts

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