steamid

package module
v0.0.0-...-4aeaaef Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2016 License: MIT Imports: 3 Imported by: 0

README

steamid

Build Status

This is a Go package for parsing and manipulating Steam's SteamIDs.

Documentation is done using Go's typical style. Online documentation can be found at godoc.org/github.com/nightexcessive/steamid.

Documentation

Overview

package steamid provides utilities for handling and manipulating SteamIDs

The implementation is based on and compliant with the details from https://developer.valvesoftware.com/wiki/SteamID.

Index

Constants

View Source
const (
	UniverseUnspecified = 0
	UniversePublic      = 1
	UniverseBeta        = 2
	UniverseInternal    = 3
	UniverseDev         = 4
	UniverseRC          = 5
)

Universes

See https://developer.valvesoftware.com/wiki/SteamID#Universes_Available_for_Steam_Accounts for more information.

Variables

View Source
var ErrInvalidSteamID = errors.New("invalid SteamID")

ErrInvalidSteamID is returned when an attempt is made to parse an invalid SteamID.

Functions

This section is empty.

Types

type AccountType

type AccountType uint8

AccountType represents a Steam account type.

For more information about account types, see https://developer.valvesoftware.com/wiki/SteamID#Types_of_Steam_Accounts

const (
	AccountTypeInvalid        AccountType = 0
	AccountTypeIndividual     AccountType = 1
	AccountTypeMultiseat      AccountType = 2
	AccountTypeGameServer     AccountType = 3
	AccountTypeAnonGameServer AccountType = 4
	AccountTypePending        AccountType = 5
	AccountTypeContentServer  AccountType = 6
	AccountTypeClan           AccountType = 7
	AccountTypeChat           AccountType = 8
	AccountTypeP2PSuperSeeder AccountType = 9
	AccountTypeAnonUser       AccountType = 10
)

The list of known account types

See https://developer.valvesoftware.com/wiki/SteamID#Types_of_Steam_Accounts for more information.

func (AccountType) Modifier

func (a AccountType) Modifier() uint64

Modifier returns the account type's modifier. If the account type does not have a modifier, it returns 0.

Currently the only account types with modifiers are AccountTypeIndividual and AccountTypeClan.

func (AccountType) String

func (a AccountType) String() string

String gives the name of this account type. If the name of this account type isn't known, it returns an empty string.

type SteamID

type SteamID uint64

SteamID represents a single SteamID, including its universe, instance, type, and ID.

See https://developer.valvesoftware.com/wiki/SteamID#As_Represented_in_Computer_Programs for implementation details.

func FromValues

func FromValues(universe uint8, accountInstance uint32, accountType AccountType, accountID uint32) SteamID

FromValues creates a SteamID from the given values.

func Parse

func Parse(steamID string) (SteamID, error)

Parse attempts to parse a SteamID from a string via automatic detection of the string's format. If it fails, it will return an invalid SteamID and ErrInvalidSteamID.

func ParseCommunityID

func ParseCommunityID(id uint64, accountType AccountType) SteamID

ParseCommunityID creates a SteamID from a community ID and modifier.

The account type is a non-negative number. The only valid account types for this function are AccountTypeIndividual and AccountTypeClan.

If an invalid account type is given, this function will return an invalid SteamID.

func ParseV2

func ParseV2(steamID string) (SteamID, error)

ParseV2 attempts to parse a SteamID from the version 2 textual representation. For example, STEAM_0:0:1.

func ParseV3

func ParseV3(steamID string) (SteamID, error)

ParseV3 attempts to parse a SteamID from the version 3 textual representation. For example, [U:0:2].

func (SteamID) AccountID

func (id SteamID) AccountID() uint32

AccountID returns the account ID of this SteamID. This is the unique identifier for the account.

func (SteamID) AccountInstance

func (id SteamID) AccountInstance() uint32

AccountInstance returns the instance of the account. It is usually 1 for user accounts.

func (SteamID) AccountType

func (id SteamID) AccountType() AccountType

AccountType returns the account type of this SteamID. For more information about account types, see the AccountType type.

func (SteamID) MarshalText

func (id SteamID) MarshalText() (text []byte, err error)

MarshalText implements encoding.TextMarshaler

func (SteamID) SteamID2

func (id SteamID) SteamID2() string

SteamID2 returns the version 2 textual representation of this SteamID. For example, STEAM_0:0:1.

When a SteamID type can not be turned into a version 2 ID, it returns an empty string.

func (SteamID) SteamID3

func (id SteamID) SteamID3() string

SteamID3 returns the version 3 textual representation of this SteamID. For example, [U:1:2].

When a SteamID type can not be turned into a version 3 ID, it returns an empty string.

func (SteamID) String

func (id SteamID) String() string

String returns a string representation of this SteamID. It attempts to use a version 2 SteamID first, then a version 3 SteamID, and finally the raw representation of this SteamID. The last of those can not be parsed by Parse.

func (SteamID) Universe

func (id SteamID) Universe() uint8

Universe returns the universe of this SteamID.

See https://developer.valvesoftware.com/wiki/SteamID#Universes_Available_for_Steam_Accounts for available universes.

func (*SteamID) UnmarshalText

func (id *SteamID) UnmarshalText(text []byte) (err error)

UnmarshalText implements encoding.TextUnmarshaler

Jump to

Keyboard shortcuts

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