model

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ScoreKindFromDTO

func ScoreKindFromDTO(clientScoreKind *string, gameType string) string

Types

type ByMessageTargetIDs

type ByMessageTargetIDs []MessageTarget

func (ByMessageTargetIDs) Len

func (a ByMessageTargetIDs) Len() int

func (ByMessageTargetIDs) Less

func (a ByMessageTargetIDs) Less(i, j int) bool

func (ByMessageTargetIDs) Swap

func (a ByMessageTargetIDs) Swap(i, j int)

type ByPlayerCountNotificationIDs

type ByPlayerCountNotificationIDs []PlayerCountNotification

func (ByPlayerCountNotificationIDs) Len

func (ByPlayerCountNotificationIDs) Less

func (a ByPlayerCountNotificationIDs) Less(i, j int) bool

func (ByPlayerCountNotificationIDs) Swap

func (a ByPlayerCountNotificationIDs) Swap(i, j int)

type ChangedServerStatus

type ChangedServerStatus struct {
	Target MessageTarget

	Prev              ServerStatus
	Curr              ServerStatus
	Offline           bool
	UserNotifications []discord.UserID
}

func (*ChangedServerStatus) Content

func (c *ChangedServerStatus) Content() string

type Channel

type Channel struct {
	GuildID discord.GuildID
	ID      discord.ChannelID
	Running bool
}

func (*Channel) RunningInt64

func (c *Channel) RunningInt64() int64

func (Channel) StatusString

func (c Channel) StatusString() string

func (Channel) String

func (c Channel) String() string

type ChannelTarget

type ChannelTarget struct {
	GuildID   discord.GuildID
	ChannelID discord.ChannelID
}

func (ChannelTarget) Less

func (a ChannelTarget) Less(other ChannelTarget) bool

type Channels

type Channels []Channel

func (Channels) StatusString

func (c Channels) StatusString() string

func (Channels) String

func (c Channels) String() string

type Client

type Client struct {
	Name     string `json:"name"`
	Clan     string `json:"clan"`
	Country  int16  `json:"country"`
	Score    int32  `json:"score"`
	IsPlayer bool   `json:"is_player"`
	Skin     *Skin  `json:"skin,omitempty"`
	Afk      *bool  `json:"afk,omitempty"`
	Team     *int16 `json:"team,omitempty"`
}

func ClientFromDTO

func ClientFromDTO(client servers.Client) Client

func (*Client) IsConnecting

func (c *Client) IsConnecting() bool

func (*Client) IsPlayerInt64

func (c *Client) IsPlayerInt64() int64

type ClientStatus

type ClientStatus struct {
	Name      string
	Clan      string
	Country   int16
	Score     int32
	IsPlayer  bool
	Team      *int16
	FlagAbbr  string
	FlagEmoji string // mapped emoji
}

func (*ClientStatus) ClanLen

func (cs *ClientStatus) ClanLen() int

func (*ClientStatus) Equals

func (cs *ClientStatus) Equals(other *ClientStatus) bool

func (*ClientStatus) Format

func (cs *ClientStatus) Format(namePadding, clanPadding int, scoreKind string) string

func (*ClientStatus) FormatClan

func (cs *ClientStatus) FormatClan(padding int) string

func (*ClientStatus) FormatName

func (cs *ClientStatus) FormatName(padding int) string

func (*ClientStatus) FormatScore

func (cs *ClientStatus) FormatScore(scoreKind string) string

func (*ClientStatus) IsBot

func (c *ClientStatus) IsBot() bool

func (*ClientStatus) IsSpectator

func (c *ClientStatus) IsSpectator() bool

func (*ClientStatus) NameLen

func (cs *ClientStatus) NameLen() int

func (*ClientStatus) TeamID

func (c *ClientStatus) TeamID() int16

func (*ClientStatus) ToEmbedFields

func (cs *ClientStatus) ToEmbedFields(namePadding, clanPadding int, scoreKind string) (fields []discord.EmbedField, charLen int)

type ClientStatusList

type ClientStatusList []ClientStatus

func (ClientStatusList) Equals

func (c ClientStatusList) Equals(other ClientStatusList) bool

func (ClientStatusList) Format

func (clients ClientStatusList) Format(namePadding, clanPadding int, scoreKind string) string

func (ClientStatusList) Iterate

func (clients ClientStatusList) Iterate(scoreKind string, f func(idx int, client ClientStatus) bool)

The index that is passed to the must not be assumed to be the current position in the list. Depending on the scoreKind, the iteration might happend in reverse while the index is still increasing.

func (ClientStatusList) ToEmbedList

func (clients ClientStatusList) ToEmbedList(color discord.Color, namePadding, clanPadding int, scoreKind string) []discord.Embed

type Flag

type Flag struct {
	ID    int16
	Abbr  string
	Emoji string
}

func Flags

func Flags() []Flag

func (Flag) String

func (f Flag) String() string

type FlagMapping

type FlagMapping struct {
	GuildID   discord.GuildID
	ChannelID discord.ChannelID
	FlagID    int16
	Abbr      string
	Emoji     string
}

func (*FlagMapping) String

func (f *FlagMapping) String() string

type FlagMappings

type FlagMappings []FlagMapping

func (FlagMappings) String

func (f FlagMappings) String() string

type Guild

type Guild struct {
	ID          discord.GuildID
	Description string
}

func (*Guild) String

func (g *Guild) String() string

type Guilds

type Guilds []Guild

func (Guilds) String

func (g Guilds) String() string

type Mentions

type Mentions []discord.UserID

func (Mentions) Equals

func (m Mentions) Equals(other Mentions) bool

type MessageMentions

type MessageMentions map[MessageTarget]Mentions

type MessageTarget

type MessageTarget struct {
	ChannelTarget
	MessageID discord.MessageID
}

func (*MessageTarget) Equals

func (t *MessageTarget) Equals(other MessageTarget) bool

func (MessageTarget) Less

func (a MessageTarget) Less(other MessageTarget) bool

func (MessageTarget) String

func (t MessageTarget) String() string

type MessageUserTarget

type MessageUserTarget struct {
	MessageTarget
	UserID discord.UserID
}

type Part

type Part struct {
	Name  string `json:"name"`
	Color *int32 `json:"color,omitempty"`
}

func PartFromDTO

func PartFromDTO(part *servers.Part) *Part

type PlayerCountNotification

type PlayerCountNotification struct {
	MessageUserTarget
	Threshold int
}

func (PlayerCountNotification) Notify

type PlayerCountNotifications

type PlayerCountNotifications []PlayerCountNotification

type Server

type Server struct {
	Timestamp    time.Time
	Address      string
	Protocols    []string
	Name         string
	Gametype     string
	Passworded   bool
	Map          string
	MapSha256Sum *string
	MapSize      *int32
	Version      string
	MaxClients   int16
	MaxPlayers   int16
	ScoreKind    string
	Clients      []Client // serialized as json into database
}

func NewServersFromDTO

func NewServersFromDTO(servers []servers.Server) ([]Server, error)

expands the servers.Server DTO into a slice of Server models

func (*Server) ProtocolsFromJSON

func (s *Server) ProtocolsFromJSON(data []byte) error

func (*Server) ProtocolsJSON

func (s *Server) ProtocolsJSON() []byte

type ServerStatus

type ServerStatus struct {
	Timestamp    time.Time // not used for equality checks
	Address      string
	Protocols    []string
	Name         string
	Gametype     string
	Passworded   bool
	Map          string
	MapSha256Sum *string
	MapSize      *int32
	Version      string
	MaxClients   int16
	MaxPlayers   int16
	ScoreKind    string
	Clients      ClientStatusList

	// not relevant for equality checks
	// derived meta data
	Spectators    ClientStatusList
	Teams         map[int16]ClientStatusList
	LongestName   int
	LongestClan   int
	NumPlayers    int // not spectators
	NumSpectators int
}

func (*ServerStatus) AddClientStatus

func (ss *ServerStatus) AddClientStatus(client ClientStatus)

func (*ServerStatus) Equals

func (ss *ServerStatus) Equals(other ServerStatus) bool

func (*ServerStatus) HasV6Protocol

func (s *ServerStatus) HasV6Protocol() bool

func (ServerStatus) Header

func (ss ServerStatus) Header() string

func (ServerStatus) NameToQuickJoinUrl

func (ss ServerStatus) NameToQuickJoinUrl() string

func (*ServerStatus) ProtocolsFromJSON

func (s *ServerStatus) ProtocolsFromJSON(data []byte) error

func (*ServerStatus) ProtocolsJSON

func (s *ServerStatus) ProtocolsJSON() []byte

func (ServerStatus) String

func (ss ServerStatus) String() string

func (ServerStatus) ToEmbeds

func (ss ServerStatus) ToEmbeds() []discord.Embed

func (*ServerStatus) TotalTeams

func (ss *ServerStatus) TotalTeams() int

type Skin

type Skin struct {
	Name       *string `json:"name,omitempty"`
	ColorBody  *int32  `json:"color_body,omitempty"`
	ColorFeet  *int32  `json:"color_feet,omitempty"`
	Body       *Part   `json:"body,omitempty"`
	Marking    *Part   `json:"marking,omitempty"`
	Decoration *Part   `json:"decoration,omitempty"`
	Hands      *Part   `json:"hands,omitempty"`
	Feet       *Part   `json:"feet,omitempty"`
	Eyes       *Part   `json:"eyes,omitempty"`
}

func SkinFromDTO

func SkinFromDTO(skin *servers.Skin) *Skin

type Tracking

type Tracking struct {
	MessageTarget
	Address string // ipv4:port or [ipv6]:port
}

Tracking is a struct that represents a tracking message which contains a single server's status.

type Trackings

type Trackings []Tracking

Jump to

Keyboard shortcuts

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