Philipp15b / go-steam

Steam's protocol in Go to allow automation of different actions on the Steam network without running an actual Steam client. Includes APIs for friends, chatting, trading, trade offers and TF2 crafting.
https://pkg.go.dev/github.com/Philipp15b/go-steam/v3
Other
390 stars 129 forks source link

Connect #73

Closed StringNick closed 8 years ago

StringNick commented 8 years ago

Connect failed: dial tcp 209.197.29.196:27017: getsockopt: connection timed out and thats all

b1naryth1ef commented 8 years ago

That likely means the steam endpoint your attempting to connect to isn't up, or you can't route to it. Try switching to another steam endpoint.

Philipp15b commented 8 years ago

The current internal server list is pretty outdated, so you'll likely needs lots of tries before you can connect. After connecting, you can connect to one of the servers you get from the ClientCMListEvent. Alternatively, you can use InitializeSteamDirectory in the steam package.

slacki commented 8 years ago

@Philipp15b Isn't the list of servers now gathered from Steam API before connection by default? c24ff67 I thought that solved the problem of outdated server list.

StringNick commented 8 years ago

i think i try all servers from node.js servers.js

StringNick commented 8 years ago

Okay, i try to connect like that, someone told use InitializeSteamDirectory, i try use Connect to specified server, dont help. Or can someone send example how connect<3, or worked ip

package main

import (
    "io/ioutil"
    "log"

    "github.com/Philipp15b/go-steam"
    "github.com/Philipp15b/go-steam/protocol/steamlang"
)

func main() {
    myLoginInfo := new(steam.LogOnDetails)
    myLoginInfo.Username = "sa"
    myLoginInfo.Password = "sa"
    //  if sentry, err := ioutil.ReadFile("sentry"); err == nil {
    //  myLoginInfo.SentryFileHash = sentry
    //}

    client := steam.NewClient()
    err := steam.InitializeSteamDirectory()

    if err != nil {
        log.Panic(err.Error())
    }
    client.ConnectEurope()

    for event := range client.Events() {
        switch e := event.(type) {
        case *steam.ConnectedEvent:
            log.Println("Connecting SteamBot")
            client.Auth.LogOn(myLoginInfo)
        case *steam.MachineAuthUpdateEvent:
            log.Println("Wrote Sentry")
            ioutil.WriteFile("sentry", e.Hash, 0666)
        case *steam.LoggedOnEvent:
            log.Println("SteamBot logged in")
            client.Social.SetPersonaState(steamlang.EPersonaState_Online)

        case steam.FatalErrorEvent:
            log.Println(e)
        case error:
            log.Println(e)

        }
    }

}
StringNick commented 8 years ago

oh no guys, my example worked, i forgot go build<3

slacki commented 8 years ago

If you take a look at the client.go file, only Connect() method uses Steam Directory to get list of currently available servers. Use Connect() instead of ConnectEurope().

Also if the account uses the Steam Guard, you will need to provide auth code from email or auth code from steam authenticator app.

StringNick commented 8 years ago

Slacki, i connected, but now dont work next state, he connect and thats all

slacki commented 8 years ago

Could you provide more details? What do you mean by "next state"?

StringNick commented 8 years ago

Look at my main func

func main() {
    myLoginInfo := new(steam.LogOnDetails)
    myLoginInfo.Username = "st34nick"
    myLoginInfo.Password = "434"

    client := steam.NewClient()
    steam.InitializeSteamDirectory()

    client.Connect()
    for event := range client.Events() {
        switch e := event.(type) {
        case *steam.ConnectedEvent:
            log.Println("SteamBot connected to server")
            client.Auth.LogOn(myLoginInfo)
            log.Println("Trying to Auth")
        case *steam.MachineAuthUpdateEvent:
            log.Println("Use sentry")
            ioutil.WriteFile("sentry", e.Hash, 0666)
        case *steam.LoggedOnEvent:
            log.Println("SteamBot succesfully auth")
            client.Social.SetPersonaState(steamlang.EPersonaState_Online)
        case steam.FatalErrorEvent:
            log.Print(e)
        case error:
            log.Print(e)
        }
    }
}

In console

2016/01/18 18:06:43 SteamBot connected to server
2016/01/18 18:06:43 Trying to Auth

And thats all, then nothing help, i think i loose some event in auth

slacki commented 8 years ago

I suggest you to add case for steam.LogOnFailedEvent

case *steam.LogOnFailedEvent:
    log.Println(e)

Then you will be able to see what exactly failed during the authentication process.

StringNick commented 8 years ago

Ty man, i forgot about twoFactorAuth, okay now all good, thank you very, much, i will do example and post here for new ppl who use go-steam

slacki commented 8 years ago

That would be appriciated a lot, I'm sure of that. ;)

StringNick commented 8 years ago

Slacki, okay, can u help, how can i send tradeoffer, i dont understand how i should create tradeoffer.Client

slacki commented 8 years ago

Sorry mate, haven't tried that yet, cannot help you there.

YellowOrWhite commented 8 years ago
case *steam.WebSessionIdEvent:
        client.Web.LogOn()
case *steam.WebLoggedOnEvent:
        offerClient = tradeoffer.NewClient(tradeoffer.APIKey(botConfig.APIKey), client.Web.SessionId, client.Web.SteamLogin, client.Web.SteamLoginSecure)
Philipp15b commented 8 years ago

This should be fixed by a995980. The server list has been updated and the API is a bit more clear what connects to what and how.