tf2bdd

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMigration        = errors.New("could not migrate db schema")
	ErrStoreIOFSOpen    = errors.New("failed to create migration iofs")
	ErrStoreIOFSClose   = errors.New("failed to close migration iofs")
	ErrStoreDriver      = errors.New("failed to create db driver")
	ErrCreateMigration  = errors.New("failed to create migrator")
	ErrPerformMigration = errors.New("failed to migrate database")
	ErrDuplicate        = errors.New("duplicate entry")
	ErrNotFound         = errors.New("entry not found")
)

Functions

func AddPlayer

func AddPlayer(ctx context.Context, db *sql.DB, player Player, author int64) error

func CreateHTTPServer

func CreateHTTPServer(mux *http.ServeMux, listenAddr string) *http.Server

func CreateRouter

func CreateRouter(database *sql.DB, config Config) *http.ServeMux

func DiscordAddURL

func DiscordAddURL(clientID string) string

func NewBot

func NewBot(token string) (*discordgo.Session, error)

func OpenDB

func OpenDB(dbPath string) (*sql.DB, error)

func SetupDB

func SetupDB(database *sql.DB) error

func StartBot

func StartBot(ctx context.Context, session *discordgo.Session, database *sql.DB, config Config) error

func ValidateConfig

func ValidateConfig(config Config) error

Types

type Config

type Config struct {
	SteamKey        string   `mapstructure:"steam_key"`
	DiscordClientID string   `mapstructure:"discord_client_id"`
	DiscordBotToken string   `mapstructure:"discord_bot_token"`
	DiscordRoles    []string `mapstructure:"discord_roles"`
	ExternalURL     string   `mapstructure:"external_url"`
	DatabasePath    string   `mapstructure:"database_path"`
	ListenHost      string   `mapstructure:"listen_host"`
	ListenPort      uint16   `mapstructure:"listen_port"`
	ListTitle       string   `mapstructure:"list_title"`
	ListDescription string   `mapstructure:"list_description"`
	ListAuthors     []string `mapstructure:"list_authors"`
	ExportedAttrs   []string `mapstructure:"exported_attrs"`
}

func ReadConfig

func ReadConfig() (Config, error)

func (Config) ListenAddr added in v1.0.5

func (config Config) ListenAddr() string

func (Config) UpdateURL added in v1.0.5

func (config Config) UpdateURL() (string, error)

type LastSeen

type LastSeen struct {
	PlayerName string `json:"player_name"`
	Time       int64  `json:"time"`
}

type ListSource

type ListSource struct {
	Authors     []string `json:"authors"`
	Description string   `json:"description"`
	Title       string   `json:"title"`
	UpdateURL   string   `json:"update_url"`
}

type Player

type Player struct {
	SteamID    steamid.SteamID `json:"steamid"`
	Attributes []string        `json:"attributes"`
	LastSeen   LastSeen        `json:"last_seen,omitempty"`
	Author     int64           `json:"-"`
	CreatedOn  time.Time       `json:"-"`
	Proof      Proof           `json:"proof"`
}

type PlayerListRoot

type PlayerListRoot struct {
	ListSource ListSource `json:"file_info"`
	Schema     string     `json:"$schema"`
	Players    []Player   `json:"players"`
	Version    int        `json:"version"`
}

type Proof added in v1.0.3

type Proof []string

func (*Proof) Scan added in v1.0.3

func (p *Proof) Scan(value interface{}) error

func (Proof) Value added in v1.0.3

func (p Proof) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

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