Documentation ¶
Index ¶
- Constants
- Variables
- func Calendar(ctx context.Context, ch <-chan interface{}, name, tokFile, credFile string, ...) error
- func Discord(ctx context.Context, ch <-chan interface{}, token string, userIDs []string, ...) error
- func Mail(ctx context.Context, ch <-chan interface{}, ...) error
- func Slack(ctx context.Context, ch <-chan interface{}, token string, chatIDs []string, ...) error
- func Telegram(ctx context.Context, ch <-chan interface{}, apiKey string, chatIDs []string, ...) error
Constants ¶
const ( CalendarSendDelay = 200 * time.Millisecond // recommended delay between Calendar API calls CalendarMaxResults = 200 )
const ( MailSendDelay = 50 * time.Millisecond MailSubject = "Nova ocjena iz e-Dnevnika" )
const (
DiscordSendDelay = 50 * time.Millisecond // recommended delay between messages
)
Variables ¶
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") )
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") )
var ( ErrMailSendingMessage = errors.New("error sending mail message") ErrMailInvalidPort = errors.New("invalid or missing SMTP port, will try with default 465/tcp") )
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.