messenger

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CalendarSendDelay  = 300 * time.Millisecond // recommended delay between Calendar API calls
	CalendarMaxResults = 100
)
View Source
const (
	MailSendDelay = 300 * time.Millisecond
	MailSubject   = "Nova ocjena iz e-Dnevnika"
)
View Source
const (
	DiscordSendDelay = 150 * time.Millisecond // recommended delay between messages

)

Variables

View Source
var (
	ErrCalendarReadingCreds = errors.New("unable to read credentials file")
	ErrCalendarParsingCreds = errors.New("unable to parse credentials file")
	ErrCalendarNotFound     = errors.New("unable to find Google Calendar ID")
)
View Source
var (
	ErrDiscordEmptyAPIKey     = errors.New("empty Discord API key")
	ErrDiscordEmptyUserIds    = errors.New("empty list of Discord User IDs")
	ErrDiscordCreatingSession = errors.New("error creating Discord session")
	ErrDiscordCreatingChannel = errors.New("error creating Discord channel")
	ErrDiscordSendingMessage  = errors.New("error sending Discord message")
)
View Source
var (
	ErrMailSendingMessage = errors.New("error sending mail message")
	ErrMailInvalidPort    = errors.New("invalid or missing SMTP port, will try with default 465/tcp")
)
View Source
var (
	ErrSlackEmptyAPIKey    = errors.New("empty Slack API key")
	ErrSlackEmptyUserIds   = errors.New("empty list of Slack Chat IDs")
	ErrSlackSendingMessage = errors.New("error sending Slack message")
)
View Source
var (
	ErrTelegramEmptyAPIKey    = errors.New("empty Telegram API key")
	ErrTelegramEmptyUserIds   = errors.New("empty list of Telegram Chat IDs")
	ErrTelegramInvalidChatID  = errors.New("invalid Telegram Chat ID")
	ErrTelegramSendingMessage = errors.New("error sending Telegram message")
)

Functions

func Calendar added in v0.10.0

func Calendar(ctx context.Context, ch <-chan interface{}, name, tokFile, credFile string, retries uint) error

Calendar is a function that processes messages from a channel and creates events in Google Calendar.

It takes the following parameters: - ctx: the context.Context object for managing the execution of the function - ch: a channel for receiving messages - name: the name of the calendar - tokFile: the path to the token file - credFile: the path to the credential file - retries: the number of retry attempts for inserting a Google Calendar event

It returns an error indicating any issues encountered during the execution of the function.

func Discord

func Discord(ctx context.Context, ch <-chan interface{}, token string, userIDs []string, retries uint) error

Discord sends messages through the Discord API to the specified user IDs.

ctx: The context.Context that can be used to cancel the operation. ch: The channel from which to receive messages. token: The Discord API token. userIDs: The list of user IDs to send the messages to. retries: The number of attempts to send the message before giving up. Returns an error if there was a problem sending the message.

func Mail

func Mail(ctx context.Context, ch <-chan interface{}, server, port, username, password, from, subject string, to []string, retries uint) error

Mail sends a message through the mail service.

The function takes the following parameters: - ctx: the context.Context object for cancellation and timeouts. - ch: a channel from which messages are received. - server: the address of the mail server. - port: the port number for the mail server. - username: the username for authentication. - password: the password for authentication. - from: the email address of the sender. - subject: the subject of the email. - to: a slice of email addresses of the recipients. - retries: the number of retry attempts to send the message.

The function returns an error.

func Slack

func Slack(ctx context.Context, ch <-chan interface{}, token string, chatIDs []string, retries uint) error

Slack sends messages through the Slack API.

ctx: the context in which the function is executed. ch: the channel from which messages are received. token: the Slack API key. chatIDs: the IDs of the recipients. retries: the number of retries in case of failure. error: an error if there was a problem sending the message.

func Telegram

func Telegram(ctx context.Context, ch <-chan interface{}, apiKey string, chatIDs []string, retries uint) error

Telegram sends messages through the Telegram API.

It takes the following parameters: - ctx: the context.Context object for handling deadlines and cancellations. - ch: a channel for receiving messages to be sent. - apiKey: the API key for accessing the Telegram API. - chatIDs: a slice of strings containing the IDs of the chat recipients. - retries: the number of times to retry sending a message in case of failure.

It returns an error indicating any failures that occurred during the process.

Types

This section is empty.

Jump to

Keyboard shortcuts

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