Documentation
¶
Index ¶
- Constants
- Variables
- type CPData
- type CvarData
- type EventListener
- type ItemPickup
- type Listener
- func (l *Listener) AddSource(handler *EventListener, m *TF2RconConnection) *Source
- func (l *Listener) AddSourceSecret(secret string, handler *EventListener, m *TF2RconConnection) *Source
- func (l *Listener) RemoveSource(s *Source, m *TF2RconConnection)
- func (l *Listener) TestSource(m *TF2RconConnection) bool
- type LogMessage
- type ParsedMsg
- type Player
- type PlayerDamage
- type PlayerData
- type PlayerHeal
- type PlayerKill
- type PlayerTrigger
- type Source
- type TF2RconConnection
- func (c *TF2RconConnection) AddTag(newTag string) error
- func (c *TF2RconConnection) BanPlayer(minutes int, p Player, message string) error
- func (c *TF2RconConnection) ChangeMap(mapname string) error
- func (c *TF2RconConnection) ChangeRconPassword(password string) error
- func (c *TF2RconConnection) ChangeServerPassword(password string) error
- func (c *TF2RconConnection) Close()
- func (c *TF2RconConnection) ExecConfig(config string) error
- func (c *TF2RconConnection) GetConVar(cvar string) (string, error)
- func (c *TF2RconConnection) GetPlayers() ([]Player, error)
- func (c *TF2RconConnection) GetServerPassword() (string, error)
- func (c *TF2RconConnection) KickPlayer(p Player, message string) error
- func (c *TF2RconConnection) KickPlayerID(userID string, message string) error
- func (c *TF2RconConnection) Query(req string) (string, error)
- func (c *TF2RconConnection) QueryNoResp(req string) error
- func (c *TF2RconConnection) Reconnect(duration time.Duration) error
- func (c *TF2RconConnection) RedirectLogs(addr string) error
- func (c *TF2RconConnection) RemoveTag(tagName string) error
- func (c *TF2RconConnection) Say(message string) error
- func (c *TF2RconConnection) Sayf(format string, a ...interface{}) error
- func (c *TF2RconConnection) SetConVar(cvar string, val string) (string, error)
- func (c *TF2RconConnection) StopLogRedirection(addr string)
- func (c *TF2RconConnection) UnbanPlayer(p Player) error
- type TeamData
- type UnknownCommand
Constants ¶
const ( PlayerGlobalMessage = iota PlayerTeamMessage PlayerChangedClass PlayerChangedTeam PlayerPickedUpItem PlayerSpawned PlayerKilled PlayerDamaged PlayerHealed PlayerKilledMedic PlayerUberFinished PlayerBlockedCapture PlayerConnected PlayerDisconnected TeamPointCapture TeamScoreUpdate WorldGameOver WorldRoundWin WorldRoundStart ServerCvar TournamentStarted LogFileClosed RconCommand )
const TimeFormat = "01/02/2006 - 15:04:05"
TimeFormat is the reference time used by the server to represent time
Variables ¶
var ( ErrUnknownCommand = errors.New("Unknown Command") CVarValueRegex = regexp.MustCompile(`^"(?:.*?)" = "(.*?)"`) )
var ( //ErrInvalidPacket represents an error when an invalid packet is found ErrInvalidPacket = errors.New("invalid packet") )
Functions ¶
This section is empty.
Types ¶
type EventListener ¶
type EventListener struct { PlayerConnected func(PlayerData) PlayerDisconnected func(PlayerData) PlayerGlobalMessage func(PlayerData, string) // strings are chat message PlayerTeamMessage func(PlayerData, string) PlayerSpawned func(PlayerData, string) // string is class PlayerClassChanged func(PlayerData, string) // string is new classes PlayerTeamChange func(PlayerData, string) // string is new team PlayerKilled func(PlayerKill) PlayerDamaged func(PlayerDamage) PlayerHealed func(PlayerHeal) PlayerKilledMedic func(PlayerTrigger) PlayerUberFinished func(PlayerData) PlayerBlockedCapture func(CPData, PlayerData) // cp blocked by player PlayerItemPickup func(ItemPickup) TeamPointCapture func(TeamData) TeamScoreUpdate func(TeamData) GameOver func() WorldRoundWin func(string) // string is team which won CVarChange func(variable string, value string) LogFileClosed func() TournamentStarted func() RconCommand func(from, command string) // from - IP Address, command - command executed // contains filtered or unexported fields }
type ItemPickup ¶
type ItemPickup struct { PlayerData PlayerData `json:"player"` Item string `json:"item"` Healing int `json:"healing"` }
type Listener ¶
type Listener struct {
// contains filtered or unexported fields
}
func NewListener ¶
NewListener returns a new Listener
func NewListenerAddr ¶
func (*Listener) AddSource ¶
func (l *Listener) AddSource(handler *EventListener, m *TF2RconConnection) *Source
func (*Listener) AddSourceSecret ¶
func (l *Listener) AddSourceSecret(secret string, handler *EventListener, m *TF2RconConnection) *Source
func (*Listener) RemoveSource ¶
func (l *Listener) RemoveSource(s *Source, m *TF2RconConnection)
func (*Listener) TestSource ¶
func (l *Listener) TestSource(m *TF2RconConnection) bool
type LogMessage ¶
LogMessage represents a log message in a TF2 server, and contains a timestamp and a message. The message can be a player message that contains the sender's username, steamid and other info or a server message.
func ParseLogEntry ¶
func ParseLogEntry(line string) LogMessage
ParseLogEntry parses a log entry of the format:
L 03/09/2016 - 02:50:52: <log message>\n\0
and returns a LogMessage object
type ParsedMsg ¶
type ParsedMsg struct { Type int Data interface{} }
func (*ParsedMsg) CallHandler ¶
func (p *ParsedMsg) CallHandler(handler *EventListener)
type PlayerDamage ¶
type PlayerDamage struct { PlayerTrigger Damage int `json:"damage"` Weapon string `json:"weapon"` Airshot bool `json:"airshot"` Headshot bool `json:"headshot"` }
type PlayerData ¶
type PlayerData struct { Username string `json:"username"` SteamId string `json:"steamid"` UserId string `json:"userid"` Team string `json:"team"` NewTeam string `json:"newteam"` Text string `json:"text"` Class string `json:"class"` }
When a player says something in the global chat, or when they join the game
type PlayerHeal ¶
type PlayerHeal struct { PlayerTrigger Healed int `json:"healed"` // health gained }
type PlayerKill ¶
type PlayerKill struct { PlayerTrigger Weapon string `json:"weapon"` CustomKill string `json:"customkill"` }
type PlayerTrigger ¶
type PlayerTrigger struct { //player1 triggered "Foo" against player2 Player1 PlayerData `json:"player1"` Player2 PlayerData `json:"player2"` }
type TF2RconConnection ¶
type TF2RconConnection struct {
// contains filtered or unexported fields
}
TF2RconConnection represents a rcon connection to a TF2 server
func NewTF2RconConnection ¶
func NewTF2RconConnection(address, password string) (*TF2RconConnection, error)
NewTF2RconConnection builds a new TF2RconConnection to a server at address ("ip:port") using a rcon_password password
func (*TF2RconConnection) AddTag ¶
func (c *TF2RconConnection) AddTag(newTag string) error
func (*TF2RconConnection) BanPlayer ¶
func (c *TF2RconConnection) BanPlayer(minutes int, p Player, message string) error
BanPlayer bans a player
func (*TF2RconConnection) ChangeMap ¶
func (c *TF2RconConnection) ChangeMap(mapname string) error
ChangeMap changes the map
func (*TF2RconConnection) ChangeRconPassword ¶
func (c *TF2RconConnection) ChangeRconPassword(password string) error
ChangeRconPassword changes the rcon password and updates the current connection to use the new password
func (*TF2RconConnection) ChangeServerPassword ¶
func (c *TF2RconConnection) ChangeServerPassword(password string) error
ChangeServerPassword changes the server password
func (*TF2RconConnection) ExecConfig ¶
func (c *TF2RconConnection) ExecConfig(config string) error
ExecConfig accepts a string and executes its lines one by one. Assumes UNiX line endings
func (*TF2RconConnection) GetConVar ¶
func (c *TF2RconConnection) GetConVar(cvar string) (string, error)
func (*TF2RconConnection) GetPlayers ¶
func (c *TF2RconConnection) GetPlayers() ([]Player, error)
GetPlayers returns a list of players in the server. Includes bots.
func (*TF2RconConnection) GetServerPassword ¶
func (c *TF2RconConnection) GetServerPassword() (string, error)
GetServerPassword returns the server password
func (*TF2RconConnection) KickPlayer ¶
func (c *TF2RconConnection) KickPlayer(p Player, message string) error
KickPlayer kicks a player
func (*TF2RconConnection) KickPlayerID ¶
func (c *TF2RconConnection) KickPlayerID(userID string, message string) error
Kicks a player with the given player ID
func (*TF2RconConnection) Query ¶
func (c *TF2RconConnection) Query(req string) (string, error)
Query executes a query and returns the server responses
func (*TF2RconConnection) QueryNoResp ¶
func (c *TF2RconConnection) QueryNoResp(req string) error
func (*TF2RconConnection) Reconnect ¶
func (c *TF2RconConnection) Reconnect(duration time.Duration) error
func (*TF2RconConnection) RedirectLogs ¶
func (c *TF2RconConnection) RedirectLogs(addr string) error
RedirectLogs send the logaddress_add command
func (*TF2RconConnection) RemoveTag ¶
func (c *TF2RconConnection) RemoveTag(tagName string) error
func (*TF2RconConnection) Say ¶
func (c *TF2RconConnection) Say(message string) error
Say sends a message to the TF2 server chat
func (*TF2RconConnection) Sayf ¶
func (c *TF2RconConnection) Sayf(format string, a ...interface{}) error
func (*TF2RconConnection) SetConVar ¶
func (c *TF2RconConnection) SetConVar(cvar string, val string) (string, error)
func (*TF2RconConnection) StopLogRedirection ¶
func (c *TF2RconConnection) StopLogRedirection(addr string)
func (*TF2RconConnection) UnbanPlayer ¶
func (c *TF2RconConnection) UnbanPlayer(p Player) error
UnbanPlayer unbans a player
type UnknownCommand ¶
type UnknownCommand string
func (UnknownCommand) Error ¶
func (c UnknownCommand) Error() string