Documentation ¶
Index ¶
- type AltAcc
- type AltsTable
- func (at *AltsTable) AddAlt(owner string, playerID string, playerName string) error
- func (at *AltsTable) GetAllAlts() (result []AltAcc, err error)
- func (at *AltsTable) GetAlt(playerID string) (result AltAcc, err error)
- func (at *AltsTable) GetAltsOf(owner string) (result []AltAcc, err error)
- func (at *AltsTable) RemAlt(identifier string) error
- type AuthCode
- type AuthTable
- func (at *AuthTable) Authorize(authCode string) (playerID string, isOK bool)
- func (at *AuthTable) GetAllAuthCodes() (authCodes []AuthCode, err error)
- func (at *AuthTable) GetAuthCode(playerID string) (authCode string, err error)
- func (at *AuthTable) GetPlayerID(authCode string) (playerID string, err error)
- func (at *AuthTable) NewAuthCode(playerID string) (authCode string, err error)
- func (at *AuthTable) RemoveCode(authCode string) (err error)
- type Config
- type LinkedAcc
- type LinksTable
- func (lt *LinksTable) GetAllLinks() (linkedList []LinkedAcc, err error)
- func (lt *LinksTable) GetDiscordID(playerID string) (discordID string, err error)
- func (lt *LinksTable) GetPlayerID(discordID string) (playerID string, err error)
- func (lt *LinksTable) NewLink(discordID string, playerID string) error
- func (lt *LinksTable) SetLink(discordID, playerID string) error
- func (lt *LinksTable) UnLink(identifier string) error
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AltAcc ¶
type AltAcc struct { // The person who claimed the alt Owner string `json:"alt_owner" gorm:"column:owner;type:text;unique;not null"` // The ID of the alt account (this will be used for verifying) PlayerID string `json:"alt_id" gorm:"column:player_id;type:text;primary_key;not null"` // The name of the alt, this doesn't need to be consistent since it's mostly for listing without // reaching out to Mojang's API PlayerName string `json:"alt_name" gorm:"column:player_name;type:text;unique;not null"` }
AltAcc represents an alt account claimed by an admin.
type AltsTable ¶
type AltsTable struct {
// contains filtered or unexported fields
}
AltsTable - The Minecraft server administrators can use alt account management to claim Minecraft players as their alts. This will allow those players to join without authentication. This is super useful for mostly alts, but also any player you want to join without question. It will still check to see if the owner of the alt is authenticated which can only be done by administrators of the server.
func GetAltsTable ¶
GetAltsTable will initialize the table if it doesn't exist. It will then return AltsTable where other functions can access this database table.
func (*AltsTable) AddAlt ¶
AddAlt adds a new alt account. owner must be the owner player name. playerID must be the player's UUID. playerName must be the player's in-game name.
func (*AltsTable) GetAllAlts ¶
GetAllAlts will get all the alt accounts in the database.
func (*AltsTable) GetAlt ¶
GetAlt is used by bot/verify.go, it can get an alt account based on a playerID but if the alt doesn't exist all the attributes of AltAcc will be empty.
type AuthCode ¶
type AuthCode struct { // Pending authentication code AuthCode string `gorm:"column:auth_code;type:text;unique;not null"` // The Minecraft player associated with the pending code PlayerID string `gorm:"column:player_id;type:text;unique;not null"` }
AuthCode represents a pending authentication code stored in the database.
type AuthTable ¶
type AuthTable struct {
// contains filtered or unexported fields
}
AuthTable - Authentication codes are generated by (at *AuthTable) NewAuthCode() when a new player joins the Minecraft server. Players can redeem their authentication code through the Discord bot using the "auth" command. This is done through (bot *Bot) cmdAuth().
func GetAuthTable ¶
GetAuthTable will setup the table if it doesn't exist
func (*AuthTable) Authorize ¶
Authorize a given authentication code. It will return the player ID associated with the given auth code and the returned bool will be false.
func (*AuthTable) GetAllAuthCodes ¶
GetAllAuthCodes will get all the pending authentication codes in the table.
func (*AuthTable) GetAuthCode ¶
GetAuthCode will get a pending authentication code of a player UUID. If it doesn't exist than an empty string will be returned
func (*AuthTable) GetPlayerID ¶
GetPlayerID will the player ID associated with the given authentication code.
func (*AuthTable) NewAuthCode ¶
NewAuthCode will create a new authentication code for a given player UUID. If the player already has an authentication code then their pending one will be returned instead.
func (*AuthTable) RemoveCode ¶
RemoveCode will remove an authentication code given. The bool returned represents if the authentication code removed was removed.
type Config ¶
type Config struct { Host string `yaml:"host"` Port int `yaml:"port"` User string `yaml:"username"` Password string `yaml:"password"` Database string `yaml:"database_name"` MaxConnections int `yaml:"max_connections"` MaxIdleConnections int `yaml:"max_idle_connections"` ConnLifespan time.Duration `yaml:"conn_lifespan"` }
Config is a Postgres configuration.
type LinkedAcc ¶
type LinkedAcc struct { // Their Discord user ID (Twitter snowflake) DiscordID string `gorm:"column:discord_id;type:text;unique;not null"` // Their Minecraft UUID (without hyphens) PlayerID string `gorm:"column:player_id;type:text;unique;not null"` }
LinkedAcc represents a linked account for a Discord or Minecraft user.
type LinksTable ¶
type LinksTable struct {
// contains filtered or unexported fields
}
LinksTable - The account links feature mcauth is where the magic happens. Here Minecraft player UUID's (without hyphens) are associated with Discord user ID's (Twitter snowflakes). Once a user has been authenticated using their authentication code (see authcodes.go) they will be stored here with their Minecraft player UUID and Discord user ID on the same row entry
func GetLinksTable ¶
func GetLinksTable(gDB *gorm.DB) LinksTable
GetLinksTable will create the account_links table if it doesn't exist. it will return LinksTable which can be used to interface with the table.
func (*LinksTable) GetAllLinks ¶
func (lt *LinksTable) GetAllLinks() (linkedList []LinkedAcc, err error)
GetAllLinks will get all the linked accounts in the table.
func (*LinksTable) GetDiscordID ¶
func (lt *LinksTable) GetDiscordID(playerID string) (discordID string, err error)
GetDiscordID will get a Minecraft player's associated Discord user ID.
func (*LinksTable) GetPlayerID ¶
func (lt *LinksTable) GetPlayerID(discordID string) (playerID string, err error)
GetPlayerID will get a Discord user's associated Minecraft player UUID (without hyphens).
func (*LinksTable) NewLink ¶
func (lt *LinksTable) NewLink(discordID string, playerID string) error
NewLink establishes a new account link.
func (*LinksTable) SetLink ¶
func (lt *LinksTable) SetLink(discordID, playerID string) error
SetLink will set a link whether it exists or not.
func (*LinksTable) UnLink ¶
func (lt *LinksTable) UnLink(identifier string) error
UnLink will remove a link based on the given identifier. The identifier can be either their Discord user ID or Minecraft player UUID (without hyphens).
type Store ¶
type Store struct { Alts AltsTable Auth AuthTable Links LinksTable // contains filtered or unexported fields }
Store is the database. For more information about each table visit their file. This is where they're all grouped together.