farmerstate

package
v0.0.0-...-397c195 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: Unlicense Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ActAsForeverExpiry = time.Date(9999, 12, 31, 23, 59, 59, 0, time.UTC)

ActAsForeverExpiry represents an indefinite/forever expiration time for an act-as switch.

Functions

func AddActAsLink(mainUserID, altUserID string) error

AddActAsLink links altUserID as an alternate account for mainUserID.

func AddGuildMembership

func AddGuildMembership(userID, guildID string) bool

AddGuildMembership adds a user to a guild. Returns true if added, false if already a member.

func AddRecentCoopID

func AddRecentCoopID(userID string, coopID string)

AddRecentCoopID adds a coop ID to the recent list (max 5)

func AddTimer

func AddTimer(id, userID, channelID, msgID string, reminder time.Time, message string, duration int64, origChannelID, origMsgID string, active bool)

AddTimer inserts a new timer into the database.

func AddWatch

func AddWatch(userID, watchType, targetID string)

AddWatch inserts a new watch into the database.

func ClearActAsSwitch

func ClearActAsSwitch(mainUserID, channelID string) error

ClearActAsSwitch removes the active act-as switch for mainUserID in channelID.

func ClearAllActAsSwitches

func ClearAllActAsSwitches(mainUserID string) error

ClearAllActAsSwitches removes all active act-as switches for mainUserID across all channels.

func ClearEphemeralMessageSwitch

func ClearEphemeralMessageSwitch(messageID string)

ClearEphemeralMessageSwitch removes the ephemeral message switch mapping.

func ClearPendingActAsRegistration

func ClearPendingActAsRegistration(mainUserID string)

ClearPendingActAsRegistration removes a pending registration entry.

func ClearUltra

func ClearUltra(userID string)

ClearUltra clears a player's ultra status.

func DeleteAllActAsLinks(userID string) error

DeleteAllActAsLinks removes all links involving userID.

func DeleteAllLeaderboardExclusionsForUserInGuild

func DeleteAllLeaderboardExclusionsForUserInGuild(guildID, userID string) error

DeleteAllLeaderboardExclusionsForUserInGuild removes all exclusions for a user in a specific guild.

func DeleteAllLeaderboardOptInsForUserInGuild

func DeleteAllLeaderboardOptInsForUserInGuild(guildID, userID string) error

DeleteAllLeaderboardOptInsForUserInGuild removes all opt-ins for a user in a specific guild.

func DeleteAllLeaderboardStatsForPlayer

func DeleteAllLeaderboardStatsForPlayer(player string) error

DeleteAllLeaderboardStatsForPlayer removes every leaderboard stat for a player globally.

func DeleteAllLeaderboardStatsForPlayerInGuild

func DeleteAllLeaderboardStatsForPlayerInGuild(player, guildID string) error

DeleteAllLeaderboardStatsForPlayerInGuild is a no-op since leaderboard_stats is now global.

func DeleteFarmer

func DeleteFarmer(userID string)

DeleteFarmer deletes a Farmer from the map and SQLite database tables

func DeleteInactiveTimers

func DeleteInactiveTimers()

DeleteInactiveTimers removes all inactive timers from the database.

func DeleteLeaderboardExclusion

func DeleteLeaderboardExclusion(guildID, userID, lbType string) error

DeleteLeaderboardExclusion removes a specific leaderboard exclusion record.

func DeleteLeaderboardOptIn

func DeleteLeaderboardOptIn(guildID, userID, lbType string) error

DeleteLeaderboardOptIn removes a specific leaderboard opt-in record.

func DeleteLeaderboardStatsForPlayer

func DeleteLeaderboardStatsForPlayer(player, lbType string) error

DeleteLeaderboardStatsForPlayer removes snapshots for a specific player and type.

func DeleteTimer

func DeleteTimer(id string)

DeleteTimer removes a timer from the database by its ID.

func DeleteUserWatches

func DeleteUserWatches(userID string)

DeleteUserWatches deletes all watches for a given user.

func DeleteWatch

func DeleteWatch(userID, watchType, targetID string)

DeleteWatch deletes a specific watch.

func FarmerExists

func FarmerExists(userID string) bool

FarmerExists returns true if a record for the given userID exists in farmer_state.

func FindAltDiscordID

func FindAltDiscordID(altID string, callerIDs ...string) string

FindAltDiscordID returns the registered Discord user ID for an alt, if any. It checks direct Discord snowflake IDs, discord_id settings, exact in-game name matches in farmer state, and /act-as account links for the alt or its controller.

func FlushPendingSaves

func FlushPendingSaves()

FlushPendingSaves forces an immediate write of all pending database updates.

func GetActAsLinks(mainUserID string) []string

GetActAsLinks returns all alternate account user IDs linked to mainUserID.

func GetActAsMains

func GetActAsMains(altUserID string) []string

GetActAsMains returns all main user IDs that have linked altUserID as an alternate.

func GetActAsSwitch

func GetActAsSwitch(mainUserID, channelID string) (altUserID string, expiresAt time.Time, active bool)

GetActAsSwitch returns the active switch if unexpired and valid for channelID.

func GetAllActAsLinkedUsers

func GetAllActAsLinkedUsers(userID string) []string

GetAllActAsLinkedUsers returns all user IDs linked with userID in either direction.

func GetAltControllerByMiscString

func GetAltControllerByMiscString(key, value string) []string

GetAltControllerByMiscString returns all IDs for farmers where MiscSettingsString[key] == value.

func GetDiscordUserIDFromEggIncName

func GetDiscordUserIDFromEggIncName(eggIncName string) (string, error)

GetDiscordUserIDFromEggIncName retrieves the Discord user ID based on the provided eggincname. It also checks if the account is an alternate and returns the parent's Discord ID if so.

func GetDiscordUserIDFromEiIgn

func GetDiscordUserIDFromEiIgn(eiIgn string) (string, error)

GetDiscordUserIDFromEiIgn retrieves the Discord user ID based on the provided ei_ign. It also checks if the account is an alternate and returns the parent's Discord ID if so.

func GetDiscordUserIDFromEiIgnExact

func GetDiscordUserIDFromEiIgnExact(eiIgn string) (string, error)

GetDiscordUserIDFromEiIgnExact retrieves the Discord user ID based on the provided ei_ign without collapsing alternate accounts back to their controller.

func GetEffectiveUserID

func GetEffectiveUserID(userID string, contextIDs ...string) string

GetEffectiveUserID returns altUserID if mainUserID has an active, unexpired switch in any of contextIDs; otherwise mainUserID. Checks ephemeral message switch registrations first, then channel/thread switches.

func GetEffectiveUserIDAndExpiry

func GetEffectiveUserIDAndExpiry(userID string, contextIDs ...string) (effectiveID string, expiresAt time.Time, isActingAs bool)

GetEffectiveUserIDAndExpiry returns the effective user ID, switch expiry, and whether an active switch is in place. Checks ephemeral message switch registrations first, then channel/thread switches.

func GetEggIncName

func GetEggIncName(userID string) string

GetEggIncName returns a Farmer Egg Inc name

func GetEiIgnsByGuild

func GetEiIgnsByGuild(guildID string) []string

GetEiIgnsByGuild returns all ei_ign values for farmers who are members of the given guild.

func GetEiIgnsByMiscString

func GetEiIgnsByMiscString(key, value string) []string

GetEiIgnsByMiscString returns all ei_ign values for farmers where MiscSettingsString[key] == value.

func GetEphemeralMessageSwitch

func GetEphemeralMessageSwitch(messageID string) (string, bool)

GetEphemeralMessageSwitch returns the altUserID if the message was launched under an act-as switch.

func GetGuildMembers

func GetGuildMembers(guildID string) []string

GetGuildMembers returns all user IDs that are members of the given guild.

func GetLastSeen

func GetLastSeen(userID string) time.Time

GetLastSeen returns the last time a farmer was added to a contract

func GetLatestLeaderboardSnapDate

func GetLatestLeaderboardSnapDate(lbType string) (string, error)

GetLatestLeaderboardSnapDate returns the most recent snap_date for a lb_type.

func GetLaunchHistory

func GetLaunchHistory(userID string) bool

GetLaunchHistory returns a Farmer Launch History

func GetLeaderboardOptInGuilds

func GetLeaderboardOptInGuilds() ([]string, error)

GetLeaderboardOptInGuilds returns all distinct guild IDs that have at least one opt-in.

func GetLeaderboardOptInUsers

func GetLeaderboardOptInUsers() ([]string, error)

GetLeaderboardOptInUsers returns all Discord user IDs who have at least one opt-in in any guild.

func GetLeaderboardSnapDates

func GetLeaderboardSnapDates(lbType string) ([]string, error)

GetLeaderboardSnapDates returns all distinct snap_dates for a lb_type, newest first.

func GetLinkedAltIDs

func GetLinkedAltIDs(callerID string) []string

GetLinkedAltIDs returns all unique alternate account IDs linked to callerID.

func GetLinks(userID string) []string

GetLinks will return a slice of bookmark links

func GetMiscSettingFlag

func GetMiscSettingFlag(userID string, key string) bool

GetMiscSettingFlag returns a Farmer sticky setting

func GetMiscSettingString

func GetMiscSettingString(userID string, key string) string

GetMiscSettingString returns a Farmer sticky setting

func GetMissionShipPrimary

func GetMissionShipPrimary(userID string) int

GetMissionShipPrimary returns a Farmer Mission Ship Primary

func GetMissionShipSecondary

func GetMissionShipSecondary(userID string) int

GetMissionShipSecondary returns a Farmer Mission Ship Secondary

func GetPendingActAsRegistration

func GetPendingActAsRegistration(mainUserID string) (pendingActAsRegistration, bool)

GetPendingActAsRegistration retrieves a pending registration if not expired.

func GetPermitLevel

func GetPermitLevel(userID string) uint32

GetPermitLevel returns a player's permit level (0 for standard, 1 for pro; defaults to 1 / Pro if unset).

func GetPing

func GetPing(userID string) bool

GetPing returns a Farmer's ping preference

func GetRecentCoopIDs

func GetRecentCoopIDs(userID string) []string

GetRecentCoopIDs returns the list of recently used coop IDs

func GetSlashActAsCommand

func GetSlashActAsCommand(cmd string) *dc.Command

GetSlashActAsCommand returns the slash command definition for /act-as.

func GetSlashPrivacyCommand

func GetSlashPrivacyCommand(cmd string) *dc.Command

GetSlashPrivacyCommand creates a new slash command for setting Egg, Inc name

func GetTokens

func GetTokens(userID string) int

GetTokens returns a Farmer's tokens

func GetUserEggIncID

func GetUserEggIncID(userID string) string

GetUserEggIncID returns the decrypted Egg Inc ID for a user or alt.

func GetUserGuilds

func GetUserGuilds(userID string) []string

GetUserGuilds returns all guild IDs the user belongs to.

func HandleActAsAutocomplete

func HandleActAsAutocomplete(e *dc.AutocompleteEvent)

HandleActAsAutocomplete provides autocomplete suggestions for /act-as subcommands.

func HandleActAsCommand

func HandleActAsCommand(client dc.Client, e *dc.CommandEvent)

HandleActAsCommand routes subcommands for /act-as. Note: /act-as always resolves e.UserID() as the real user and never applies act-as mapping.

func HandleActAsRegisterModalSubmit

func HandleActAsRegisterModalSubmit(client dc.Client, e *dc.ModalEvent)

HandleActAsRegisterModalSubmit processes the submitted verification code modal.

func HandlePrivacy

func HandlePrivacy(e *dc.CommandEvent)

HandlePrivacy will handle the /privacy command through the dc facade.

func HandlePrivacyAutocomplete

func HandlePrivacyAutocomplete(e *dc.AutocompleteEvent)

HandlePrivacyAutocomplete provides autocomplete suggestions for the alt option on /privacy.

func HandlePrivacyButton

func HandlePrivacyButton(e *dc.ComponentEvent)

HandlePrivacyButton handles DELETE and KEEP confirmation button clicks for /privacy data removal.

func HandleSetEggIncName

func HandleSetEggIncName(client dc.Client, e *dc.CommandEvent, isCoordinator func(dc.Client, string) bool)

HandleSetEggIncName handles the /seteggincname command

func HasProPermit

func HasProPermit(userID string) bool

HasProPermit returns true if the player has the Pro Permit (permit level == 1).

func InsertSuspectMission

func InsertSuspectMission(arg InsertSuspectMissionParams) error

InsertSuspectMission records a suspect mission anomaly to the database.

func IsActAsForever

func IsActAsForever(exp time.Time) bool

IsActAsForever reports whether exp indicates a switch that does not expire.

func IsActAsLinked

func IsActAsLinked(mainUserID, altUserID string) bool

IsActAsLinked reports whether altUserID is currently linked to mainUserID.

func IsActAsLinkedEither

func IsActAsLinkedEither(u1, u2 string) bool

IsActAsLinkedEither reports whether u1 and u2 are linked in either direction.

func IsDiscordSnowflake

func IsDiscordSnowflake(s string) bool

IsDiscordSnowflake reports whether s looks like a Discord snowflake ID (17-20 digits).

func IsUltra

func IsUltra(userID string) bool

IsUltra will return if a player has joined an ultra contract in last 60 days, or has an active Ultra subscription.

func MoveActAsSwitch

func MoveActAsSwitch(mainUserID, fromChannelID, toChannelID string) error

MoveActAsSwitch transfers an active act-as switch for mainUserID from fromChannelID to toChannelID, preserving expiry.

func MoveActAsSwitchWithExpiry

func MoveActAsSwitchWithExpiry(mainUserID, fromChannelID, toChannelID string, newExpiry time.Time) error

MoveActAsSwitchWithExpiry transfers an active act-as switch for mainUserID from fromChannelID to toChannelID with a new expiry.

func PruneOlderLeaderboardStatsForPlayer

func PruneOlderLeaderboardStatsForPlayer(lbType, player, keepSnapDate string) error

PruneOlderLeaderboardStatsForPlayer removes older leaderboard stats for a specific player and type.

func PurgeAltLinks(mainUserID, altUserID string)

PurgeAltLinks removes all act-as links, switches, and alt-controller associations for altUserID.

func ReencryptFarmerEIDs

func ReencryptFarmerEIDs(oldKeyB64, newKeyB64 string) (int, int, error)

ReencryptFarmerEIDs safely migrates all encrypted Egg Inc IDs in farmer_state from oldKeyB64 to newKeyB64. It returns the number of successfully migrated records and the total number of records that contained an encrypted EID.

func RegisterEphemeralMessageSwitch

func RegisterEphemeralMessageSwitch(messageID, mainUserID, altUserID string)

RegisterEphemeralMessageSwitch records that an ephemeral response message was created while acting as altUserID.

func RemoveActAsLink(mainUserID, altUserID string) error

RemoveActAsLink removes the link between mainUserID and altUserID.

func RemoveCustomBanner

func RemoveCustomBanner(userID string, guildID string) error

RemoveCustomBanner deletes a user's custom banner from the database.

func RemoveGuildMembership

func RemoveGuildMembership(userID, guildID string)

RemoveGuildMembership removes a user from a guild.

func ResolveAltSelection

func ResolveAltSelection(userID string, altParam string, cmdName string) (targetID string, eggIncID string, notice string)

ResolveAltSelection determines which user ID and Egg Inc ID to display, along with any informational message.

func SetActAsSwitch

func SetActAsSwitch(mainUserID, channelID, altUserID string, expiresAt time.Time) error

SetActAsSwitch sets an active act-as switch for mainUserID in channelID until expiresAt.

func SetCustomBanner

func SetCustomBanner(userID string, guildID string, imageData []byte) error

SetCustomBanner saves a user's custom banner PNG bytes into the database.

func SetEggIncName

func SetEggIncName(userID string, eggIncName string)

SetEggIncName sets a Farmer Egg Inc name

func SetFarmerBackupDetails

func SetFarmerBackupDetails(userID string, backup *ei.Backup) (newIGN string, ignChanged bool, newTE uint32, teChanged bool)

SetFarmerBackupDetails updates the player's saved game name ("ei_ign"), Truth Eggs ("TE"), Ultra status, and Permit Level from their Egg Inc backup. It returns the updated game name, whether the name changed, the updated Truth Egg count, and whether the Truth Egg count changed.

func SetLastSeen

func SetLastSeen(userID string)

SetLastSeen updates the timestamp of the last time a farmer was added to a contract

func SetLaunchHistory

func SetLaunchHistory(userID string, setting bool)

SetLaunchHistory sets a Farmer Launch History

func SetLink(userID string, description string, guildID string, channelID string, messageID string)

SetLink will store a link for a user

func SetMiscSettingFlag

func SetMiscSettingFlag(userID string, key string, value bool)

SetMiscSettingFlag sets a key-value sticky setting

func SetMiscSettingString

func SetMiscSettingString(userID string, key string, value string)

SetMiscSettingString sets a key-value sticky setting

func SetMissionShipPrimary

func SetMissionShipPrimary(userID string, setting int)

SetMissionShipPrimary sets a Farmer Mission Ship Primary

func SetMissionShipSecondary

func SetMissionShipSecondary(userID string, setting int)

SetMissionShipSecondary sets a Farmer Mission Ship Secondary

func SetPermitLevel

func SetPermitLevel(userID string, level uint32)

SetPermitLevel sets a player's permit level (0 for standard, 1 for pro).

func SetPing

func SetPing(userID string, ping bool)

SetPing sets a Farmer's ping preference

func SetTokens

func SetTokens(userID string, tokens int)

SetTokens sets a Farmer's tokens

func SetUltra

func SetUltra(userID string, isUltra ...bool)

SetUltra sets whether a player is an ultra player. An optional boolean parameter specifies the ultra status (defaults to true).

func SlashSetEggIncNameCommand

func SlashSetEggIncNameCommand(cmd string) *dc.Command

SlashSetEggIncNameCommand creates a new slash command for setting Egg, Inc name

func StorePendingActAsRegistration

func StorePendingActAsRegistration(mainUserID, altUserID, code string, ttl time.Duration)

StorePendingActAsRegistration saves a pending verification code for account linking.

func SyncCustomBanner

func SyncCustomBanner(userID string, guildID string, destPath string) bool

SyncCustomBanner checks if a custom banner exists in the database and is newer than the file on disk. If it is, it writes the image data from the database to the specified path.

func UpdateTimerMsg

func UpdateTimerMsg(id, channelID, msgID string)

UpdateTimerMsg updates the channel and message ID of a timer in the database.

func UpdateTimerState

func UpdateTimerState(id string, active bool)

UpdateTimerState updates the active state of a timer in the database.

func UpsertLeaderboardExclusion

func UpsertLeaderboardExclusion(guildID, userID, lbType string) error

UpsertLeaderboardExclusion adds a leaderboard exclusion record for a user in a guild.

func UpsertLeaderboardOptIn

func UpsertLeaderboardOptIn(guildID, userID, lbType string) error

UpsertLeaderboardOptIn adds a leaderboard opt-in record for a user in a guild.

func UpsertLeaderboardStat

func UpsertLeaderboardStat(lbType, player, gameName, snapDate string, value float64, details sql.NullString) error

UpsertLeaderboardStat saves one leaderboard snapshot row (upsert on primary key).

Types

type ActAsLink struct {
	MainUserID string
	AltUserID  string
	CreatedAt  time.Time
}

type ActAsSwitch

type ActAsSwitch struct {
	MainUserID string
	ChannelID  string
	AltUserID  string
	ExpiresAt  time.Time
}

type AddGuildMembershipParams

type AddGuildMembershipParams struct {
	UserID  string
	GuildID string
}

type AltAccount

type AltAccount struct {
	ID          string
	IGN         string
	DisplayName string
	EggIncID    string
}

AltAccount holds identification and display info for an alternate account.

func GetUserAltsWithSavedEID

func GetUserAltsWithSavedEID(userID string) []AltAccount

GetUserAltsWithSavedEID returns all registered alternate accounts for userID that have a saved Egg Inc ID.

type CustomBanner

type CustomBanner struct {
	UserID    string
	GuildID   string
	ImageData []byte
	UpdatedAt time.Time
}

type DBTX

type DBTX interface {
	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
	PrepareContext(context.Context, string) (*sql.Stmt, error)
	QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
	QueryRowContext(context.Context, string, ...interface{}) *sql.Row
}

type DeleteActAsLinkParams

type DeleteActAsLinkParams struct {
	MainUserID   string
	AltUserID    string
	MainUserID_2 string
	AltUserID_2  string
}

type DeleteActAsSwitchForPairParams

type DeleteActAsSwitchForPairParams struct {
	MainUserID   string
	AltUserID    string
	MainUserID_2 string
	AltUserID_2  string
}

type DeleteActAsSwitchParams

type DeleteActAsSwitchParams struct {
	MainUserID string
	ChannelID  string
}

type DeleteAllActAsLinksForUserParams

type DeleteAllActAsLinksForUserParams struct {
	MainUserID string
	AltUserID  string
}

type DeleteAllActAsSwitchesForUserParams

type DeleteAllActAsSwitchesForUserParams struct {
	MainUserID string
	AltUserID  string
}

type DeleteAllLeaderboardExclusionsForUserInGuildParams

type DeleteAllLeaderboardExclusionsForUserInGuildParams struct {
	GuildID string
	UserID  string
}

type DeleteAllLeaderboardOptInsForUserInGuildParams

type DeleteAllLeaderboardOptInsForUserInGuildParams struct {
	GuildID string
	UserID  string
}

type DeleteCustomBannerParams

type DeleteCustomBannerParams struct {
	UserID  string
	GuildID string
}

type DeleteLeaderboardExclusionParams

type DeleteLeaderboardExclusionParams struct {
	GuildID string
	UserID  string
	LbType  string
}

type DeleteLeaderboardOptInParams

type DeleteLeaderboardOptInParams struct {
	GuildID string
	UserID  string
	LbType  string
}

type DeleteLeaderboardStatsForPlayerParams

type DeleteLeaderboardStatsForPlayerParams struct {
	Player string
	LbType string
}

type DeleteWatchParams

type DeleteWatchParams struct {
	UserID    string
	WatchType string
	TargetID  string
}

type Farmer

type Farmer struct {
	UserID               string    // Discord User ID
	EggIncName           string    // User's Egg Inc name
	Ping                 bool      // True/False
	Tokens               int       // Number of tokens this user wants
	LaunchChain          bool      // Launch History chain option
	MissionShipPrimary   int       // Launch Helper Ship Selection - Primary
	MissionShipSecondary int       // Launch Helper Ship Selection - Secondary
	UltraContract        time.Time // Date last Ultra contract was detected
	MiscSettingsFlag     map[string]bool
	MiscSettingsString   map[string]string
	Links                []Link // Array of Links
	LastUpdated          time.Time
	LastSeen             time.Time // Last time farmer was added to a contract
	DataPrivacy          bool      // User data privacy setting
}

Farmer struct to store user data

type FarmerGuildMembership

type FarmerGuildMembership struct {
	UserID  string
	GuildID string
}

type FarmerState

type FarmerState struct {
	ID    string
	Key   string
	Value sql.NullString
}

type GetActAsSwitchParams

type GetActAsSwitchParams struct {
	MainUserID string
	ChannelID  string
}

type GetActAsSwitchRow

type GetActAsSwitchRow struct {
	AltUserID string
	ExpiresAt time.Time
}

type GetCustomBannerParams

type GetCustomBannerParams struct {
	UserID  string
	GuildID string
}

type GetCustomBannerRow

type GetCustomBannerRow struct {
	ImageData []byte
	UpdatedAt time.Time
}

type GetEiIgnsByMiscStringParams

type GetEiIgnsByMiscStringParams struct {
	Column1 sql.NullString
	Value   sql.NullString
}

type GetIdsByMiscStringParams

type GetIdsByMiscStringParams struct {
	Column1 sql.NullString
	Value   sql.NullString
}

type GetLeaderboardExclusionsForUserRow

type GetLeaderboardExclusionsForUserRow struct {
	GuildID string
	LbType  string
}

func GetLeaderboardExclusionsForUser

func GetLeaderboardExclusionsForUser(userID string) ([]GetLeaderboardExclusionsForUserRow, error)

GetLeaderboardExclusionsForUser returns all (guild_id, lb_type) exclusion pairs for a given user.

type GetLeaderboardForSnapDateParams

type GetLeaderboardForSnapDateParams struct {
	LbType   string
	GuildID  string
	SnapDate string
}

type GetLeaderboardForSnapDateRow

type GetLeaderboardForSnapDateRow struct {
	Player   string
	GameName string
	Value    float64
	Details  sql.NullString
}

func GetLeaderboardForSnapDate

func GetLeaderboardForSnapDate(lbType, guildID, snapDate string) ([]GetLeaderboardForSnapDateRow, error)

GetLeaderboardForSnapDate returns all rows for a lb_type, guild_id and snap_date, ordered by value DESC.

type GetLeaderboardOptInsForGuildRow

type GetLeaderboardOptInsForGuildRow struct {
	UserID string
	LbType string
}

func GetLeaderboardOptInsForGuild

func GetLeaderboardOptInsForGuild(guildID string) ([]GetLeaderboardOptInsForGuildRow, error)

GetLeaderboardOptInsForGuild returns all (user_id, lb_type) pairs for a given guild.

type GetLeaderboardOptInsForUserRow

type GetLeaderboardOptInsForUserRow struct {
	GuildID string
	LbType  string
}

func GetLeaderboardOptInsForUser

func GetLeaderboardOptInsForUser(userID string) ([]GetLeaderboardOptInsForUserRow, error)

GetLeaderboardOptInsForUser returns all (guild_id, lb_type) pairs for a given user.

type GetLeaderboardSnapDatesForGuildParams

type GetLeaderboardSnapDatesForGuildParams struct {
	GuildID string
	LbType  string
}

type GetLeaderboardSnapDatesForGuildRow

type GetLeaderboardSnapDatesForGuildRow struct {
	SnapDate    string
	PlayerCount int64
}

func GetLeaderboardSnapDatesForGuild

func GetLeaderboardSnapDatesForGuild(guildID, lbType string) ([]GetLeaderboardSnapDatesForGuildRow, error)

GetLeaderboardSnapDatesForGuild returns all distinct snap_dates and player counts for a given lb_type and guild_id, newest first.

type GetLeaderboardStatForPlayerAndSnapDateParams

type GetLeaderboardStatForPlayerAndSnapDateParams struct {
	LbType   string
	Player   string
	SnapDate string
}

type GetLeaderboardStatForPlayerAndSnapDateRow

type GetLeaderboardStatForPlayerAndSnapDateRow struct {
	Player   string
	GameName string
	SnapDate string
	Value    float64
	Details  sql.NullString
}

type GetLeaderboardStatForPlayerParams

type GetLeaderboardStatForPlayerParams struct {
	LbType string
	Player string
}

type GetLeaderboardStatForPlayerRow

type GetLeaderboardStatForPlayerRow struct {
	Player   string
	GameName string
	SnapDate string
	Value    float64
	Details  sql.NullString
}

func GetLeaderboardStatForPlayer

func GetLeaderboardStatForPlayer(lbType, player string) (GetLeaderboardStatForPlayerRow, error)

GetLeaderboardStatForPlayer returns the most recent stat for a player + lb_type.

func GetLeaderboardStatForPlayerAndSnapDate

func GetLeaderboardStatForPlayerAndSnapDate(lbType, player, snapDate string) (GetLeaderboardStatForPlayerRow, error)

GetLeaderboardStatForPlayerAndSnapDate returns the stat for a player + lb_type + snap_date.

type GetStatsForPlayerInGuildParams

type GetStatsForPlayerInGuildParams struct {
	Player  string
	GuildID string
}

type InsertActAsLinkParams

type InsertActAsLinkParams struct {
	MainUserID string
	AltUserID  string
}

type InsertLegacyFarmerstateParams

type InsertLegacyFarmerstateParams struct {
	ID    string
	Value sql.NullString
}

type InsertSuspectMissionParams

type InsertSuspectMissionParams struct {
	UserID           string
	MissionID        string
	Ship             int64
	Status           int64
	DurationType     int64
	MissionType      int64
	Level            int64
	Capacity         int64
	QualityBump      float64
	TargetArtifact   int64
	DurationSeconds  float64
	StartTimeDerived float64
	BaseSeconds      float64
	EventMultiplier  float64
}

type InsertTimerParams

type InsertTimerParams struct {
	ID                string
	UserID            string
	ChannelID         string
	MsgID             string
	Reminder          time.Time
	Message           string
	Duration          int64
	OriginalChannelID string
	OriginalMsgID     string
	Active            bool
}

type InsertWatchParams

type InsertWatchParams struct {
	UserID    string
	WatchType string
	TargetID  string
}

type IsActAsLinkedEitherParams

type IsActAsLinkedEitherParams struct {
	MainUserID   string
	AltUserID    string
	MainUserID_2 string
	AltUserID_2  string
}

type IsActAsLinkedParams

type IsActAsLinkedParams struct {
	MainUserID string
	AltUserID  string
}

type LeaderboardExclusion

type LeaderboardExclusion struct {
	GuildID string
	UserID  string
	LbType  string
}

type LeaderboardOptin

type LeaderboardOptin struct {
	GuildID string
	UserID  string
	LbType  string
}

type LeaderboardStat

type LeaderboardStat struct {
	LbType   string
	Player   string
	GameName string
	SnapDate string
	Value    float64
	Details  sql.NullString
}

func GetStatsForPlayer

func GetStatsForPlayer(player string) ([]LeaderboardStat, error)

GetStatsForPlayer returns all leaderboard stats for a specific player across all types.

func GetStatsForPlayerInGuild

func GetStatsForPlayerInGuild(player, guildID string) ([]LeaderboardStat, error)

GetStatsForPlayerInGuild returns all leaderboard stats for a player in a specific guild.

type Link struct {
	Link      string    `json:"Link"`
	Timestamp time.Time `json:"Timestamp"`
}

Link will hold bookmark links

type PruneOlderLeaderboardStatsForPlayerParams

type PruneOlderLeaderboardStatsForPlayerParams struct {
	LbType   string
	Player   string
	SnapDate string
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) AddGuildMembership

func (q *Queries) AddGuildMembership(ctx context.Context, arg AddGuildMembershipParams) (int64, error)

func (*Queries) ClearExtraLegacyRecords

func (q *Queries) ClearExtraLegacyRecords(ctx context.Context) error
func (q *Queries) DeleteActAsLink(ctx context.Context, arg DeleteActAsLinkParams) (int64, error)

func (*Queries) DeleteActAsSwitch

func (q *Queries) DeleteActAsSwitch(ctx context.Context, arg DeleteActAsSwitchParams) (int64, error)

func (*Queries) DeleteActAsSwitchForPair

func (q *Queries) DeleteActAsSwitchForPair(ctx context.Context, arg DeleteActAsSwitchForPairParams) (int64, error)

func (*Queries) DeleteAllActAsLinksForUser

func (q *Queries) DeleteAllActAsLinksForUser(ctx context.Context, arg DeleteAllActAsLinksForUserParams) (int64, error)

func (*Queries) DeleteAllActAsSwitchesForUser

func (q *Queries) DeleteAllActAsSwitchesForUser(ctx context.Context, arg DeleteAllActAsSwitchesForUserParams) (int64, error)

func (*Queries) DeleteAllLeaderboardExclusionsForUserInGuild

func (q *Queries) DeleteAllLeaderboardExclusionsForUserInGuild(ctx context.Context, arg DeleteAllLeaderboardExclusionsForUserInGuildParams) error

func (*Queries) DeleteAllLeaderboardOptInsForUserInGuild

func (q *Queries) DeleteAllLeaderboardOptInsForUserInGuild(ctx context.Context, arg DeleteAllLeaderboardOptInsForUserInGuildParams) error

func (*Queries) DeleteAllLeaderboardStatsForPlayerInGuild

func (q *Queries) DeleteAllLeaderboardStatsForPlayerInGuild(ctx context.Context) error

No-op since leaderboard_stats is now global.

func (*Queries) DeleteCustomBanner

func (q *Queries) DeleteCustomBanner(ctx context.Context, arg DeleteCustomBannerParams) error

func (*Queries) DeleteExpiredActAsSwitches

func (q *Queries) DeleteExpiredActAsSwitches(ctx context.Context, expiresAt time.Time) error

func (*Queries) DeleteFarmerLegacyRecords

func (q *Queries) DeleteFarmerLegacyRecords(ctx context.Context, id string) error

func (*Queries) DeleteFarmerRecord

func (q *Queries) DeleteFarmerRecord(ctx context.Context, id string) error

func (*Queries) DeleteInactiveTimers

func (q *Queries) DeleteInactiveTimers(ctx context.Context) error

func (*Queries) DeleteLeaderboardExclusion

func (q *Queries) DeleteLeaderboardExclusion(ctx context.Context, arg DeleteLeaderboardExclusionParams) error

func (*Queries) DeleteLeaderboardOptIn

func (q *Queries) DeleteLeaderboardOptIn(ctx context.Context, arg DeleteLeaderboardOptInParams) error

func (*Queries) DeleteLeaderboardStatsForPlayer

func (q *Queries) DeleteLeaderboardStatsForPlayer(ctx context.Context, arg DeleteLeaderboardStatsForPlayerParams) error

func (*Queries) DeleteLegacyFarmerstate

func (q *Queries) DeleteLegacyFarmerstate(ctx context.Context, id string) error

func (*Queries) DeleteTimer

func (q *Queries) DeleteTimer(ctx context.Context, id string) error

func (*Queries) DeleteUserCustomBanners

func (q *Queries) DeleteUserCustomBanners(ctx context.Context, userID string) error

func (*Queries) DeleteUserGuildMemberships

func (q *Queries) DeleteUserGuildMemberships(ctx context.Context, userID string) error

func (*Queries) DeleteUserLeaderboardExclusions

func (q *Queries) DeleteUserLeaderboardExclusions(ctx context.Context, userID string) error

func (*Queries) DeleteUserLeaderboardOptIns

func (q *Queries) DeleteUserLeaderboardOptIns(ctx context.Context, userID string) error

func (*Queries) DeleteUserLeaderboardStats

func (q *Queries) DeleteUserLeaderboardStats(ctx context.Context, player string) error

func (*Queries) DeleteUserSuspectMissions

func (q *Queries) DeleteUserSuspectMissions(ctx context.Context, userID string) error

func (*Queries) DeleteUserTimers

func (q *Queries) DeleteUserTimers(ctx context.Context, userID string) error

func (*Queries) DeleteUserWatches

func (q *Queries) DeleteUserWatches(ctx context.Context, userID string) error

func (*Queries) DeleteWatch

func (q *Queries) DeleteWatch(ctx context.Context, arg DeleteWatchParams) error

func (*Queries) GetActAsLinksForMain

func (q *Queries) GetActAsLinksForMain(ctx context.Context, mainUserID string) ([]string, error)

func (*Queries) GetActAsMainsForAlt

func (q *Queries) GetActAsMainsForAlt(ctx context.Context, altUserID string) ([]string, error)

func (*Queries) GetActAsSwitch

func (q *Queries) GetActAsSwitch(ctx context.Context, arg GetActAsSwitchParams) (GetActAsSwitchRow, error)

func (*Queries) GetAllLegacyFarmerstate

func (q *Queries) GetAllLegacyFarmerstate(ctx context.Context) ([]FarmerState, error)

func (*Queries) GetAllWatches

func (q *Queries) GetAllWatches(ctx context.Context) ([]Watch, error)

func (*Queries) GetCustomBanner

func (q *Queries) GetCustomBanner(ctx context.Context, arg GetCustomBannerParams) (GetCustomBannerRow, error)

func (*Queries) GetCustomBannersForUser

func (q *Queries) GetCustomBannersForUser(ctx context.Context, userID string) ([]CustomBanner, error)

func (*Queries) GetEiIgnsByGuild

func (q *Queries) GetEiIgnsByGuild(ctx context.Context, guildID string) ([]interface{}, error)

func (*Queries) GetEiIgnsByMiscString

func (q *Queries) GetEiIgnsByMiscString(ctx context.Context, arg GetEiIgnsByMiscStringParams) ([]interface{}, error)

func (*Queries) GetGuildMembers

func (q *Queries) GetGuildMembers(ctx context.Context, guildID string) ([]string, error)

func (*Queries) GetIdsByMiscString

func (q *Queries) GetIdsByMiscString(ctx context.Context, arg GetIdsByMiscStringParams) ([]string, error)

func (*Queries) GetLatestLeaderboardSnapDate

func (q *Queries) GetLatestLeaderboardSnapDate(ctx context.Context, lbType string) (string, error)

Returns the most recent snap_date recorded for a given lb_type.

func (*Queries) GetLeaderboardExclusionsForUser

func (q *Queries) GetLeaderboardExclusionsForUser(ctx context.Context, userID string) ([]GetLeaderboardExclusionsForUserRow, error)

Returns all (guild_id, lb_type) exclusion pairs for a given user.

func (*Queries) GetLeaderboardForSnapDate

func (q *Queries) GetLeaderboardForSnapDate(ctx context.Context, arg GetLeaderboardForSnapDateParams) ([]GetLeaderboardForSnapDateRow, error)

Returns all rows for a given lb_type, guild_id, and snap_date, ordered by value descending.

func (*Queries) GetLeaderboardOptInGuilds

func (q *Queries) GetLeaderboardOptInGuilds(ctx context.Context) ([]string, error)

Returns all distinct guild IDs that have at least one opt-in.

func (*Queries) GetLeaderboardOptInUsers

func (q *Queries) GetLeaderboardOptInUsers(ctx context.Context) ([]string, error)

Returns all Discord user IDs who have at least one opt-in in any guild.

func (*Queries) GetLeaderboardOptInsForGuild

func (q *Queries) GetLeaderboardOptInsForGuild(ctx context.Context, guildID string) ([]GetLeaderboardOptInsForGuildRow, error)

Returns all (user_id, lb_type) pairs for a given guild.

func (*Queries) GetLeaderboardOptInsForUser

func (q *Queries) GetLeaderboardOptInsForUser(ctx context.Context, userID string) ([]GetLeaderboardOptInsForUserRow, error)

Returns all (guild_id, lb_type) pairs for a given user.

func (*Queries) GetLeaderboardSnapDates

func (q *Queries) GetLeaderboardSnapDates(ctx context.Context, lbType string) ([]string, error)

Returns all distinct snap_dates for a given lb_type, newest first.

func (*Queries) GetLeaderboardSnapDatesForGuild

Returns distinct snap_dates and player counts for a given lb_type and guild_id, newest first.

func (*Queries) GetLeaderboardStatForPlayer

Returns the most recent stat row for a player + lb_type.

func (*Queries) GetLeaderboardStatForPlayerAndSnapDate

Returns the stat row for a player + lb_type + snap_date.

func (*Queries) GetLegacyFarmerstate

func (q *Queries) GetLegacyFarmerstate(ctx context.Context, id string) (FarmerState, error)

func (*Queries) GetStatsForPlayer

func (q *Queries) GetStatsForPlayer(ctx context.Context, player string) ([]LeaderboardStat, error)

Returns all leaderboard stats for a specific player across all types, newest first.

func (*Queries) GetStatsForPlayerInGuild

func (q *Queries) GetStatsForPlayerInGuild(ctx context.Context, arg GetStatsForPlayerInGuildParams) ([]LeaderboardStat, error)

Returns all leaderboard stats for a specific player in a specific guild.

func (*Queries) GetSuspectMissions

func (q *Queries) GetSuspectMissions(ctx context.Context, userID string) ([]SuspectMission, error)

func (*Queries) GetTimers

func (q *Queries) GetTimers(ctx context.Context) ([]Timer, error)

func (*Queries) GetTimersForUser

func (q *Queries) GetTimersForUser(ctx context.Context, userID string) ([]Timer, error)

func (*Queries) GetUserGuilds

func (q *Queries) GetUserGuilds(ctx context.Context, userID string) ([]string, error)

func (*Queries) GetUserIdFromEiIgn

func (q *Queries) GetUserIdFromEiIgn(ctx context.Context, value sql.NullString) (string, error)

func (*Queries) GetUserIdsFromEiIgn

func (q *Queries) GetUserIdsFromEiIgn(ctx context.Context, value sql.NullString) ([]string, error)

func (*Queries) GetWatchesForUser

func (q *Queries) GetWatchesForUser(ctx context.Context, userID string) ([]Watch, error)
func (q *Queries) InsertActAsLink(ctx context.Context, arg InsertActAsLinkParams) error

func (*Queries) InsertLegacyFarmerstate

func (q *Queries) InsertLegacyFarmerstate(ctx context.Context, arg InsertLegacyFarmerstateParams) (FarmerState, error)

func (*Queries) InsertSuspectMission

func (q *Queries) InsertSuspectMission(ctx context.Context, arg InsertSuspectMissionParams) error

func (*Queries) InsertTimer

func (q *Queries) InsertTimer(ctx context.Context, arg InsertTimerParams) error

func (*Queries) InsertWatch

func (q *Queries) InsertWatch(ctx context.Context, arg InsertWatchParams) error

func (*Queries) IsActAsLinked

func (q *Queries) IsActAsLinked(ctx context.Context, arg IsActAsLinkedParams) (int64, error)

func (*Queries) IsActAsLinkedEither

func (q *Queries) IsActAsLinkedEither(ctx context.Context, arg IsActAsLinkedEitherParams) (int64, error)

func (*Queries) PruneOlderLeaderboardStatsForPlayer

func (q *Queries) PruneOlderLeaderboardStatsForPlayer(ctx context.Context, arg PruneOlderLeaderboardStatsForPlayerParams) error

Deletes older leaderboard stats for a player if RetainRecentOnly is true.

func (*Queries) RemoveGuildMembership

func (q *Queries) RemoveGuildMembership(ctx context.Context, arg RemoveGuildMembershipParams) error

func (*Queries) UpdateLegacyFarmerstate

func (q *Queries) UpdateLegacyFarmerstate(ctx context.Context, arg UpdateLegacyFarmerstateParams) (int64, error)

func (*Queries) UpdateTimerMsg

func (q *Queries) UpdateTimerMsg(ctx context.Context, arg UpdateTimerMsgParams) error

func (*Queries) UpdateTimerState

func (q *Queries) UpdateTimerState(ctx context.Context, arg UpdateTimerStateParams) error

func (*Queries) UpsertActAsSwitch

func (q *Queries) UpsertActAsSwitch(ctx context.Context, arg UpsertActAsSwitchParams) error

func (*Queries) UpsertCustomBanner

func (q *Queries) UpsertCustomBanner(ctx context.Context, arg UpsertCustomBannerParams) error

func (*Queries) UpsertLeaderboardExclusion

func (q *Queries) UpsertLeaderboardExclusion(ctx context.Context, arg UpsertLeaderboardExclusionParams) error

func (*Queries) UpsertLeaderboardOptIn

func (q *Queries) UpsertLeaderboardOptIn(ctx context.Context, arg UpsertLeaderboardOptInParams) error

func (*Queries) UpsertLeaderboardStat

func (q *Queries) UpsertLeaderboardStat(ctx context.Context, arg UpsertLeaderboardStatParams) error

Inserts or replaces a leaderboard snapshot for (lb_type, player, snap_date).

func (*Queries) WithTx

func (q *Queries) WithTx(tx *sql.Tx) *Queries

type RemoveGuildMembershipParams

type RemoveGuildMembershipParams struct {
	UserID  string
	GuildID string
}

type SuspectMission

type SuspectMission struct {
	UserID           string
	MissionID        string
	Ship             int64
	Status           int64
	DurationType     int64
	MissionType      int64
	Level            int64
	Capacity         int64
	QualityBump      float64
	TargetArtifact   int64
	DurationSeconds  float64
	StartTimeDerived float64
	BaseSeconds      float64
	EventMultiplier  float64
}

type Timer

type Timer struct {
	ID                string
	UserID            string
	ChannelID         string
	MsgID             string
	Reminder          time.Time
	Message           string
	Duration          int64
	OriginalChannelID string
	OriginalMsgID     string
	Active            bool
}

func GetAllTimers

func GetAllTimers() []Timer

GetAllTimers returns all timers from the database.

type UpdateLegacyFarmerstateParams

type UpdateLegacyFarmerstateParams struct {
	Value sql.NullString
	ID    string
}

type UpdateTimerMsgParams

type UpdateTimerMsgParams struct {
	ChannelID string
	MsgID     string
	ID        string
}

type UpdateTimerStateParams

type UpdateTimerStateParams struct {
	Active bool
	ID     string
}

type UpsertActAsSwitchParams

type UpsertActAsSwitchParams struct {
	MainUserID string
	ChannelID  string
	AltUserID  string
	ExpiresAt  time.Time
}

type UpsertCustomBannerParams

type UpsertCustomBannerParams struct {
	UserID    string
	GuildID   string
	ImageData []byte
}

type UpsertLeaderboardExclusionParams

type UpsertLeaderboardExclusionParams struct {
	GuildID string
	UserID  string
	LbType  string
}

type UpsertLeaderboardOptInParams

type UpsertLeaderboardOptInParams struct {
	GuildID string
	UserID  string
	LbType  string
}

type UpsertLeaderboardStatParams

type UpsertLeaderboardStatParams struct {
	LbType   string
	Player   string
	GameName string
	SnapDate string
	Value    float64
	Details  sql.NullString
}

type UserPrivacyData

type UserPrivacyData struct {
	FarmerState           *Farmer                              `json:"farmer_state,omitempty"`
	GuildMemberships      []string                             `json:"guild_memberships,omitempty"`
	CustomBanners         []CustomBanner                       `json:"custom_banners,omitempty"`
	Timers                []Timer                              `json:"timers,omitempty"`
	SuspectMissions       []SuspectMission                     `json:"suspect_missions,omitempty"`
	LeaderboardStats      []LeaderboardStat                    `json:"leaderboard_stats,omitempty"`
	LeaderboardOptins     []GetLeaderboardOptInsForUserRow     `json:"leaderboard_optins,omitempty"`
	LeaderboardExclusions []GetLeaderboardExclusionsForUserRow `json:"leaderboard_exclusions,omitempty"`
	Watches               []Watch                              `json:"watches,omitempty"`
	ActAsLinks            []string                             `json:"act_as_links,omitempty"`
	ActAsMains            []string                             `json:"act_as_mains,omitempty"`
}

UserPrivacyData contains all information we store about a user

func GetFullUserData

func GetFullUserData(userID string) *UserPrivacyData

type Watch

type Watch struct {
	UserID    string
	WatchType string
	TargetID  string
	CreatedAt time.Time
}

func GetAllWatches

func GetAllWatches() []Watch

GetAllWatches returns all watches in the database.

func GetWatchesForUser

func GetWatchesForUser(userID string) []Watch

GetWatchesForUser returns all watches for a given user.

Jump to

Keyboard shortcuts

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