g-man-tf2

module
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 3, 2026 License: BSD-3-Clause

README ΒΆ

πŸŽ’ G-MAN TF2

The Ultimate Team Fortress 2 Domain Module & Economy Engine for G-MAN

Go Reference Go Report Card License GitHub Stars

"Professionals have standards"

πŸ‡ΊπŸ‡Έ English β€’ πŸ‡·πŸ‡Ί Русский

G-MAN TF2 is the official, production-grade Team Fortress 2 domain module and economy engine designed for the G-MAN automation framework. It bridges Valve's Game Coordinator (GC), real-time inventory caching, and complex TF2 trading math into a high-performance, decoupled Go package.

go get github.com/lemon4ksan/g-man-tf2@latest

πŸ“‚ Project Directory Structure

pkg/
β”œβ”€β”€ tf2/              # Central TF2 GC Session Driver & SOCache Cache
β”‚   β”œβ”€β”€ tf2.go        # Module implementation & options (RegisterModule)
β”‚   β”œβ”€β”€ socache.go    # Live GC Shared Object parser & inventory keeper
β”‚   └── actions.go    # Low-level GC commands (Crafting, Achievement Unlocking)
β”œβ”€β”€ backpack/         # Unified in-memory inventory views & slot lock management
β”œβ”€β”€ crafting/         # Automated crafting & weapon smelting engine recipes
β”œβ”€β”€ schema/           # High-fidelity TF2 schema manager & items_game parser
β”œβ”€β”€ sku/              # Standardized item SKU parsers (quality, effect, paint, etc.)
β”œβ”€β”€ currency/         # Float-safe metal arithmetic & Key-to-Scrap equations
β”œβ”€β”€ services/         # Third-party platform services integrations
β”‚   β”œβ”€β”€ pricedb/      # Pricing and PriceDB Socket.IO connection sync
β”‚   β”œβ”€β”€ bptf/         # backpack.tf integrations (listing management, snap scraper)
β”‚   β”œβ”€β”€ crit/         # Crit.tf storefront listing synchronizer
β”‚   └── rep/          # Trust, feedback, and user reputation lookup utilities
β”œβ”€β”€ trading/          # Onion-style trading middlewares (pricer, limits, counters)
β”œβ”€β”€ reason/           # TF2-specific trade rejection reasons

πŸš€ Quick Start

1. Install Dependencies

You need both the core G-MAN runtime client and the TF2 domain package:

go get github.com/lemon4ksan/g-man@latest
go get github.com/lemon4ksan/g-man-tf2@latest
2. Initialize the Orchestrator

Launch the client, register the TF2 schema and backpack managers, and load active trading middlewares:

package main

import (
	"context"
	"os"

	"github.com/lemon4ksan/g-man/pkg/log"
	"github.com/lemon4ksan/g-man/pkg/steam"
	"github.com/lemon4ksan/g-man/pkg/steam/auth"
	"github.com/lemon4ksan/g-man/pkg/steam/sys/directory"
	"github.com/lemon4ksan/g-man/pkg/storage/jsonfile"
	
	// G-MAN TF2 Imports
	"github.com/lemon4ksan/g-man-tf2/pkg/backpack"
	"github.com/lemon4ksan/g-man-tf2/pkg/schema"
	"github.com/lemon4ksan/g-man-tf2/pkg/tf2"
)

func main() {
	ctx := context.Background()
	store, _ := jsonfile.New("storage.json")
	logger := log.New(log.DefaultConfig(log.LevelInfo))

	// 1. Initialize Steam Client with modular G-MAN TF2 plugins
	client, err := steam.NewClient(steam.Config{Storage: store},
		steam.WithLogger(logger),
		tf2.WithModule(),
		schema.WithModule(schema.DefaultConfig()),
		backpack.WithModule(),
	)
	if err != nil {
		panic(err)
	}
	defer client.Close()

	// 2. Fetch registered module references
	tf2Mod := tf2.From(client)
	bpMod := backpack.From(client)

	// 3. Listen for inventory updates synced via GC SOCache
	sub := client.Bus().Subscribe(&tf2.BackpackLoadedEvent{})
	go func() {
		for event := range sub.C() {
			if bpEvent, ok := event.(*tf2.BackpackLoadedEvent); ok {
				logger.Info("TF2 Inventory synchronized via SOCache!", 
					log.Int("items_count", bpEvent.Count),
				)
				
				pure := bpMod.GetPureStock()
				logger.Info("Current balances",
					log.Int("keys", pure.Keys),
					log.Float64("refined", pure.TotalRefined()),
				)
			}
		}
	}()

	// 4. Discover optimal connection server and login
	dir := directory.New(client.Service())
	server, _ := dir.GetOptimalCMServer(ctx)
	login := auth.NewLogOnDetails(os.Getenv("STEAM_USER"), os.Getenv("STEAM_PASS"))

	if err := client.Run(); err != nil {
		panic(err)
	}

	if err := client.ConnectAndLogin(ctx, server, login); err != nil {
		panic(err)
	}

	client.Wait()
}
3. Register TF2 Onion-Trading Middlewares

Add decoupled processing steps to build your custom business rule checks inside G-MAN's Trade Offer Engine:

package main

import (
	"github.com/lemon4ksan/g-man/pkg/log"
	"github.com/lemon4ksan/g-man/pkg/trading/engine"
	
	"github.com/lemon4ksan/g-man-tf2/pkg/backpack"
	"github.com/lemon4ksan/g-man-tf2/pkg/pricedb"
	"github.com/lemon4ksan/g-man-tf2/pkg/trading"
)

func RegisterPipeline(
	tradeEngine *engine.Engine,
	bp *backpack.Backpack,
	priceMgr *pricedb.Manager,
	logger log.Logger,
) {
	stockCfg := trading.StockConfig{
		MaxTotal:   3000,
		DefaultMax: 20,
		MaxPerSKU: map[string]int{
			"5021;6": 500, // Limit Mann Co. Supply Crate Keys to 500
		},
	}

	tradeEngine.Use(
		// 1. Stock checking middleware
		trading.StockLimitMiddleware(bp, stockCfg, logger),
		
		// 2. Price DB validation middleware
		trading.PricerMiddleware(priceMgr, logger),
	)
}

⚑ Memory & Performance Efficiency

G-MAN TF2 inherits G-MAN’s core focus on low-footprint systems, making it highly suitable for running dozens of concurrent accounts on a single cheap VPS:

  • Fidelity Schema Engine: Prunes excess game tracker structures (especially in LiteMode), indexing item defindexes and schema attributes in a mere ~10 MB of active heap memory.
  • SOCache Storage: Employs zero-allocation pointer mappings to reflect inventories, keeping physical memory footprint at ~25 MB RSS overall under production workloads.

🀝 Contributing

We welcome contributions to G-MAN TF2! If you're interested in refining metal combining formulas, improving the dynamic schema deserializer, or enhancing reputation lookup APIs:

  1. Review CONTRIBUTING.md for conventions.
  2. Verify changes with unit tests: go test -race ./....
  3. Open a Pull Request detailing the changes and your design logic.

β˜• Support the Development

Testing Game Coordinator states, live trade offers, and smelting workflows requires active capital to cover Steam Market transaction fees, in-game item acquisitions, and test-transaction fees. If G-man helped you automate your trading workflows or optimized your server resources, feel free to show some support:

Trade Offer

"Yeah, money well spent!"

Disclaimer: This software is not affiliated with, maintained by, or endorsed by Valve Corporation or any of its subsidiaries. Steam, Team Fortress 2, and all related Valve properties are registered trademarks of Valve Corporation. Use of this library is at your own risk.

This project is licensed under the BSD 3-Clause License. See LICENSE for full details.

Directories ΒΆ

Path Synopsis
cmd
bot command
coverage command
examples
inventory command
maintenance command
pkg
backpack
Package backpack manages the Team Fortress 2 inventory state for both local and remote profiles.
Package backpack manages the Team Fortress 2 inventory state for both local and remote profiles.
behavior/pricemanager
Package pricemanager provides a backpack.tf price manager for the g-man-tf2 bot.
Package pricemanager provides a backpack.tf price manager for the g-man-tf2 bot.
crafting
Package crafting provides automatic crafting, metal condensing, and metal-change operations for Team Fortress 2.
Package crafting provides automatic crafting, metal condensing, and metal-change operations for Team Fortress 2.
currency
Package currency provides high-performance structures and utilities for Team Fortress 2 currency math.
Package currency provides high-performance structures and utilities for Team Fortress 2 currency math.
reason
Package reason contains TF2-specific trade reasons.
Package reason contains TF2-specific trade reasons.
schema
Package schema provides a manager for the Team Fortress 2 item schema.
Package schema provides a manager for the Team Fortress 2 item schema.
services/bptf
Package bptf provides a comprehensive, high-performance Go client for the backpack.tf API, specifically designed for Team Fortress 2 trading automation.
Package bptf provides a comprehensive, high-performance Go client for the backpack.tf API, specifically designed for Team Fortress 2 trading automation.
services/crit
Package crit provides an integration client for crit.tf classifieds, group stores and showcase APIs.
Package crit provides an integration client for crit.tf classifieds, group stores and showcase APIs.
services/mannco
Package mannco provides a client for interacting with the Mannco.store API.
Package mannco provides a client for interacting with the Mannco.store API.
services/pricedb
Package pricedb provides a high-performance, strictly typed client for the PriceDB.io API.
Package pricedb provides a high-performance, strictly typed client for the PriceDB.io API.
services/rep
Package rep provides utilities for checking user bans against various ban lists.
Package rep provides utilities for checking user bans against various ban lists.
sku
Package sku implements the TF2 Stock Keeping Unit format.
Package sku implements the TF2 Stock Keeping Unit format.
tf2
Package tf2 provides integration with the Team Fortress 2 Game Coordinator.
Package tf2 provides integration with the Team Fortress 2 Game Coordinator.
trading
Package trading defines the Team Fortress 2 automated trading, valuation, and security logic.
Package trading defines the Team Fortress 2 automated trading, valuation, and security logic.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL