db

package
v0.0.0-...-2cb72f2 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DayFormat  = "Monday"
	HourFormat = "3PM"
	TimeFormat = DayFormat + " " + HourFormat

	ShowPrefix = "show:"
	HostSuffix = ":host"
	NameSuffix = ":name"

	ShowsEmbedChannel = "embed:shows:channel"
	ShowsEmbedMessage = "embed:shows:message"

	EmailToUser = "emails:%s:user"

	VerificationCodeToUser  = "verification:%s:user"
	VerificationCodeToEmail = "verification:%s:email"

	Custom = "custom:%s"
)

Variables

This section is empty.

Functions

func FillShowFromTransaction

func FillShowFromTransaction(show *Show, tx *buntdb.Tx) error

Obtains a show given a time, filling it in from a transaction.

Types

type Database

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

func Open

func Open(path string) (*Database, error)

func (*Database) CheckVerification

func (database *Database) CheckVerification(userID, code string) (bool, error)

Checks if a verification code for a user is valid.

func (*Database) Close

func (database *Database) Close() error

func (*Database) DeleteShow

func (database *Database) DeleteShow(day, hour string) error

Deletes a show from the database.

func (*Database) GetCustomString

func (database *Database) GetCustomString(key, fallback string) (string, error)

Gets some custom string stored in the database, returning the fallback if not found.

func (*Database) GetRawDatabase

func (database *Database) GetRawDatabase() *buntdb.DB

func (*Database) GetShow

func (database *Database) GetShow(day, hour string) (Show, error)

Gets a show from the database, given the time it starts.

func (*Database) GetShowsEmbed

func (database *Database) GetShowsEmbed() (string, string, error)

Gets the channel for the shows embed, if it has been set

func (*Database) InvalidateEmail

func (database *Database) InvalidateEmail(email string) (string, error)

Removes an email address from the database, returning the user ID of the user who held validation if it was found.

func (*Database) IsEmailRegistered

func (database *Database) IsEmailRegistered(email string) (bool, string, error)

Checks if an email is registered to a user, returning the user ID if it is.

func (*Database) PutShow

func (database *Database) PutShow(show Show) (Show, bool, error)

Puts a show into the database, returning the previous show if it existed.

func (*Database) SetShowsEmbed

func (database *Database) SetShowsEmbed(channelID, messageID string) (string, string, bool, error)

Sets the shows embed id, returning the old id if it exists.

func (*Database) StoreVerificationCode

func (database *Database) StoreVerificationCode(userID, email, code string) error

Stores a verification code for 15 minutes.

func (*Database) ValidateUser

func (database *Database) ValidateUser(userID, code string) error

Validates a user, storing their email in the emails database for future validation.

type Show

type Show struct {
	Hosts []string
	Day   string
	Hour  string
	Name  string
}

Represents a single show that is broadcast on STAR.

Jump to

Keyboard shortcuts

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