users

package
v1.7.25 Latest Latest
Warning

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

Go to latest
Published: May 16, 2021 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LifetimeMilesLeaderboard [][]string
View Source
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 InitLeaderboard

func InitLeaderboard()

LifetimeMilesLeaderboard creates a leaderboard

func LeaderboardContent

func LeaderboardContent(title string, leaderboard [][]string) string

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 Shutdown

func Shutdown()

ShutDown loops through all of the logged-in users and logs them out

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 Find

func Find(username string) User

Find will look up the username in the DB, and return a User if possible

func FindOrCreate

func FindOrCreate(username string) User

FindOrCreate will try to find the user in the DB, otherwise it will create a new user

func LoginIfNecessary

func LoginIfNecessary(username string) *User

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 (u User) AddToScore(scoreboardName string, valueToAdd float32)

func (User) BonusMiles

func (u User) BonusMiles() float32

func (User) CurrentMiles

func (u User) CurrentMiles() float32

func (User) CurrentMonthlyMiles

func (u User) CurrentMonthlyMiles() float32

func (User) GetScore

func (u User) GetScore(scoreboardName string) float32

func (User) GuessCooldownRemaining

func (u User) GuessCooldownRemaining() time.Duration

GuessCooldownRemaining returns the amount of time a user needs to wait before they can guess again

func (*User) HasCommandAvailable

func (u *User) HasCommandAvailable() bool

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

func (u *User) HasGuessCommandAvailable(lastTimewarpTime time.Time) bool

HasGuessCommandAvailable returns true if the user is allowed to use the guess command

func (User) IsFollower

func (u User) IsFollower() bool

IsFollower returns true if the user is a follower

func (User) IsSubscriber

func (u User) IsSubscriber() bool

IsSubscriber returns true if the user is a subscriber

func (*User) SetLastLocationTime

func (u *User) SetLastLocationTime()

func (User) String

func (u User) String() string

User.String prints a colored version of the user

Jump to

Keyboard shortcuts

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