acmregister

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: 7 Imported by: 0

Documentation

Index

Constants

View Source
const SubmissionSaveDuration = 1 * time.Hour

SubmissionSaveDuration is the duration to save submissions for.

Variables

View Source
var ErrMemberAlreadyExists = errors.New("a member with your information already exists, contact the server administrator")

ErrMemberAlreadyExists is returned if a member is being registered with an existing member's information.

View Source
var ErrNotFound = errors.New("not found")

ErrNotFound is returned if anything is not found.

View Source
var ErrUnknownPronouns = errors.New("unknown pronouns")

ErrUnknownPronouns is returned if a Pronouns is unknown. Use NewPronouns and check its error to ensure that it is never invalid.

Functions

This section is empty.

Types

type ContainsContext

type ContainsContext interface {
	WithContext(context.Context) ContainsContext
}

ContainsContext can be embedded by any interface to have an overrideable context.

type Email

type Email string

Email describes an email type.

func (Email) Split

func (e Email) Split() (username, hostname string, ok bool)

Split splits up the email into 2 parts.

func (Email) Username

func (e Email) Username() string

Username returns the username part of the email.

type EmailHostsVerifier

type EmailHostsVerifier []string

EmailHostsVerifier whitelists hosts allowed for the email.

func (EmailHostsVerifier) String

func (h EmailHostsVerifier) String() string

String returns a label string.

func (EmailHostsVerifier) VerifyEmail

func (h EmailHostsVerifier) VerifyEmail(email Email) error

type EmailVerifier

type EmailVerifier interface {
	VerifyEmail(ctx context.Context, email Email) error
}

EmailVerifier is used to verify email addresses' validity. Note that it's not meant to validate its authenticity.

type KnownGuild

type KnownGuild struct {
	GuildID           discord.GuildID
	ChannelID         discord.ChannelID
	RoleID            discord.RoleID
	InitUserID        discord.UserID
	RegisteredMessage string
	AdminRoleID       discord.RoleID // optional
}

type KnownGuildStore

type KnownGuildStore interface {
	ContainsContext
	// InitGuild initializes a guild.
	InitGuild(KnownGuild) error
	// GuildInfo returns the information about a registered guild.
	GuildInfo(discord.GuildID) (*KnownGuild, error)
	// GuildSetAdminRole sets the admin role for the given guild.
	// This is a field in KnownGuild that is optional.
	GuildSetAdminRole(discord.GuildID, discord.RoleID) error
	// DeleteGuild deletes the guild with the given ID from the registered
	// database.
	DeleteGuild(discord.GuildID) error
}

KnownGuildStore stores all known guilds, or guilds that are using the registration feature.

type Member

type Member struct {
	GuildID  discord.GuildID
	UserID   discord.UserID
	Metadata MemberMetadata
}

type MemberMetadata

type MemberMetadata struct {
	Email     Email    `json:"email"`
	FirstName string   `json:"first_name"`
	LastName  string   `json:"last_name"`
	Pronouns  Pronouns `json:"pronouns"`
}

func (MemberMetadata) Name

func (m MemberMetadata) Name() string

Name returns the first name and last if any.

func (MemberMetadata) Nickname

func (m MemberMetadata) Nickname() string

Nickname returns the nickname for the given member using their metadata.

type MemberStore

type MemberStore interface {
	ContainsContext
	// MemberInfo returns the member's info for the given user.
	MemberInfo(discord.GuildID, discord.UserID) (*MemberMetadata, error)
	// RegisterMember registers the given member into the store.
	RegisterMember(Member) error
	// UnregisterMember unregisters the given member from the store.
	UnregisterMember(discord.GuildID, discord.UserID) error
}

MemberStore stores all registered members.

type Pronouns

type Pronouns string

Pronouns describes a pronouns string in the format (they/them).

const (
	HeHim          Pronouns = "he/him"
	SheHer         Pronouns = "she/her"
	TheyThem       Pronouns = "they/them"
	AnyPronouns    Pronouns = "any"
	HiddenPronouns Pronouns = ""
)

func NewPronouns

func NewPronouns(pronouns string) (Pronouns, error)

NewPronouns creates a new Pronouns value. An error is returned if the pronouns are invalid.

func (Pronouns) Validate

func (p Pronouns) Validate() error

type Store

Store describes a Store instance. It combines all smaller stores.

type SubmissionStore

type SubmissionStore interface {
	ContainsContext
	// SaveSubmission temporarily saves a submission. The submission doesn't
	// have to be valid.
	SaveSubmission(Member) error
	// RestoreSubmission returns a saved submission.
	RestoreSubmission(discord.GuildID, discord.UserID) (*MemberMetadata, error)
}

SubmissionStore stores submissions for a short while so that forms can be temproarily stored.

Directories

Path Synopsis
Package env contains environment variable bindings to acmregister settings.
Package env contains environment variable bindings to acmregister settings.

Jump to

Keyboard shortcuts

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