Documentation ¶
Index ¶
- Variables
- func GiveEveryoneMiles(gift float32)
- func InitLeaderboard()
- func LeaderboardContent(title string, leaderboard [][]string) string
- func LogoutIfNecessary(username string)
- func PrintCurrentSession()
- func Shutdown()
- func UpdateLeaderboard()
- func UpdateSession()
- type User
- func (u User) AddToScore(scoreboardName string, valueToAdd float32)
- func (u User) BonusMiles() float32
- func (u User) CurrentMiles() float32
- func (u User) CurrentMonthlyMiles() float32
- func (u User) GetScore(scoreboardName string) float32
- func (u User) GuessCooldownRemaining() time.Duration
- func (u *User) HasCommandAvailable() bool
- func (u *User) HasGuessCommandAvailable(lastTimewarpTime time.Time) bool
- func (u User) IsFollower() bool
- func (u User) IsSubscriber() bool
- func (u *User) SetLastLocationTime()
- func (u User) String() string
Constants ¶
This section is empty.
Variables ¶
var LifetimeMilesLeaderboard [][]string
var LoggedIn = make(map[string]*User)
LoggedIn is a map that contains all the currently logged-in users, mapping their username to a User
Functions ¶
func GiveEveryoneMiles ¶
func GiveEveryoneMiles(gift float32)
GiveEveryoneMiles gives all logged-in users miles
func LeaderboardContent ¶
LeaderboardContent creates the content for the leaderboard onscreen
func LogoutIfNecessary ¶
func LogoutIfNecessary(username string)
LogoutIfNecessary will log out the user if it finds them in the session
func PrintCurrentSession ¶
func PrintCurrentSession()
PrintCurrentSession simply prints info about the current session
func UpdateLeaderboard ¶
func UpdateLeaderboard()
func UpdateSession ¶
func UpdateSession()
UpdateSession will use the data from the Twitch API to maintain a list of currently-logged-in users
Types ¶
type User ¶
type User struct { ID uint16 `db:"id"` Username string `db:"username"` Miles float32 `db:"miles"` NumVisits uint16 `db:"num_visits"` HasDonated bool `db:"has_donated"` IsBot bool `db:"is_bot"` FirstSeen time.Time `db:"first_seen"` LastSeen time.Time `db:"last_seen"` DateCreated time.Time `db:"date_created"` LoggedIn time.Time // contains filtered or unexported fields }
func FindOrCreate ¶
FindOrCreate will try to find the user in the DB, otherwise it will create a new user
func LoginIfNecessary ¶
LoginIfNecessary checks the list of currently-logged in users and will run login() if this user isn't currently logged in
func (User) AddToScore ¶
func (User) BonusMiles ¶
func (User) CurrentMiles ¶
func (User) CurrentMonthlyMiles ¶
func (User) GuessCooldownRemaining ¶
GuessCooldownRemaining returns the amount of time a user needs to wait before they can guess again
func (*User) HasCommandAvailable ¶
HasCommandAvailable lets users run a command once a day, unless they are a follower in which case they can run as many as they like
func (*User) HasGuessCommandAvailable ¶
HasGuessCommandAvailable returns true if the user is allowed to use the guess command
func (User) IsFollower ¶
IsFollower returns true if the user is a follower
func (User) IsSubscriber ¶
IsSubscriber returns true if the user is a subscriber
func (*User) SetLastLocationTime ¶
func (u *User) SetLastLocationTime()