Documentation ¶
Overview ¶
This package allows you to automate actions on Valve's Steam network. It is a Go port of SteamKit.
To login, you'll have to create a new Client first. Then connect to the Steam network and wait for a ConnectedCallback. Then you may call the Login method in the Auth module with your login information. This is covered in more detail in the method's documentation. After you've received the LoggedOnEvent, you should set your persona state to online to receive friend lists etc.
package main import ( "github.com/Philipp15b/go-steam" "github.com/Philipp15b/go-steam/internal/steamlang" "io/ioutil" "log" ) func main() { myLoginInfo := new(steam.LogOnDetails) myLoginInfo.Username = "Your username" myLoginInfo.Password = "Your password" client := steam.NewClient() client.Connect() for event := range client.Events() { switch e := event.(type) { case *steam.ConnectedEvent: client.Auth.LogOn(myLoginInfo) case *steam.MachineAuthUpdateEvent: ioutil.WriteFile("sentry", e.Hash, 0666) case *steam.LoggedOnEvent: client.Social.SetPersonaState(steamlang.EPersonaState_Online) case steam.FatalErrorEvent: log.Print(e) case error: log.Print(e) } } }
Events ¶
go-steam emits events that can be read via Client.Events(). Although the channel has the type interface{}, only types from this package ending with "Event" and errors will be emitted.
Index ¶
- Variables
- func GetPublicKey(universe EUniverse) *rsa.PublicKey
- func GetRandomCM() *netutil.PortAddr
- func GetRandomEuropeCM() *netutil.PortAddr
- func GetRandomNorthAmericaCM() *netutil.PortAddr
- func GetRandomSingaporeCM() *netutil.PortAddr
- type AccountInfoEvent
- type Auth
- type ChatActionResultEvent
- type ChatEnterEvent
- type ChatInviteEvent
- type ChatMemberInfoEvent
- type ChatMsgEvent
- type ClanEventDetails
- type ClanStateEvent
- type Client
- func (c *Client) Connect() *netutil.PortAddr
- func (c *Client) ConnectEurope() *netutil.PortAddr
- func (c *Client) ConnectNorthAmerica() *netutil.PortAddr
- func (c *Client) ConnectSingapore() *netutil.PortAddr
- func (c *Client) ConnectTo(addr *netutil.PortAddr)
- func (c *Client) ConnectToBind(addr *netutil.PortAddr, local *net.TCPAddr)
- func (c *Client) Connected() bool
- func (c *Client) Disconnect()
- func (c *Client) Emit(event interface{})
- func (c *Client) Errorf(format string, a ...interface{})
- func (c *Client) Events() <-chan interface{}
- func (c *Client) Fatalf(format string, a ...interface{})
- func (c *Client) GetNextJobId() JobId
- func (c *Client) RegisterPacketHandler(handler PacketHandler)
- func (c *Client) SessionId() int32
- func (c *Client) SteamId() SteamId
- func (c *Client) Write(msg IMsg)
- type ClientCMListEvent
- type ConnectedEvent
- type DisconnectedEvent
- type FatalErrorEvent
- type FriendAddedEvent
- type FriendStateEvent
- type FriendsListEvent
- type GCPacketHandler
- type GameCoordinator
- type GroupStateEvent
- type IgnoreFriendEvent
- type LogOnDetails
- type LoggedOffEvent
- type LoggedOnEvent
- type LoginKeyEvent
- type MachineAuthUpdateEvent
- type NotificationEvent
- type NotificationType
- type Notifications
- type PacketHandler
- type PersonaStateEvent
- type ProfileInfoEvent
- type SentryHash
- type Social
- func (s *Social) AddFriend(id SteamId)
- func (s *Social) BanChatMember(room SteamId, user SteamId)
- func (s *Social) GetAvatar() string
- func (s *Social) GetPersonaName() string
- func (s *Social) GetPersonaState() EPersonaState
- func (s *Social) HandlePacket(packet *Packet)
- func (s *Social) IgnoreFriend(id SteamId, setIgnore bool)
- func (s *Social) JoinChat(id SteamId)
- func (s *Social) KickChatMember(room SteamId, user SteamId)
- func (s *Social) LeaveChat(id SteamId)
- func (s *Social) RemoveFriend(id SteamId)
- func (s *Social) RequestFriendInfo(id SteamId, requestedInfo EClientPersonaStateFlag)
- func (s *Social) RequestFriendListInfo(ids []SteamId, requestedInfo EClientPersonaStateFlag)
- func (s *Social) RequestProfileInfo(id SteamId)
- func (s *Social) SendMessage(to SteamId, entryType EChatEntryType, message string)
- func (s *Social) SetPersonaName(name string)
- func (s *Social) SetPersonaState(state EPersonaState)
- func (s *Social) UnbanChatMember(room SteamId, user SteamId)
- type StateChangeDetails
- type TradeProposedEvent
- type TradeRequestId
- type TradeResultEvent
- type TradeSessionStartEvent
- type Trading
- type Web
- type WebLoggedOnEvent
- type WebSessionIdEvent
Constants ¶
This section is empty.
Variables ¶
var CMServers = [][]string{
{
"72.165.61.174:27017",
"72.165.61.174:27018",
"72.165.61.175:27017",
"72.165.61.175:27018",
"72.165.61.176:27017",
"72.165.61.176:27018",
"72.165.61.185:27017",
"72.165.61.185:27018",
"72.165.61.187:27017",
"72.165.61.187:27018",
"72.165.61.188:27017",
"72.165.61.188:27018",
"209.197.29.196:27017",
"209.197.29.197:27017",
},
{
"146.66.152.12:27017",
"146.66.152.12:27018",
"146.66.152.12:27019",
"146.66.152.13:27017",
"146.66.152.13:27018",
"146.66.152.13:27019",
"146.66.152.14:27017",
"146.66.152.14:27018",
"146.66.152.14:27019",
"146.66.152.15:27017",
"146.66.152.15:27018",
"146.66.152.15:27019",
},
{
"103.28.54.10:27017",
"103.28.54.11:27017",
},
}
CMServers contains a list of worlwide servers
Functions ¶
func GetPublicKey ¶
func GetRandomCM ¶
GetRandomCM returns back a random server anywhere
func GetRandomEuropeCM ¶
GetRandomEuropeCM returns back a random server in europe
func GetRandomNorthAmericaCM ¶
GetRandomNorthAmericaCM returns back a random server in north america
func GetRandomSingaporeCM ¶
GetRandomSingaporeCM returns back a random server in singapore
Types ¶
type AccountInfoEvent ¶
type Auth ¶
type Auth struct {
// contains filtered or unexported fields
}
func (*Auth) HandlePacket ¶
func (a *Auth) HandlePacket(packet *Packet)
func (*Auth) LogOn ¶
func (a *Auth) LogOn(details *LogOnDetails)
Log on with the given details. You must always specify username and password. For the first login, don't set an authcode or a hash and you'll receive an error and Steam will send you an authcode. Then you have to login again, this time with the authcode. Shortly after logging in, you'll receive a MachineAuthUpdateEvent with a hash which allows you to login without using an authcode in the future.
If you don't use Steam Guard, username and password are enough.
type ChatActionResultEvent ¶
type ChatActionResultEvent struct { ChatRoomId SteamId `json:",string"` ChatterId SteamId `json:",string"` Action EChatAction Result EChatActionResult }
Fired when a chat action has completed
type ChatEnterEvent ¶
type ChatEnterEvent struct { ChatRoomId SteamId `json:",string"` FriendId SteamId `json:",string"` ChatRoomType EChatRoomType OwnerId SteamId `json:",string"` ClanId SteamId `json:",string"` ChatFlags byte EnterResponse EChatRoomEnterResponse Name string }
Fired in response to joining a chat
type ChatInviteEvent ¶
type ChatInviteEvent struct { InvitedId SteamId `json:",string"` ChatRoomId SteamId `json:",string"` PatronId SteamId `json:",string"` ChatRoomType EChatRoomType FriendChatId SteamId `json:",string"` ChatRoomName string GameId uint64 `json:",string"` }
Fired when a chat invite is received
type ChatMemberInfoEvent ¶
type ChatMemberInfoEvent struct { ChatRoomId SteamId `json:",string"` Type EChatInfoType StateChangeInfo StateChangeDetails }
Fired in response to a chat member's info being received
type ChatMsgEvent ¶
type ChatMsgEvent struct { ChatRoomId SteamId `json:",string"` // not set for friend messages ChatterId SteamId `json:",string"` Message string EntryType EChatEntryType }
Fired when the client receives a message from either a friend or a chat room
func (*ChatMsgEvent) IsMessage ¶
func (c *ChatMsgEvent) IsMessage() bool
Whether the type is ChatMsg
type ClanEventDetails ¶
type ClanStateEvent ¶
type ClanStateEvent struct { ClandId SteamId `json:",string"` StateFlags EClientPersonaStateFlag AccountFlags EAccountFlags ClanName string Avatar string MemberTotalCount uint32 MemberOnlineCount uint32 MemberChattingCount uint32 MemberInGameCount uint32 Events []ClanEventDetails Announcements []ClanEventDetails }
Fired when a clan's state has been changed
type Client ¶
type Client struct { Auth *Auth Social *Social Web *Web Notifications *Notifications Trading *Trading GC *GameCoordinator ConnectionTimeout time.Duration // contains filtered or unexported fields }
Represents a client to the Steam network. Always poll events from the channel returned by Events() or receiving messages will stop. All access, unless otherwise noted, should be threadsafe.
When a FatalErrorEvent is emitted, the connection is automatically closed. The same client can be used to reconnect. Other errors don't have any effect.
func (*Client) Connect ¶
Connects to a random server of the included list of connection managers and returns the address. If this client is already connected, it is disconnected first.
You will receive a ServerListEvent after logging in which contains a new list of servers of which you should choose one yourself and connect with ConnectTo since the included list may not always be up to date.
func (*Client) ConnectEurope ¶
ConnectEurope Connects to a random Europe server on the Steam network
func (*Client) ConnectNorthAmerica ¶
ConnectNorthAmerica Connects to a random North American server on the Steam network
func (*Client) ConnectSingapore ¶
ConnectSingapore Connects to a random SG server on the Steam network
func (*Client) ConnectTo ¶
Connects to a specific server. If this client is already connected, it is disconnected first.
func (*Client) ConnectToBind ¶
Connects to a specific server, and binds to a specified local IP
func (*Client) Disconnect ¶
func (c *Client) Disconnect()
func (*Client) Events ¶
func (c *Client) Events() <-chan interface{}
Get the event channel. By convention all events are pointers, except for errors. It is never closed.
func (*Client) GetNextJobId ¶
func (c *Client) GetNextJobId() JobId
func (*Client) RegisterPacketHandler ¶
func (c *Client) RegisterPacketHandler(handler PacketHandler)
Registers a PacketHandler that receives all incoming packets.
type ClientCMListEvent ¶
A list of connection manager addresses to connect to in the future. You should always save them and then select one of these instead of the builtin ones for the next connection.
type ConnectedEvent ¶
type ConnectedEvent struct{}
type DisconnectedEvent ¶
type DisconnectedEvent struct{}
type FatalErrorEvent ¶
type FatalErrorEvent error
When this event is emitted by the Client, the connection is automatically closed. This may be caused by a network error, for example.
type FriendAddedEvent ¶
type FriendAddedEvent struct { Result EResult SteamId SteamId `json:",string"` PersonaName string }
Fired in response to adding a friend to your friends list
type FriendStateEvent ¶
type FriendStateEvent struct { SteamId SteamId `json:",string"` Relationship EFriendRelationship }
func (*FriendStateEvent) IsFriend ¶
func (f *FriendStateEvent) IsFriend() bool
type FriendsListEvent ¶
type FriendsListEvent struct{}
type GCPacketHandler ¶
type GCPacketHandler interface {
HandleGCPacket(*GCPacket)
}
type GameCoordinator ¶
type GameCoordinator struct {
// contains filtered or unexported fields
}
func (*GameCoordinator) HandlePacket ¶
func (g *GameCoordinator) HandlePacket(packet *Packet)
func (*GameCoordinator) RegisterPacketHandler ¶
func (g *GameCoordinator) RegisterPacketHandler(handler GCPacketHandler)
func (*GameCoordinator) SetGamesPlayed ¶
func (g *GameCoordinator) SetGamesPlayed(appIds ...uint64)
Sets you in the given games. Specify none to quit all games.
func (*GameCoordinator) Write ¶
func (g *GameCoordinator) Write(msg IGCMsg)
type GroupStateEvent ¶
type GroupStateEvent struct { SteamId SteamId `json:",string"` Relationship EClanRelationship }
func (*GroupStateEvent) IsMember ¶
func (g *GroupStateEvent) IsMember() bool
type IgnoreFriendEvent ¶
type IgnoreFriendEvent struct {
Result EResult
}
Fired in response to ignoring a friend
type LogOnDetails ¶
type LogOnDetails struct { Username string Password string AuthCode string SentryFileHash SentryHash }
type LoggedOffEvent ¶
type LoggedOffEvent struct {
Result EResult
}
type LoggedOnEvent ¶
type LoggedOnEvent struct { Result EResult ExtendedResult EResult OutOfGameSecsPerHeartbeat int32 InGameSecsPerHeartbeat int32 PublicIp uint32 ServerTime uint32 AccountFlags EAccountFlags ClientSteamId SteamId `json:",string"` EmailDomain string CellId uint32 CellIdPingThreshold uint32 Steam2Ticket []byte UsePics bool WebApiUserNonce string IpCountryCode string VanityUrl string NumLoginFailuresToMigrate int32 NumDisconnectsToMigrate int32 }
type LoginKeyEvent ¶
type MachineAuthUpdateEvent ¶
type MachineAuthUpdateEvent struct {
Hash []byte
}
type NotificationEvent ¶
type NotificationEvent struct { Type NotificationType Count uint }
This event is emitted for every CMsgClientUserNotifications message and likewise only used for trade offers. Unlike the the above it is also emitted when the count of a type that was tracked before by this Notifications instance reaches zero.
type Notifications ¶
type Notifications struct {
// contains filtered or unexported fields
}
func (*Notifications) HandlePacket ¶
func (n *Notifications) HandlePacket(packet *Packet)
type PacketHandler ¶
type PacketHandler interface {
HandlePacket(*Packet)
}
type PersonaStateEvent ¶
type PersonaStateEvent struct { StatusFlags EClientPersonaStateFlag FriendId SteamId `json:",string"` State EPersonaState StateFlags EPersonaStateFlag GameAppId uint32 GameId uint64 `json:",string"` GameName string GameServerIp uint32 GameServerPort uint32 QueryPort uint32 SourceSteamId SteamId `json:",string"` GameDataBlob []byte Name string Avatar string LastLogOff uint32 LastLogOn uint32 ClanRank uint32 ClanTag string OnlineSessionInstances uint32 PublishedSessionId uint32 PersonaSetByUser bool FacebookName string FacebookId uint64 `json:",string"` }
Fired when someone changing their friend details
type ProfileInfoEvent ¶
type ProfileInfoEvent struct { Result EResult SteamId SteamId `json:",string"` TimeCreated uint32 RealName string CityName string StateName string CountryName string Headline string Summary string }
Fired in response to requesting profile info for a user
type SentryHash ¶
type SentryHash []byte
type Social ¶
type Social struct { Friends *socialcache.FriendsList Groups *socialcache.GroupsList Chats *socialcache.ChatsList // contains filtered or unexported fields }
Provides access to social aspects of Steam.
func (*Social) AddFriend ¶
func (s *Social) AddFriend(id SteamId)
Adds a friend to your friends list or accepts a friend. You'll receive a FriendStateEvent for every new/changed friend
func (*Social) BanChatMember ¶
func (s *Social) BanChatMember(room SteamId, user SteamId)
Bans the specified chat member from the given chat room
func (*Social) GetPersonaName ¶
Gets the local user's persona name
func (*Social) GetPersonaState ¶
func (s *Social) GetPersonaState() EPersonaState
Gets the local user's persona state
func (*Social) HandlePacket ¶
func (s *Social) HandlePacket(packet *Packet)
func (*Social) IgnoreFriend ¶
Ignores or unignores a friend on Steam
func (*Social) KickChatMember ¶
func (s *Social) KickChatMember(room SteamId, user SteamId)
Kicks the specified chat member from the given chat room
func (*Social) RemoveFriend ¶
func (s *Social) RemoveFriend(id SteamId)
Removes a friend from your friends list
func (*Social) RequestFriendInfo ¶
func (s *Social) RequestFriendInfo(id SteamId, requestedInfo EClientPersonaStateFlag)
Requests persona state for a specified SteamId
func (*Social) RequestFriendListInfo ¶
func (s *Social) RequestFriendListInfo(ids []SteamId, requestedInfo EClientPersonaStateFlag)
Requests persona state for a list of specified SteamIds
func (*Social) RequestProfileInfo ¶
func (s *Social) RequestProfileInfo(id SteamId)
Requests profile information for a specified SteamId
func (*Social) SendMessage ¶
Sends a chat message to ether a room or friend
func (*Social) SetPersonaName ¶
Sets the local user's persona name and broadcasts it over the network
func (*Social) SetPersonaState ¶
func (s *Social) SetPersonaState(state EPersonaState)
Sets the local user's persona state and broadcasts it over the network
func (*Social) UnbanChatMember ¶
func (s *Social) UnbanChatMember(room SteamId, user SteamId)
Unbans the specified chat member from the given chat room
type StateChangeDetails ¶
type StateChangeDetails struct { ChatterActedOn SteamId `json:",string"` StateChange EChatMemberStateChange ChatterActedBy SteamId `json:",string"` }
type TradeProposedEvent ¶
type TradeProposedEvent struct { RequestId TradeRequestId Other SteamId `json:",string"` }
type TradeRequestId ¶
type TradeRequestId uint32
type TradeResultEvent ¶
type TradeResultEvent struct { RequestId TradeRequestId Response EEconTradeResponse Other SteamId `json:",string"` // Number of days Steam Guard is required to have been active NumDaysSteamGuardRequired uint32 // Number of days a new device cannot trade for. NumDaysNewDeviceCooldown uint32 // Default number of days one cannot trade after a password reset. DefaultNumDaysPasswordResetProbation uint32 // See above. NumDaysPasswordResetProbation uint32 }
type TradeSessionStartEvent ¶
type TradeSessionStartEvent struct {
Other SteamId `json:",string"`
}
type Trading ¶
type Trading struct {
// contains filtered or unexported fields
}
Provides access to the Steam client's part of Steam Trading, that is bootstrapping the trade. The trade itself is not handled by the Steam client itself, but it's a part of the Steam website.
You'll receive a TradeProposedEvent when a friend proposes a trade. You can accept it with the RespondRequest method. You can request a trade yourself with RequestTrade.
func (*Trading) CancelRequest ¶
func (t *Trading) CancelRequest(other SteamId)
This cancels a request made with RequestTrade.
func (*Trading) HandlePacket ¶
func (t *Trading) HandlePacket(packet *Packet)
func (*Trading) RequestTrade ¶
func (t *Trading) RequestTrade(other SteamId)
Requests a trade. You'll receive a TradeResultEvent if the request fails or if the friend accepted the trade.
func (*Trading) RespondRequest ¶
func (t *Trading) RespondRequest(requestId TradeRequestId, accept bool)
Responds to a TradeProposedEvent.
type Web ¶
type Web struct { // The `sessionid` cookie required to use the steam website. // This cookie may contain a characters that will need to be URL-escaped, otherwise // Steam (probably) interprets is as a string. // When used as an URL paramter this is automatically escaped by the Go HTTP package. SessionId string // The `steamLogin` cookie required to use the steam website. Already URL-escaped. // This is only available after calling LogOn(). SteamLogin string // The `steamLoginSecure` cookie required to use the steam website over HTTPs. Already URL-escaped. // This is only availbile after calling LogOn(). SteamLoginSecure string // contains filtered or unexported fields }
func (*Web) HandlePacket ¶
func (w *Web) HandlePacket(packet *Packet)
type WebLoggedOnEvent ¶
type WebLoggedOnEvent struct{}
type WebSessionIdEvent ¶
type WebSessionIdEvent struct{}
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
inventory
Includes inventory types as used in the trade package
|
Includes inventory types as used in the trade package |
This program generates the protobuf and SteamLanguage files from the SteamKit data.
|
This program generates the protobuf and SteamLanguage files from the SteamKit data. |
This package includes some basics for the Steam protocol.
|
This package includes some basics for the Steam protocol. |
steamlang
Contains code generated from SteamKit's SteamLanguage data.
|
Contains code generated from SteamKit's SteamLanguage data. |
Includes helper types for working with JSON data
|
Includes helper types for working with JSON data |
Utilities for reading and writing of binary data
|
Utilities for reading and writing of binary data |
Provides access to TF2 Game Coordinator functionality.
|
Provides access to TF2 Game Coordinator functionality. |
Allows automation of Steam Trading.
|
Allows automation of Steam Trading. |
tradeapi
Wrapper around the HTTP trading API for type safety 'n' stuff.
|
Wrapper around the HTTP trading API for type safety 'n' stuff. |
Implements methods to interact with the official Trade Offer API.
|
Implements methods to interact with the official Trade Offer API. |