Coder Social home page Coder Social logo

go-dota2's Introduction

Dota2

Go Reference Go Report Card Widget DOI

Introduction

go-dota2 is a DOTA 2 client plugin for go-steam.

Games implemented:

Also see: the old C#/SteamKit Implementation.

This project makes use of a dynamic API generator (apigen) designed to automatically interpret Valve's various naming conventions into a intermediate API scheme representation, which is then converted into Go code.

Implementation Progress

Complete.

  • GC session state management
  • Player profile fetching / call tracking
  • SOCache tracking / state management
  • Basic chat interaction
  • Lobby tracking / state management
    • Read lobby state correctly
    • Implement normal lobby operations
  • Party tracking / state management
    • Read party and invite state correctly
    • Implement normal party operations
  • Code generation for API
  • Code generation for events

SOCache Mechanism

The caching mechanism makes it easy to watch for changes to common objects, like Lobby, LobbyInvite, Party, PartyInvite.

This mechanism is used everywhere, these objects are not exposed in their own events.

import (
	gcmm "github.com/paralin/go-dota2/protocol"
	"github.com/paralin/go-dota2/cso"
)

eventCh, eventCancel, err := dota.GetCache().SubscribeType(cso.Lobby)
if err != nil {
    return err
}

defer eventCancel()

lobbyEvent := <-eventCh
lobby := lobbyEvent.Object.(*gcmm.CSODOTALobby)

Events for the object type are emitted on the eventCh. Be sure to call eventCancel once you are done with the channel to prevent resource leaks.

The cache object also adds interfaces to get and list the current objects in the cache.

Implementation Generation

The base API implementation is generated by the apigen code. Using heuristics, request IDs are matched to response IDs, and events and action-only requests are identified. Some manual tweaking is done in the overrides file.

Next, the API information is used to build a Go code-gen set of implementations around the MakeRequest request tracking mechanism.

This means that ALL of the Dota API will be available in this codebase, although only some of it is documented.

go-steam Dependency

This library depends on go-steam.

go-dota2's People

Contributors

13k avatar macnibblet avatar mrjosh avatar paralin avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

go-dota2's Issues

How to pass `AuthCode string` (Guard Code) programatically?

how do i pass LogOnDetails.AuthCode programatically it's being send to my email?

do i parse an email and restart the bot with the AuthCode set to the Code i get from steam email?

How should I manage this? What happens if i dont pass the AuthCode?

Lobby Management

Can I somehow assign players to slots in the lobby or find out which slot the player is currently in?

Help wanted

I wrote u before an email.
I have question. Does it possible when my bot in gamespectator channel named as Game_<match_id> sends ot get client messages to see full match history?
I saw u in arcana's git dota2 repository, so i was wonder if u finishe your secret project and get full match details. Even if it practice or something like that

inviting players to a Dota 2 party

Hi @paralin

Firstly, thank you for the go-dota2 library; it's been incredibly helpful for my projects related to Dota 2.

I'm reaching out to inquire about a feature I need but haven't been able to figure out how to implement with the library: inviting players to a Dota 2 party. The documentation has been great for managing lobbies, but my current project necessitates inviting players directly to parties, and I'm unsure of how to proceed.

Could you offer any advice or point me towards the relevant parts of the API for achieving party invites? Even a nudge in the right direction would be immensely appreciated.

Thanks again for your work on go-dota2. Looking forward to your guidance.

Best, Helder

Update the generated clients

I attempted to use the tools in the repo to update the generated client code & protobuf without much success. Any chance you could look into it?

Catch event after SayHello

GDay.

Should i catch some event after SayHello for set playing status?

Or is this enough ?

game := dota2.New(c, log.New())

game.SayHello()
game.SetPlaying(true)

Thanks

Not work

It's been down for a week now. Steam changed the authorization mechanism

Create Immortal Draft lobby

Hello, is it possible to create a lobby with immortal draft enabled ? How to ? If not, will it be in a close/distant future ?
Thank you in advance :)

Getting started

Hi, where to start for using this library? Like i want to get game coordinator status from dota2.

Thank you

Concurrency problems

Hi there,

I ran into a problem that I can not call functions in the goroutine. I get the same result every time.

Whether prompt means it that functions cannot be asynchronous?
Or does it store the cache somewhere? If so, how can I reset it in order to get normal responses in goroutines?

Bellow is my implementation and results

Concurrently in goroutines without time delay

telegram-cloud-photo-size-2-5442943494114098942-y

Consistently in goroutines with time delay

telegram-cloud-photo-size-2-5442943494114098943-y

Thanks in advance!

Can't refresh the protocol after the latest release yesterday.

I tried to edit the update_protos.bash sed for replacing . in the protobuf files but to no available.
So I managed to edit the files I needed in the protocol folder and regenerate the protobuf from there.

Another thing I noticed which is that the newer files are generated with ProtoPackageIsVersion4 instead of ProtoPackageIsVersion3

the dota2 is not ready

the dota client is not ready to accept requests yet, or has just become unready.

dota2Client := dota.New(client, logrus.NewEntry(logrus.New()))
dota2Client.RequestMatchDetails(ctx, matchID)
How can I find the ctx?

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

This repository currently has no open or pending branches.

Detected dependencies

github-actions
.github/workflows/codeql-analysis.yml
  • step-security/harden-runner v2.6.0@1b05615854632b887b69ae1be8cbefe72d3ae423
  • actions/checkout v4.1.1@b4ffde65f46336ab88eb53be808477a3936bae11
  • github/codeql-action v2.22.4@49abf0ba24d0b7953cb586944e918a0b92074c80
  • github/codeql-action v2.22.4@49abf0ba24d0b7953cb586944e918a0b92074c80
  • github/codeql-action v2.22.4@49abf0ba24d0b7953cb586944e918a0b92074c80
.github/workflows/dependency-review.yml
  • step-security/harden-runner v2.6.0@1b05615854632b887b69ae1be8cbefe72d3ae423
  • actions/checkout v4.1.1@b4ffde65f46336ab88eb53be808477a3936bae11
  • actions/dependency-review-action v3.1.0@6c5ccdad469c9f8a2996bfecaec55a631a347034
.github/workflows/tests.yml
  • step-security/harden-runner v2.6.0@1b05615854632b887b69ae1be8cbefe72d3ae423
  • actions/checkout v4.1.1@b4ffde65f46336ab88eb53be808477a3936bae11
  • actions/setup-go v4.1.0@93397bea11091df50f3d7e59dc26a7711a8bcfbe
  • actions/cache v3.3.2@704facf57e6136b1bc63b828d79edcd491f0ee84
  • actions/cache v3.3.2@704facf57e6136b1bc63b828d79edcd491f0ee84
gomod
go.mod
  • go 1.19
  • github.com/fatih/camelcase v1.0.0
  • github.com/golang/protobuf v1.5.3
  • github.com/paralin/go-steam v0.0.0-20230323124938-41e2a40a56ff@41e2a40a56ff
  • github.com/pkg/errors v0.9.1
  • github.com/serenize/snaker v0.0.0-20201027110005-a7ad2135616e@a7ad2135616e
  • github.com/sirupsen/logrus v1.9.3
  • github.com/urfave/cli/v2 v2.25.7
  • google.golang.org/protobuf v1.31.0
hack/go.mod
  • go 1.19
  • github.com/golang/protobuf v1.5.3
  • github.com/golangci/golangci-lint v1.55.1
  • github.com/square/goprotowrap v0.0.0-20220325193554-9257bb483144@9257bb483144

  • Check this box to trigger a request for Renovate to run again on this repository

Need some help

I attempted to used the FindTopSourceTVGames to find some live games.
but the server_steam_id returned by FindTopSourceTVGames is not equal to http://api.steampowered.com/IDOTA2Match_<ID>/GetTopLiveGame/v1 returned.
for example, FindTopSourceTVGames returns 90154659017595900, GetTopLiveGame returns 90154659017595910, and the 90154659017595910 returned by Steam REST API is correct.

Do you know why this happened?

Unknown Shared Object

*errors.fundamental: unknown shared object type id: 2012
  File "/go/pkg/mod/github.com/paralin/[email protected]/cso/cso_types.go", line 96, in NewSharedObject
  File "/go/pkg/mod/github.com/paralin/[email protected]/socache/socache_container.go", line 27, in NewSOCacheContainer
  File "/go/pkg/mod/github.com/paralin/[email protected]/socache/socache.go", line 29, in (*SOCache).GetContainerForTypeID
  File "/go/pkg/mod/github.com/paralin/[email protected]/socache/socache.go", line 49, in (*SOCache).HandleSubscribed
  File "/go/pkg/mod/github.com/paralin/[email protected]/client_session.go", line 71, in (*Dota2).handleClientWelcome
  File "/go/pkg/mod/github.com/paralin/[email protected]/client.go", line 164, in (*Dota2).HandleGCPacket
  File "/go/pkg/mod/github.com/faceit/[email protected]/gamecoordinator.go", line 47, in (*GameCoordinator).HandlePacket
  File "/go/pkg/mod/github.com/faceit/[email protected]/client.go", line 288, in (*Client).handlePacket
  File "/go/pkg/mod/github.com/faceit/[email protected]/client.go", line 360, in (*Client).handleMulti
  File "/go/pkg/mod/github.com/faceit/[email protected]/client.go", line 280, in (*Client).handlePacket
  File "/go/pkg/mod/github.com/faceit/[email protected]/client.go", line 222, in (*Client).readLoop

Not sure if related to this issue, the bot is no longer able to send message to lobby chat which is func SendChannelMessage. Appreciated if you can show me some direction where to check.

question: acquiring a session and creating a lobby

if it is really possibly, then I have issues with creating lobby. I feel maybe the lobby doesn't have enough of arguments or it is supposed to use in another event.

case *steam.LoggedOnEvent:
	log.Printf("Logged")
	client.Social.SetPersonaState(steamlang.EPersonaState_Online)

	dota2Client := dota2.New(client, logrus.NewEntry(logrus.New()))

	dota2Client.SetPlaying(true)
	
	dota2Client.CreateLobby(&gcccm.CMsgPracticeLobbySetDetails{
		AllowCheats: proto.Bool(false),
		GameName: proto.String("test123qwe"),
		FillWithBots: proto.Bool(false),
		PassKey: proto.String("qwe123test"),
	})
	
	log.Printf("Success")

can you update paralin/Dota2

I'm still using your https://github.com/paralin/Dota2 to create lobby. but lots of proto are outdate. I donot know how to generate all these .cs file using proto.
I'm using dota_gcmessages_common_match_management.proto this protocol to automatically create lobby and get lobby status.but it doesn't work anymore. I know this go-dota2 project using latest proto, but I'm not familiar with go, sorry.
Would you please update the proto, or tell me how to generate all that cs files according proto file. Thanks very much!

Need help with developing a chatbot

Hey, I am still unaware of how to use this package to my needs. Anybody who has experience with this? I want to make a chatbot to send automated messages to regional channels inside the dota 2 client. If anybody can help me out please hmu.

New patch (7.32e)

After updating dota to patch 7.32e gc does not work. Make the necessary changes to the files please!

Where to find some example code?

I'm completely new to this project.
I want to write a simple app that given a Dota 2 match ID, retrieves the match info from the GC.

Can you point me to docs/examples on how to ahieve this please?

Thank you!

create a lobby

I have 2 problems

  1. I create a lobby with details for a custom game, it is created, but my lobby is not valid, i.e. I don’t see it in the general list of all lobbies, and this is the most important point
  2. I was never able to enter the created lobby as a bot, it always writes to me that the bot is not ready, I still can’t understand what this is connected with.

WARN: Unable to handle welcome cache

Hello.

While trying to run dota like this:

func runDota(c *steam.Client) {
  log := &log.Logger{
  Out:       os.Stderr,
  Formatter: new(log.TextFormatter),
  Hooks:     make(log.LevelHooks),
  Level:     log.DebugLevel,
  }
  
  game := dota2.New(c, log)
  
  game.SayHello()
  game.SetPlaying(true)
}

Got this warn:

DEBU[0001] sending hello to GC                          
DEBU[0001] received GC welcome                          
WARN[0001] unable to handle welcome cache                error="unknown shared object type id: 2012"
DEBU[0001] connection status changed                     new=GCConnectionStatus_HAVE_SESSION old=GCConnectionStatus_NO_SESSION
DEBU[0001] unhandled cache issue (ignore)                error="unknown shared object type id: 7"

Same issue exist in node-dota2.

Accept party request!

I want to accept a party request after i receive one
I managed to get the party invite from cso.PartyInvite channel like so:

partyInviteCh, _, err := dota2Client.GetCache().SubscribeType(cso.PartyInvite)
if err != nil {
    log.Println(err)
}

Now i want to accept the party request, i searched a little bit on the package to see if there's any AcceptParty like method but i found a method called JoinPartyFromBeacon

can anyone explain to me, am i going in right direction?
Should i call JoinPartyFromBeacon method to accept the invitation ?

if yes, what are the (partyID uint64), (accountID uint32), (beaconType int32) arguments?

Thanks

[Request] Remove logger from options

I'm feeling require logger is not good idea for 3rd party lib not related to logger itself.

For me it produces unwanted logs in console, also i need to use logrus in my project even if i already used own one with some hooks, maybe sentry, e.t.c, it also push me to download another dependency in project which is also unwanted.

I can do PR if you agree with this change and you haven't time to do this yourself.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.