model

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2023 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DurationStatusUpdateTimer    = time.Second * 2
	DurationDisconnected         = DurationStatusUpdateTimer * 3
	DurationPlayerExpired        = DurationStatusUpdateTimer * 10
	DurationCheckTimer           = time.Second * 3
	DurationUpdateTimer          = time.Second * 1
	DurationAnnounceMatchTimeout = time.Minute * 5
	DurationCacheTimeout         = time.Hour * 12
	DurationWebRequestTimeout    = time.Second * 5
	DurationRCONRequestTimeout   = time.Second
	DurationProcessTimeout       = time.Second * 3
)

Variables

This section is empty.

Functions

func AvatarUrl

func AvatarUrl(hash string) string

Types

type ChatDest added in v0.0.7

type ChatDest string
const (
	ChatDestAll   ChatDest = "all"
	ChatDestTeam  ChatDest = "team"
	ChatDestParty ChatDest = "party"
)

type ChatFunc added in v0.0.7

type ChatFunc func(destination ChatDest, format string, args ...any) error

type Event

type Event struct {
	Name  EventType
	Value any
}

type EventType

type EventType int
const (
	EvtKill EventType = iota
	EvtMsg
	EvtConnect
	EvtDisconnect
	EvtStatusId
	EvtHostname
	EvtMap
	EvtTags
	EvtAddress
	EvtLobby
)

type GetPlayer

type GetPlayer func(sid64 steamid.SID64) *Player

type GetPlayerOffline

type GetPlayerOffline func(ctx context.Context, sid64 steamid.SID64, player *Player) error

type KickFunc

type KickFunc func(userId int64, reason KickReason) error

type KickReason

type KickReason string
const (
	KickReasonIdle     KickReason = "idle"
	KickReasonScamming KickReason = "scamming"
	KickReasonCheating KickReason = "cheating"
	KickReasonOther    KickReason = "other"
)

type LaunchFunc

type LaunchFunc func()

type LinkConfig

type LinkConfig struct {
	Enabled  bool   `yaml:"enabled"`
	Name     string `yaml:"name"`
	URL      string `yaml:"url"`
	IdFormat string `yaml:"id_format"`
	Deleted  bool   `yaml:"-"`
}

type LinkConfigCollection added in v0.0.7

type LinkConfigCollection []*LinkConfig

func (LinkConfigCollection) AsAny added in v0.0.7

func (list LinkConfigCollection) AsAny() []any

type ListConfig

type ListConfig struct {
	ListType ListType `yaml:"type"`
	Name     string   `yaml:"name"`
	Enabled  bool     `yaml:"enabled"`
	URL      string   `yaml:"url"`
}

type ListConfigCollection

type ListConfigCollection []*ListConfig

func (ListConfigCollection) AsAny

func (list ListConfigCollection) AsAny() []any

type ListType

type ListType string
const (
	//ListTypeBD              ListType = "bd"
	ListTypeTF2BDPlayerList ListType = "tf2bd_playerlist"
	ListTypeTF2BDRules      ListType = "tf2bd_rules"
)

type LogEvent

type LogEvent struct {
	Type            EventType
	Player          string
	PlayerPing      int
	PlayerConnected time.Duration
	Team            Team
	UserId          int64
	PlayerSID       steamid.SID64
	Victim          string
	VictimSID       steamid.SID64
	Message         string
	Timestamp       time.Time
	MetaData        string
	Dead            bool
	TeamOnly        bool
}

func (*LogEvent) ApplyTimestamp

func (e *LogEvent) ApplyTimestamp(tsString string) error

type MarkFunc

type MarkFunc func(sid64 steamid.SID64, attrs []string) error

type NoteFunc

type NoteFunc func(sid64 steamid.SID64, note string) error

type Player

type Player struct {
	sync.RWMutex

	// SteamId is the 64bit steamid of the user
	SteamId steamid.SID64

	// Name is the current in-game name of the player. This can be different from their name via steam api when
	// using changer/stealers
	Name string

	// CreatedOn is the first time we have seen the player
	CreatedOn time.Time

	// UpdatedOn is the last time we have received a status update from rcon
	// This is used to calculate when we consider the player disconnected and also when
	// they are expired and should be removed from the player pool entirely.
	UpdatedOn        time.Time
	ProfileUpdatedOn time.Time

	// The users kill count vs this player
	KillsOn   int
	RageQuits int
	DeathsBy  int

	Notes       string
	Whitelisted bool

	// PlayerSummary
	RealName         string
	NamePrevious     string
	AccountCreatedOn time.Time

	Visibility ProfileVisibility
	AvatarHash string

	// PlayerBanState
	CommunityBanned  bool
	NumberOfVACBans  int
	LastVACBanOn     *time.Time
	NumberOfGameBans int
	EconomyBan       bool

	// tf_lobby_debug
	Team Team

	// status
	// Connected is how long the user has been in the server
	Connected time.Duration
	// In game user id
	UserId int64
	Ping   int

	// Parsed stats from logs
	Kills  int
	Deaths int

	// Incremented on each kick attempt. Used to cycle through and not attempt the same bot
	KickAttemptCount int

	// Tracks the duration between announces to chat
	AnnouncedPartyLast time.Time

	AnnouncedGeneralLast time.Time

	// Dangling will be true when the user is new and doesn't have a physical entry in the database yet.
	Dangling bool

	OurFriend bool

	// Dirty indicates that state which has database backed fields has been changed and need to be saved
	Dirty bool

	Match *rules.MatchResult
}

func NewPlayer

func NewPlayer(sid64 steamid.SID64, name string) *Player

func (*Player) GetAvatarHash

func (ps *Player) GetAvatarHash() string

func (*Player) GetName

func (ps *Player) GetName() string

func (*Player) GetSteamID

func (ps *Player) GetSteamID() steamid.SID64

func (*Player) IsDisconnected

func (ps *Player) IsDisconnected() bool

func (*Player) IsExpired

func (ps *Player) IsExpired() bool

func (*Player) IsMatched

func (ps *Player) IsMatched() bool

func (*Player) Touch

func (ps *Player) Touch()

type PlayerCollection

type PlayerCollection []*Player

func (PlayerCollection) AsAny

func (players PlayerCollection) AsAny() []any

type ProfileVisibility

type ProfileVisibility int

ProfileVisibility represents whether the profile is visible or not, and if it is visible, why you are allowed to see it. Note that because this WebAPI does not use authentication, there are only two possible values returned: 1 - the profile is not visible to you (Private, Friends Only, etc), 3 - the profile is "Public", and the data is visible. Mike Blaszczak's post on Steam forums says, "The community visibility state this API returns is different than the privacy state. It's the effective visibility state from the account making the request to the account being viewed given the requesting account's relationship to the viewed account."

const (
	ProfileVisibilityPrivate ProfileVisibility = iota + 1
	ProfileVisibilityFriendsOnly
	ProfileVisibilityPublic
)

type QueryNamesFunc

type QueryNamesFunc func(ctx context.Context, sid64 steamid.SID64) (UserNameHistoryCollection, error)

type QueryUserMessagesFunc

type QueryUserMessagesFunc func(ctx context.Context, sid64 steamid.SID64) (UserMessageCollection, error)

type RCONConfig

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

func (RCONConfig) Host

func (cfg RCONConfig) Host() string

func (RCONConfig) Password

func (cfg RCONConfig) Password() string

func (RCONConfig) Port

func (cfg RCONConfig) Port() uint16

func (RCONConfig) String

func (cfg RCONConfig) String() string

type RCONConfigProvider

type RCONConfigProvider interface {
	String() string
	Host() string
	Port() uint16
	Password() string
}

func NewRconConfig

func NewRconConfig(static bool) RCONConfigProvider

type SavePlayer

type SavePlayer func(ctx context.Context, state *Player) error

type SearchOpts

type SearchOpts struct {
	Query string
}

type SearchPlayers

type SearchPlayers func(ctx context.Context, opts SearchOpts) (PlayerCollection, error)

type Server

type Server struct {
	ServerName string
	Addr       net.IP
	Port       uint16
	CurrentMap string
	Tags       []string
	LastUpdate time.Time
}

type Settings

type Settings struct {
	*sync.RWMutex `yaml:"-"`
	// Path to config used when reading Settings
	ConfigPath string `yaml:"-"`
	SteamID    string `yaml:"steam_id"`
	// Path to directory with steam.dll (C:\Program Files (x86)\Steam)
	// eg: -> ~/.local/share/Steam/userdata/123456789/config/localconfig.vdf
	SteamDir string `yaml:"steam_dir"`
	// Path to tf2 mod (C:\Program Files (x86)\Steam\steamapps\common\Team Fortress 2\tf)
	TF2Dir                 string               `yaml:"tf2_dir"`
	AutoLaunchGame         bool                 `yaml:"auto_launch_game_auto"`
	AutoCloseOnGameExit    bool                 `yaml:"auto_close_on_game_exit"`
	APIKey                 string               `yaml:"api_key"`
	DisconnectedTimeout    string               `yaml:"disconnected_timeout"`
	DiscordPresenceEnabled bool                 `yaml:"discord_presence_enabled"`
	KickerEnabled          bool                 `yaml:"kicker_enabled"`
	ChatWarningsEnabled    bool                 `yaml:"chat_warnings_enabled"`
	PartyWarningsEnabled   bool                 `yaml:"party_warnings_enabled"`
	KickTags               []string             `yaml:"kick_tags"`
	VoiceBansEnabled       bool                 `yaml:"voice_bans_enabled"`
	DebugLogEnabled        bool                 `yaml:"debug_log_enabled"`
	Lists                  ListConfigCollection `yaml:"lists"`
	Links                  []*LinkConfig        `yaml:"links"`
	RCONStatic             bool                 `yaml:"rcon_static"`
	// contains filtered or unexported fields
}

func NewSettings

func NewSettings() (*Settings, error)

func (*Settings) AddList

func (s *Settings) AddList(config *ListConfig) error

func (*Settings) ConfigRoot

func (s *Settings) ConfigRoot() string

func (*Settings) DBPath

func (s *Settings) DBPath() string

func (*Settings) GetAPIKey added in v0.0.7

func (s *Settings) GetAPIKey() string

func (*Settings) GetAutoCloseOnGameExit added in v0.0.7

func (s *Settings) GetAutoCloseOnGameExit() bool

func (*Settings) GetAutoLaunchGame added in v0.0.7

func (s *Settings) GetAutoLaunchGame() bool

func (*Settings) GetConfigPath added in v0.0.7

func (s *Settings) GetConfigPath() string

func (*Settings) GetDebugLogEnabled added in v0.0.8

func (s *Settings) GetDebugLogEnabled() bool

func (*Settings) GetDiscordPresenceEnabled added in v0.0.7

func (s *Settings) GetDiscordPresenceEnabled() bool

func (*Settings) GetKickTags added in v0.0.7

func (s *Settings) GetKickTags() []string

func (*Settings) GetKickerEnabled added in v0.0.7

func (s *Settings) GetKickerEnabled() bool
func (s *Settings) GetLinks() LinkConfigCollection

func (*Settings) GetLists added in v0.0.7

func (s *Settings) GetLists() ListConfigCollection

func (*Settings) GetPartyWarningsEnabled added in v0.0.7

func (s *Settings) GetPartyWarningsEnabled() bool

func (*Settings) GetRCONStatic added in v0.0.7

func (s *Settings) GetRCONStatic() bool

func (*Settings) GetRcon added in v0.0.7

func (s *Settings) GetRcon() RCONConfigProvider

func (*Settings) GetSteamDir added in v0.0.7

func (s *Settings) GetSteamDir() string

func (*Settings) GetSteamId

func (s *Settings) GetSteamId() steamid.SID64

func (*Settings) GetTF2Dir added in v0.0.7

func (s *Settings) GetTF2Dir() string

func (*Settings) GetVoiceBansEnabled added in v0.0.8

func (s *Settings) GetVoiceBansEnabled() bool

func (*Settings) ListRoot

func (s *Settings) ListRoot() string

func (*Settings) LocalPlayerListPath

func (s *Settings) LocalPlayerListPath() string

func (*Settings) LocalRulesListPath

func (s *Settings) LocalRulesListPath() string

func (*Settings) LogFilePath added in v0.0.8

func (s *Settings) LogFilePath() string

func (*Settings) Read

func (s *Settings) Read(inputFile io.Reader) error

func (*Settings) ReadDefaultOrCreate

func (s *Settings) ReadDefaultOrCreate() error

func (*Settings) ReadFilePath

func (s *Settings) ReadFilePath(filePath string) error

func (*Settings) Save

func (s *Settings) Save() error

func (*Settings) SetAPIKey added in v0.0.7

func (s *Settings) SetAPIKey(key string)

func (*Settings) SetAutoCloseOnGameExit added in v0.0.7

func (s *Settings) SetAutoCloseOnGameExit(autoClose bool)

func (*Settings) SetAutoLaunchGame added in v0.0.7

func (s *Settings) SetAutoLaunchGame(autoLaunch bool)

func (*Settings) SetChatWarningsEnabled added in v0.0.7

func (s *Settings) SetChatWarningsEnabled(enabled bool)

func (*Settings) SetDebugLogEnabled added in v0.0.8

func (s *Settings) SetDebugLogEnabled(enabled bool)

func (*Settings) SetDiscordPresenceEnabled added in v0.0.10

func (s *Settings) SetDiscordPresenceEnabled(enabled bool)

func (*Settings) SetKickTags added in v0.0.7

func (s *Settings) SetKickTags(tags []string)

func (*Settings) SetKickerEnabled added in v0.0.7

func (s *Settings) SetKickerEnabled(enabled bool)
func (s *Settings) SetLinks(links []*LinkConfig)

func (*Settings) SetLists added in v0.0.7

func (s *Settings) SetLists(lists ListConfigCollection)

func (*Settings) SetPartyWarningsEnabled added in v0.0.7

func (s *Settings) SetPartyWarningsEnabled(enabled bool)

func (*Settings) SetRconStatic added in v0.0.7

func (s *Settings) SetRconStatic(static bool)

func (*Settings) SetSteamDir added in v0.0.7

func (s *Settings) SetSteamDir(dir string)

func (*Settings) SetSteamID added in v0.0.7

func (s *Settings) SetSteamID(steamID string)

func (*Settings) SetTF2Dir added in v0.0.7

func (s *Settings) SetTF2Dir(dir string)

func (*Settings) SetVoiceBansEnabled added in v0.0.8

func (s *Settings) SetVoiceBansEnabled(enabled bool)

func (*Settings) Write

func (s *Settings) Write(outputFile io.Writer) error

func (*Settings) WriteFilePath

func (s *Settings) WriteFilePath(filePath string) error

type SteamIDErrFunc

type SteamIDErrFunc func(sid64 steamid.SID64) error

type SteamIDFunc

type SteamIDFunc func(sid64 steamid.SID64)

type SteamIdFormat

type SteamIdFormat string

TODO add to steamid pkg

const (
	Steam64 SteamIdFormat = "steam64"
	Steam3  SteamIdFormat = "steam3"
	Steam32 SteamIdFormat = "steam32"
	Steam   SteamIdFormat = "steam"
)

type Team

type Team int
const (
	Red Team = iota
	Blu
)

type UserInterface

type UserInterface interface {
	Refresh()
	Start(ctx context.Context)
	Quit()
	UpdateServerState(state Server)
	UpdatePlayerState(collection PlayerCollection)
	AddUserMessage(message UserMessage)
	UpdateAttributes([]string)
	SetAvatar(sid64 steamid.SID64, avatar []byte)
}

type UserMessage

type UserMessage struct {
	MessageId int64
	Team      Team
	Player    string
	PlayerSID steamid.SID64
	UserId    int64
	Message   string
	Created   time.Time
	Dead      bool
	TeamOnly  bool
}

func (UserMessage) Formatted

func (um UserMessage) Formatted() string

type UserMessageCollection

type UserMessageCollection []UserMessage

func (UserMessageCollection) AsAny

func (messages UserMessageCollection) AsAny() []any

type UserNameHistory

type UserNameHistory struct {
	NameId    int64
	Name      string
	FirstSeen time.Time
}

type UserNameHistoryCollection

type UserNameHistoryCollection []UserNameHistory

func (UserNameHistoryCollection) AsAny

func (names UserNameHistoryCollection) AsAny() []any

type Version

type Version struct {
	Version string
	Commit  string
	Date    string
	BuiltBy string
}

Jump to

Keyboard shortcuts

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