| name | go-dota2-steam |
| description | Go libraries for Steam and Dota 2 GC development. Use for paralin/go-steam, paralin/go-dota2, Steam bots, Dota 2 lobby managers, GC communication, SOCache events, parties/lobbies, or Steam account automation. |
go-dota2 and go-steam Development
Go libraries for Steam protocol and Dota 2 Game Coordinator integration.
When to Use
- Building Steam bots or automation tools
- Creating Dota 2 lobby management systems
- Implementing Game Coordinator (GC) communication
- Handling SOCache (Shared Object Cache) events
- Managing Dota 2 parties, lobbies, or matches
- Steam authentication and session management
- Trading system integration
Quick Start
import (
"github.com/paralin/go-steam"
"github.com/paralin/go-dota2"
"github.com/sirupsen/logrus"
)
client := steam.NewClient()
go func() {
for event := range client.Events() {
}
}()
client.Connect()
client.Auth.LogOn(&steam.LogOnDetails{
Username: "user",
Password: "pass",
})
d := dota2.New(client, logrus.New())
d.SetPlaying(true)
d.SayHello()
Key Concepts
Event-Driven Architecture
Both libraries use channels for events. Always listen in a goroutine:
for event := range client.Events() {
switch e := event.(type) {
case *steam.LoggedOnEvent:
}
}
SOCache for Real-Time State
Dota 2 uses SOCache for lobbies, parties, items. Subscribe to changes:
eventCh, cancel, _ := d.GetCache().SubscribeType(cso.Lobby)
defer cancel()
for event := range eventCh {
lobby := event.Object.(*protocol.CSODOTALobby)
}
Context-Based Requests
Methods returning responses require context:
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
err := d.LeaveCreateLobby(ctx, details, true)
Common Tasks
Create Dota 2 Lobby
details := &protocol.CMsgPracticeLobbySetDetails{
GameName: proto.String("My Lobby"),
GameMode: proto.Uint32(uint32(protocol.DOTA_GameMode_DOTA_GAMEMODE_AP)),
ServerRegion: proto.Uint32(1),
}
d.CreateLobby(details)
Handle Authentication
case *steam.LogOnFailedEvent:
if e.Result == steam.EResult_AccountLogonDenied {
}
case *steam.MachineAuthUpdateEvent:
References
Detailed API documentation in references/:
references/go-steam-client.md - Steam client, auth, social, trading, web sessions, SteamID
references/go-steam-events.md - Steam events reference, TF2 module, inventory access
references/go-dota2-client.md - Dota 2 client, lobbies, parties, state, protocol types
references/go-dota2-api.md - SOCache, events, generated API methods, MakeRequest
External Resources