bot

package
v0.0.0-...-db1ba95 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2024 License: ISC Imports: 24 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EmailSentFollowupData

func EmailSentFollowupData() *api.InteractionResponseData

EmailSentFollowupData creates an *api.InteractionResponseData to be used as a reply to notify the user that the email has been delivered.

func ErrorResponse

func ErrorResponse(err error) *api.InteractionResponse

ErrorResponse creates a new erroneous interaction response.

func ErrorResponseData

func ErrorResponseData(err error) *api.InteractionResponseData

ErrorResponseData creates a new erroneous interaction response data.

func InternalErrorResponse

func InternalErrorResponse() *api.InteractionResponse

InternalErrorResponse is used in case of confidential errors.

func InternalErrorResponseData

func InternalErrorResponseData() *api.InteractionResponseData

InternalErrorResponseData is used in case of confidential errors.

func SendConfirmationEmail

func SendConfirmationEmail(
	ctx context.Context, smtpVerifier *verifyemail.SMTPVerifier,
	c *Client, ev *discord.InteractionEvent, m acmregister.Member)

SendConfirmationEmail send a confirmation email then follows up to the interaction event.

Types

type Client

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

Client wraps around state.State for some common functionalities.

func NewClient

func NewClient(ctx context.Context, s *state.State) *Client

NewClient creates a new Client instance.

func (*Client) Context

func (c *Client) Context() context.Context

Context returns the internal context.

func (*Client) FollowUp

func (c *Client) FollowUp(ev *discord.InteractionEvent, data *api.InteractionResponseData)

FollowUp sends a followup response.

func (*Client) FollowUpInternalError

func (c *Client) FollowUpInternalError(ev *discord.InteractionEvent, err error)

FollowUpInternalError logs the error then follows up with an internal error message.

func (*Client) LogErr

func (c *Client) LogErr(guildID discord.GuildID, err error)

LogErr logs the given error to stdout. It attaches guild information if possible.

func (*Client) PrivateWarning

func (c *Client) PrivateWarning(ev *discord.InteractionEvent, sendErr error)

PrivateWarning is like PrivateErr, except the user does not get a reply back saying things have gone wrong. Use this if we don't intend to return after the error.

type ConfirmationEmailScheduler

type ConfirmationEmailScheduler interface {
	// ScheduleConfirmationEmail asynchronously schedules an email to be sent in
	// the background. It has no error reporting; the implementation is expected
	// to use the InteractionEvent to send a reply.
	ScheduleConfirmationEmail(c *Client, ev *discord.InteractionEvent, m acmregister.Member) error
	// Close cancels any scheduled jobs, if any.
	Close() error
}

ConfirmationEmailScheduler schedules a confirmation email to be sent and a follow-up to be notified to the user. To send this specific follow-up, use Handler.EmailSentFollowup.

func NewAsyncConfirmationEmailSender

func NewAsyncConfirmationEmailSender(smtpVerifier *verifyemail.SMTPVerifier) ConfirmationEmailScheduler

NewAsyncConfirmationEmailSender creates a new ConfirmationEmailScheduler. Its job is to send an email over SMTP and deliver a response within a goroutine.

type Handler

type Handler struct {
	Client
	// contains filtered or unexported fields
}

func NewHandler

func NewHandler(s *state.State, opts Opts) *Handler

NewHandler creates a new Handler instance bound to the given State.

func (*Handler) HandleInteraction

func (h *Handler) HandleInteraction(ev *discord.InteractionEvent) *api.InteractionResponse

func (*Handler) Intents

func (h *Handler) Intents() gateway.Intents

func (*Handler) OverwriteCommands

func (h *Handler) OverwriteCommands() error

OverwriteCommands overwrites the commands to the ones defined in Commands.

type Opts

type Opts struct {
	Store          acmregister.Store
	PINStore       verifyemail.PINStore           // optional
	EmailHosts     acmregister.EmailHostsVerifier // optional
	EmailVerifier  acmregister.EmailVerifier      // optional
	EmailScheduler ConfirmationEmailScheduler     // optional
}

Jump to

Keyboard shortcuts

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