forked from Philipp15b/go-steam
-
Notifications
You must be signed in to change notification settings - Fork 0
/
doc.go
48 lines (39 loc) · 1.4 KB
/
doc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
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.
*/
package steam