Documentation ¶
Overview ¶
Allows automation of Steam Trading.
Usage ¶
Like go-steam, this package is event-based. Call Poll() until the trade has ended, that is until the TradeEndedEvent is emitted.
// After receiving the steam.TradeSessionStartEvent t := trade.New(sessionIdCookie, steamLoginCookie, steamLoginSecure, event.Other) for { eventList, err := t.Poll() if err != nil { // error handling here continue } for _, event := range eventList { switch e := event.(type) { case *trade.ChatEvent: // respond to any chat message t.Chat("Trading is awesome!") case *trade.TradeEndedEvent: return // other event handlers here } } }
You can either log into steamcommunity.com and use the values of the `sessionId` and `steamLogin` cookies, or use go-steam and after logging in with client.Web.LogOn() and receiving the WebLoggedOnEvent use the `SessionId` and `SteamLogin` fields of steam.Web for the respective cookies.
It is important that there is no delay between the Poll() calls greater than the timeout of the Steam client (currently five seconds before the trade partner sees a warning) or the trade will be closed automatically by Steam.
Notes ¶
All method calls to Steam APIs are blocking. This packages' and its subpackages' types are not thread-safe and no calls to any method of the same trade instance may be done concurrently except when otherwise noted.
Index ¶
- Constants
- type ChatEvent
- type Currency
- type Item
- type ItemAddedEvent
- type ItemRemovedEvent
- type ReadyEvent
- type SetCurrencyEvent
- type Slot
- type Trade
- func (t *Trade) AddItem(slot Slot, item *Item) error
- func (t *Trade) Cancel() error
- func (t *Trade) Chat(message string) error
- func (t *Trade) Confirm() error
- func (t *Trade) Events() []interface{}
- func (t *Trade) GetMain() (*tradeapi.Main, error)
- func (t *Trade) GetOwnInventory(contextId uint64, appId uint32) (*inventory.Inventory, error)
- func (t *Trade) GetTheirInventory(contextId uint64, appId uint32) (*inventory.Inventory, error)
- func (t *Trade) Poll() ([]interface{}, error)
- func (t *Trade) RemoveItem(slot Slot, item *Item) error
- func (t *Trade) SetCurrency(amount uint, currency *Currency) error
- func (t *Trade) SetReady(ready bool) error
- func (t *Trade) Version() uint
- type TradeEndReason
- type TradeEndedEvent
- type UnreadyEvent
Constants ¶
const ( TradeEndReason_Complete TradeEndReason = 1 TradeEndReason_Cancelled = 2 TradeEndReason_Timeout = 3 TradeEndReason_Failed = 4 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ItemAddedEvent ¶
type ItemAddedEvent struct {
Item *Item
}
type ItemRemovedEvent ¶
type ItemRemovedEvent struct {
Item *Item
}
type ReadyEvent ¶
type ReadyEvent struct{}
type SetCurrencyEvent ¶
type Trade ¶
type Trade struct { ThemId steamid.SteamId MeReady, ThemReady bool // contains filtered or unexported fields }
func (*Trade) Events ¶
func (t *Trade) Events() []interface{}
Returns all queued events and removes them from the queue without performing a HTTP request, like Poll() would.
func (*Trade) GetOwnInventory ¶
func (*Trade) GetTheirInventory ¶
func (*Trade) Poll ¶
Returns the next batch of events to process. These can be queued from calls to methods like `AddItem` or, if there are no queued events, from a new HTTP request to Steam's API (blocking!). If the latter is the case, this method may also sleep before the request to conform to the polling interval of the official Steam client.
type TradeEndReason ¶
type TradeEndReason uint
type TradeEndedEvent ¶
type TradeEndedEvent struct {
Reason TradeEndReason
}
type UnreadyEvent ¶
type UnreadyEvent struct{}