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.
Example code ¶
You can also find a running example in the `gsbot` package.
package main import ( "io/ioutil" "log" "github.com/tjper/steam" "github.com/tjper/steam/protocol/steamlang" ) 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 steamlang.EUniverse) *rsa.PublicKey
- func GetRandomCM() *netutil.PortAddr
- func InitializeSteamDirectory() error
- 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, error)
- func (c *Client) ConnectTo(addr *netutil.PortAddr) error
- func (c *Client) ConnectToBind(addr *netutil.PortAddr, local *net.TCPAddr) error
- 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() protocol.JobId
- func (c *Client) RegisterPacketHandler(handler PacketHandler)
- func (c *Client) SessionId() int32
- func (c *Client) SteamId() steamid.SteamId
- func (c *Client) Write(msg protocol.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 LogOnFailedEvent
- 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.SteamId)
- func (s *Social) BanChatMember(room steamid.SteamId, user steamid.SteamId)
- func (s *Social) GetAvatar() []byte
- func (s *Social) GetPersonaName() string
- func (s *Social) GetPersonaState() steamlang.EPersonaState
- func (s *Social) HandlePacket(packet *protocol.Packet)
- func (s *Social) IgnoreFriend(id steamid.SteamId, setIgnore bool)
- func (s *Social) JoinChat(id steamid.SteamId)
- func (s *Social) KickChatMember(room steamid.SteamId, user steamid.SteamId)
- func (s *Social) LeaveChat(id steamid.SteamId)
- func (s *Social) RemoveFriend(id steamid.SteamId)
- func (s *Social) RequestFriendInfo(id steamid.SteamId, requestedInfo steamlang.EClientPersonaStateFlag)
- func (s *Social) RequestFriendListInfo(ids []steamid.SteamId, requestedInfo steamlang.EClientPersonaStateFlag)
- func (s *Social) RequestOfflineMessages()
- func (s *Social) RequestProfileInfo(id steamid.SteamId)
- func (s *Social) SendMessage(to steamid.SteamId, entryType steamlang.EChatEntryType, message string)
- func (s *Social) SetPersonaName(name string)
- func (s *Social) SetPersonaState(state steamlang.EPersonaState)
- func (s *Social) UnbanChatMember(room steamid.SteamId, user steamid.SteamId)
- type StateChangeDetails
Constants ¶
This section is empty.
Variables ¶
var CMServers = []string{
"155.133.248.52:27018",
"162.254.197.40:27018",
"162.254.197.180:27019",
"155.133.248.50:27019",
"162.254.197.181:27017",
"162.254.197.42:27019",
"162.254.197.180:27017",
"162.254.197.181:27018",
"162.254.197.42:27018",
"155.133.248.50:27017",
"155.133.248.52:27019",
"155.133.248.51:27019",
"155.133.248.53:27019",
"155.133.248.51:27017",
"155.133.248.53:27017",
"155.133.248.52:27017",
"155.133.248.50:27018",
"162.254.197.180:27018",
"162.254.197.40:27017",
"162.254.197.40:27019",
"162.254.197.42:27017",
"162.254.197.181:27019",
"155.133.248.53:27018",
"155.133.248.51:27018",
"146.66.152.11:27017",
"146.66.152.10:27019",
"146.66.152.10:27017",
"146.66.152.10:27018",
"146.66.152.11:27019",
"162.254.198.133:27017",
"162.254.198.133:27018",
"162.254.198.130:27019",
"162.254.198.130:27017",
"162.254.198.132:27018",
"162.254.198.130:27018",
"162.254.198.132:27017",
"162.254.198.132:27019",
"162.254.198.131:27019",
"162.254.198.131:27017",
"146.66.152.11:27018",
"162.254.198.131:27018",
"162.254.198.133:27019",
"185.25.182.77:27017",
"185.25.182.76:27018",
"185.25.182.76:27019",
"185.25.182.77:27018",
"185.25.182.76:27017",
"185.25.182.77:27019",
"162.254.196.67:27019",
"162.254.196.67:27018",
"162.254.196.83:27018",
"162.254.196.84:27018",
"162.254.196.83:27017",
"162.254.196.84:27017",
"162.254.196.68:27019",
"162.254.196.68:27017",
"162.254.196.84:27019",
"162.254.196.67:27017",
"162.254.196.83:27019",
"162.254.196.68:27018",
"146.66.155.101:27017",
"146.66.155.101:27018",
"146.66.155.100:27017",
"146.66.155.100:27018",
"146.66.155.101:27019",
"146.66.155.100:27019",
"155.133.230.50:27017",
"155.133.230.34:27018",
"155.133.230.34:27017",
"155.133.230.50:27019",
"155.133.230.34:27019",
"155.133.230.50:27018",
"162.254.192.100:27017",
"162.254.192.108:27017",
"155.133.246.68:27017",
"155.133.246.68:27018",
"155.133.246.68:27019",
"155.133.246.69:27019",
"155.133.246.69:27017",
"155.133.246.69:27018",
"162.254.192.108:27018",
"162.254.192.101:27018",
"162.254.192.101:27019",
"162.254.192.109:27018",
"162.254.192.100:27018",
"162.254.192.109:27017",
"162.254.192.109:27019",
"162.254.192.108:27019",
"162.254.192.101:27017",
"162.254.192.100:27019",
"162.254.193.46:27019",
"162.254.193.6:27018",
"162.254.193.47:27018",
"162.254.193.6:27019",
"162.254.193.7:27018",
"162.254.193.7:27017",
"162.254.193.7:27019",
"162.254.193.47:27017",
"162.254.193.47:27019",
"162.254.193.46:27018",
}
CMServers contains a list of worlwide servers
Functions ¶
func GetRandomCM ¶
GetRandomCM returns a random server from a built-in IP list.
Prefer Client.Connect(), which uses IPs from the Steam Directory, which is always more up-to-date.
func InitializeSteamDirectory ¶
func InitializeSteamDirectory() error
Load initial server list from Steam Directory Web API. Call InitializeSteamDirectory() before Connect() to use steam directory server list instead of static one.
Types ¶
type AccountInfoEvent ¶
type Auth ¶
type Auth struct {
// contains filtered or unexported fields
}
func (*Auth) HandlePacket ¶
func (*Auth) LogOn ¶
func (a *Auth) LogOn(details *LogOnDetails)
Log on with the given details. You must always specify username and password OR username and loginkey. For the first login, don't set an authcode or a hash and you'll
receive an error (EResult_AccountLogonDenied)
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.
After the event EMsg_ClientNewLoginKey is received you can use the LoginKey to login instead of using the password.
type ChatActionResultEvent ¶
type ChatActionResultEvent struct { ChatRoomId steamid.SteamId `json:",string"` ChatterId steamid.SteamId `json:",string"` Action steamlang.EChatAction Result steamlang.EChatActionResult }
Fired when a chat action has completed
type ChatEnterEvent ¶
type ChatEnterEvent struct { ChatRoomId steamid.SteamId `json:",string"` FriendId steamid.SteamId `json:",string"` ChatRoomType steamlang.EChatRoomType OwnerId steamid.SteamId `json:",string"` ClanId steamid.SteamId `json:",string"` ChatFlags byte EnterResponse steamlang.EChatRoomEnterResponse Name string }
Fired in response to joining a chat
type ChatInviteEvent ¶
type ChatInviteEvent struct { InvitedId steamid.SteamId `json:",string"` ChatRoomId steamid.SteamId `json:",string"` PatronId steamid.SteamId `json:",string"` ChatRoomType steamlang.EChatRoomType FriendChatId steamid.SteamId `json:",string"` ChatRoomName string GameId uint64 `json:",string"` }
Fired when a chat invite is received
type ChatMemberInfoEvent ¶
type ChatMemberInfoEvent struct { ChatRoomId steamid.SteamId `json:",string"` Type steamlang.EChatInfoType StateChangeInfo StateChangeDetails }
Fired in response to a chat member's info being received
type ChatMsgEvent ¶
type ChatMsgEvent struct { ChatRoomId steamid.SteamId `json:",string"` // not set for friend messages ChatterId steamid.SteamId `json:",string"` Message string EntryType steamlang.EChatEntryType Timestamp time.Time Offline bool }
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 { ClanId steamid.SteamId `json:",string"` AccountFlags steamlang.EAccountFlags ClanName string Avatar []byte 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 Steam server and returns its address. If this client is already connected, it is disconnected first. This method tries to use an address from the Steam Directory and falls back to the built-in server list if the Steam Directory can't be reached. If you want to connect to a specific server, use `ConnectTo`.
func (*Client) ConnectTo ¶
Connects to a specific server. You may want to use one of the `GetRandom*CM()` functions in this package. 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 If this client is already connected, it is disconnected first.
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 (*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 steamlang.EResult SteamId steamid.SteamId `json:",string"` PersonaName string }
Fired in response to adding a friend to your friends list
type FriendStateEvent ¶
type FriendStateEvent struct { SteamId steamid.SteamId `json:",string"` Relationship steamlang.EFriendRelationship }
func (*FriendStateEvent) IsFriend ¶
func (f *FriendStateEvent) IsFriend() bool
type FriendsListEvent ¶
type FriendsListEvent struct{}
type GCPacketHandler ¶
type GCPacketHandler interface {
HandleGCPacket(*gamecoordinator.GCPacket)
}
type GameCoordinator ¶
type GameCoordinator struct {
// contains filtered or unexported fields
}
func (*GameCoordinator) HandlePacket ¶
func (g *GameCoordinator) HandlePacket(packet *protocol.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 gamecoordinator.IGCMsg)
type GroupStateEvent ¶
type GroupStateEvent struct { SteamId steamid.SteamId `json:",string"` Relationship steamlang.EClanRelationship }
func (*GroupStateEvent) IsMember ¶
func (g *GroupStateEvent) IsMember() bool
type IgnoreFriendEvent ¶
Fired in response to ignoring a friend
type LogOnDetails ¶
type LogOnDetails struct { Username string // If logging into an account without a login key, the account's password. Password string // If you have a Steam Guard email code, you can provide it here. AuthCode string // If you have a Steam Guard mobile two-factor authentication code, you can provide it here. TwoFactorCode string SentryFileHash SentryHash LoginKey string // true if you want to get a login key which can be used in lieu of // a password for subsequent logins. false or omitted otherwise. ShouldRememberPassword bool }
type LogOnFailedEvent ¶
type LoggedOffEvent ¶
type LoggedOnEvent ¶
type LoggedOnEvent struct { Result steamlang.EResult ExtendedResult steamlang.EResult OutOfGameSecsPerHeartbeat int32 InGameSecsPerHeartbeat int32 PublicIp uint32 ServerTime uint32 AccountFlags steamlang.EAccountFlags ClientSteamId steamid.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 *protocol.Packet)
type PacketHandler ¶
type PersonaStateEvent ¶
type PersonaStateEvent struct { StatusFlags steamlang.EClientPersonaStateFlag FriendId steamid.SteamId `json:",string"` State steamlang.EPersonaState StateFlags steamlang.EPersonaStateFlag GameAppId uint32 GameId uint64 `json:",string"` GameName string GameServerIp uint32 GameServerPort uint32 QueryPort uint32 SourceSteamId steamid.SteamId `json:",string"` GameDataBlob []byte Name string Avatar []byte LastLogOff uint32 LastLogOn uint32 ClanRank uint32 ClanTag string OnlineSessionInstances uint32 PersonaSetByUser bool RichPresence []*protobuf.CMsgClientPersonaState_Friend_KV }
Fired when someone changing their friend details
type ProfileInfoEvent ¶
type ProfileInfoEvent struct { Result steamlang.EResult SteamId 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 ¶
Adds a friend to your friends list or accepts a friend. You'll receive a FriendStateEvent for every new/changed friend
func (*Social) BanChatMember ¶
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() steamlang.EPersonaState
Gets the local user's persona state
func (*Social) HandlePacket ¶
func (*Social) IgnoreFriend ¶
Ignores or unignores a friend on Steam
func (*Social) KickChatMember ¶
Kicks the specified chat member from the given chat room
func (*Social) RemoveFriend ¶
Removes a friend from your friends list
func (*Social) RequestFriendInfo ¶
func (s *Social) RequestFriendInfo(id steamid.SteamId, requestedInfo steamlang.EClientPersonaStateFlag)
Requests persona state for a specified SteamId
func (*Social) RequestFriendListInfo ¶
func (s *Social) RequestFriendListInfo(ids []steamid.SteamId, requestedInfo steamlang.EClientPersonaStateFlag)
Requests persona state for a list of specified SteamIds
func (*Social) RequestOfflineMessages ¶
func (s *Social) RequestOfflineMessages()
Requests all offline messages and marks them as read
func (*Social) RequestProfileInfo ¶
Requests profile information for a specified SteamId
func (*Social) SendMessage ¶
func (s *Social) SendMessage(to steamid.SteamId, entryType steamlang.EChatEntryType, message string)
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 steamlang.EPersonaState)
Sets the local user's persona state and broadcasts it over the network
type StateChangeDetails ¶
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
economy
|
|
inventory
Includes inventory types as used in the trade package
|
Includes inventory types as used in the trade package |
Includes helper types for working with JSON data
|
Includes helper types for working with JSON data |
This package includes some basics for the Steam protocol.
|
This package includes some basics for the Steam protocol. |
Utilities for reading and writing of binary data
|
Utilities for reading and writing of binary data |