steamid

package
Version: v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2020 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package steamid provides types and functions to represent and manipulate a SteamID.

https://developer.valvesoftware.com/wiki/SteamID

Index

Constants

View Source
const (
	AccountIDOffset uint   = 0
	AccountIDMask   uint64 = 0xFFFFFFFF
)
View Source
const (
	AccountInstanceOffset uint   = 32
	AccountInstanceMask   uint64 = 0xFFFFF
)
View Source
const (
	// ChatInstanceFlagClan is set for clan based chat steam IDs.
	ChatInstanceFlagClan = ChatInstanceFlag((AccountInstanceMask + 1) >> (iota + 1))
	// ChatInstanceFlagLobby is set for lobby based chat steam IDs.
	ChatInstanceFlagLobby
	// ChatInstanceFlagMMSLobby is set for matchmaking lobby based chat steam IDs.
	ChatInstanceFlagMMSLobby
)
View Source
const (
	AccountTypeOffset      uint   = 52
	AccountTypeMask        uint64 = 0xF
	AccountTypeRuneUnknown rune   = 'i'
)
View Source
const (
	AccountUniverseOffset uint   = 56
	AccountUniverseMask   uint64 = 0xF
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountID

type AccountID uint32

AccountID represents the "account number" part of a SteamID.

It's a 32-bits field with two parts: the least significant bit indicates wether it account uses authentication or not, the highest 31 bits represent the account number.

func NewAccountID

func NewAccountID(id uint32, authServer uint32) AccountID

func (AccountID) AuthServer

func (id AccountID) AuthServer() uint32

func (AccountID) FormatString

func (id AccountID) FormatString() string

func (AccountID) ID

func (id AccountID) ID() uint32

func (AccountID) SetAuthServer

func (id AccountID) SetAuthServer(value uint32) AccountID

func (AccountID) SetID

func (id AccountID) SetID(value uint32) AccountID

func (AccountID) SteamID

func (id AccountID) SteamID() SteamID

SteamID creates a SteamID with this AccountID and default type, universe and instance.

func (AccountID) Uint32

func (id AccountID) Uint32() uint32

func (AccountID) UsesAuthServer

func (id AccountID) UsesAuthServer() bool

type AccountInstance

type AccountInstance uint32

AccountInstance is an instance of an account.

It's a 20-bit bitfield where the lowest 17 bits store the `*Instance` flags and the highest 3 bits store the `ChatInstanceFlag*` flags.

const (
	// DesktopInstance is the account instance value for a desktop.
	DesktopInstance AccountInstance = 1 << iota
	// ConsoleInstance is the account instance value for a console.
	ConsoleInstance
	// WebInstance is the account instance value for mobile or web-based.
	WebInstance
)
const (
	UnknownInstance AccountInstance = 0
)

func AccountInstanceFromString

func AccountInstanceFromString(s string) (AccountInstance, error)

func (AccountInstance) ClearChatFlags

func (i AccountInstance) ClearChatFlags() AccountInstance

func (AccountInstance) HasChatFlag

func (i AccountInstance) HasChatFlag(flag ChatInstanceFlag) bool

func (AccountInstance) IsConsole

func (i AccountInstance) IsConsole() bool

func (AccountInstance) IsDesktop

func (i AccountInstance) IsDesktop() bool

func (AccountInstance) IsWeb

func (i AccountInstance) IsWeb() bool

func (AccountInstance) SetChatFlags

func (i AccountInstance) SetChatFlags(flags ...ChatInstanceFlag) AccountInstance

type AccountType

type AccountType steamlang.EAccountType

func AccountTypeFromRune

func AccountTypeFromRune(r rune) AccountType

func (AccountType) Enum

func (AccountType) IsAnonGameServer

func (t AccountType) IsAnonGameServer() bool

func (AccountType) IsAnonUser

func (t AccountType) IsAnonUser() bool

func (AccountType) IsChat

func (t AccountType) IsChat() bool

func (AccountType) IsClan

func (t AccountType) IsClan() bool

func (AccountType) IsConsoleUser

func (t AccountType) IsConsoleUser() bool

func (AccountType) IsContentServer

func (t AccountType) IsContentServer() bool

func (AccountType) IsGameServer

func (t AccountType) IsGameServer() bool

func (AccountType) IsIndividual

func (t AccountType) IsIndividual() bool

func (AccountType) IsInvalid

func (t AccountType) IsInvalid() bool

func (AccountType) IsMultiseat

func (t AccountType) IsMultiseat() bool

func (AccountType) IsPending

func (t AccountType) IsPending() bool

func (AccountType) Rune

func (t AccountType) Rune(instance AccountInstance) rune

type ChatInstanceFlag

type ChatInstanceFlag uint32

ChatInstanceFlag is a flag a chat SteamID may have.

type SteamID

type SteamID uint64

SteamID is a steam identifier.

func New

func New(
	accountType steamlang.EAccountType,
	universe steamlang.EUniverse,
	accountID AccountID,
	instance AccountInstance,
) SteamID

New creates a SteamID with explicit parameters.

func Parse

func Parse(s string) (SteamID, error)

Parse attempts to Parse a SteamID from the given string.

It tries to Parse the string with `ParseSteam2` and if it does not match, tries to Parse the value with `ParseSteam3`.

It returns zero and a nil error if the string does not match any of the formats.

It returns a non-nil error if any of the `ParseSteam*` functions returned a non-nil error.

func ParseSteam2

func ParseSteam2(s string) (SteamID, error)

ParseSteam2 attempts to parse a SteamID from the given string in the steam2 ID format (`STEAM_X:Y:Z`).

It returns zero and a nil error if the string does not match the steam2 ID format.

It returns a non-nil error if the string matches the steam2 ID format but could not be parsed.

func ParseSteam3

func ParseSteam3(s string) (SteamID, error)

ParseSteam3 attempts to parse a SteamID from the given string in the Steam3 ID format (`[X:Y:Z:W]`).

In the Steam3 format, the last `:W` part is optional.

It returns zero and a nil error if the string does not match the Steam3 ID format.

It returns a non-nil error if the string matches the Steam3 ID format but could not be parsed.

func (SteamID) AccountID

func (id SteamID) AccountID() AccountID

func (SteamID) AccountInstance

func (id SteamID) AccountInstance() AccountInstance

func (SteamID) AccountType

func (id SteamID) AccountType() AccountType

func (SteamID) AccountUniverse

func (id SteamID) AccountUniverse() steamlang.EUniverse

func (SteamID) ChatToClan

func (id SteamID) ChatToClan() SteamID

ChatToClan returns a copy of this SteamID with type changed from Chat to Clan and the instance with Chat flags reset.

If the SteamID's type is not Chat, it returns the receiver.

func (SteamID) ClanToChat

func (id SteamID) ClanToChat() SteamID

ClanToChat returns a copy of this SteamID with type changed from Clan to Chat and the instance flagged with `ChatInstanceFlagClan`.

If the SteamID's type is not Clan, it returns the receiver.

func (SteamID) FormatString

func (id SteamID) FormatString() string

func (SteamID) SetAccountID

func (id SteamID) SetAccountID(aid AccountID) SteamID

func (SteamID) SetAccountInstance

func (id SteamID) SetAccountInstance(i AccountInstance) SteamID

func (SteamID) SetAccountType

func (id SteamID) SetAccountType(t steamlang.EAccountType) SteamID

func (SteamID) SetAccountUniverse

func (id SteamID) SetAccountUniverse(u steamlang.EUniverse) SteamID

func (SteamID) Steam2

func (id SteamID) Steam2() string

Steam2 generates a string in the steam2 ID format.

func (SteamID) Steam3

func (id SteamID) Steam3() string

Steam3 generates a string in the steam3 ID format.

It always renders the account instance, even if it's zero.

func (SteamID) String

func (id SteamID) String() string

func (SteamID) Uint64

func (id SteamID) Uint64() uint64

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL