github markus-wa/demoinfocs-golang v2.13.0

latest releases: v4.3.0, v4.2.6, v4.2.5...
2 years ago

Support for encrypted net-messages 🥳

This means we can now read chat messages from Valve Matchmaking demos! (and more!)

Main PR: #323

New Features

Example

package main

import (
	"io/ioutil"
	"log"
	"os"

	dem "github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs"
	"github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs/events"
)

func checkErr(err error) {
	if err != nil {
		panic(err)
	}
}

func main() {
	infoF, err := os.Open("test/cs-demos/match730_003528806449641685104_1453182610_271.dem.info")
	checkErr(err)

	b, err := ioutil.ReadAll(infoF)
	checkErr(err)

	k, err := dem.MatchInfoDecryptionKey(b)
	checkErr(err)

	f, err := os.Open("test/cs-demos/match730_003528806449641685104_1453182610_271.dem")
	checkErr(err)

	defer f.Close()

	cfg := dem.DefaultParserConfig
	cfg.NetMessageDecryptionKey = k

	p := dem.NewParserWithConfig(f, cfg)

	p.RegisterEventHandler(func(message events.ChatMessage) {
		log.Println(message)
	})

	err = p.ParseToEnd()
	checkErr(err)
}

Don't miss a new demoinfocs-golang release

NewReleases is sending notifications on new releases.