seishun / node-steam-trade

Node.js wrapper around Steam trading
162 stars 36 forks source link

offerChanged and themAssets return [ undefined ] #74

Closed chrom007 closed 8 years ago

chrom007 commented 8 years ago

offerChanged and themAssets return [ undefined ] all time... what is it ? :cry:

Code:

trade.on('offerChanged', function(added, item) {
    console.log('they ' + (added ? 'added ' : 'removed '));
    console.log(item);
    console.log(trade.themAssets);
});

In console:

they added
undefined
[ undefined ]
seishun commented 8 years ago

Perhaps you could add the following above this line: https://github.com/seishun/node-steam-trade/blob/master/index.js#L185

console.log(body);
console.log(inventory);
chrom007 commented 8 years ago

body return this:

{ trade_status: 0,
  success: true,
  version: 3,
  newversion: true,
  me:
   { ready: 0,
     confirmed: 0,
     sec_since_touch: 0,
     assets: '',
     currency: '' },
  them:
   { ready: 0,
     confirmed: 0,
     sec_since_touch: 0,
     assets: [ [Object], [Object] ],
     currency: '' },
  events:
   { '1':
      { steamid: '76561198058939986',
        action: '0',
        timestamp: 1466610338,
        appid: 730,
        contextid: '2',
        assetid: '6440710501' } } }

inventory return this: {}

seishun commented 8 years ago

Does this happen every time? Does it happen with all trade partners or just specific users? Does it happen just with CS:GO items or all items? Does it happen on just one account or on all your accounts?

chrom007 commented 8 years ago

All time... All users (testing with friend). All games (CSGO, Dota, SteamGifts). And in you work?

chrom007 commented 8 years ago

Its bug in inventory... In event comes this:

EVENT====
 { steamid: '76561198055243493',
  action: '1',
  timestamp: 1466611648,
  appid: 730,
  contextid: '2',
  assetid: '6366333245' }

But this code inventory[event.assetid] (https://github.com/seishun/node-steam-trade/blob/master/index.js#L185) - don't work :( Inventory is Empty...

seishun commented 8 years ago

What happens if you log into the bot's account and trade manually with the same user?

chrom007 commented 8 years ago

dwfbuddqzso 1

seishun commented 8 years ago

Have you tried running the bot on another account?

chrom007 commented 8 years ago

Yep, same :(

seishun commented 8 years ago

Could you provide your code?

chrom007 commented 8 years ago

Yes, no problem

var Steam = require("steam");
var SteamUser = require("steam-user");
var SteamTrade = require("steam-trade");
var SteamCommunity = require("steamcommunity");

var client = new SteamUser();
var friends = new Steam.SteamFriends(client.client);
var trade = new SteamTrade();
var community = new SteamCommunity();
var fs = require("fs");

var config = {
    "login": "LOGIN",
    "password": "PASSWORD"
};

client.logOn({
    "accountName": config.login,
    "password": config.password
});

client.on("loggedOn", function(info) {
    console.log("Logged on Steam [ice_chrom]");

    client.setPersona(SteamUser.Steam.EPersonaState.Online);
    console.log("Set Status: Online\n");
});

friends.on("friendMsg", function(user, msg, type){
    if (type == 1) {
        console.log(user + ": " + msg);
    }
});

client.on("webSession", function(steamID, cookies){
    community.setCookies(cookies);
    trade.sessionID = cookies[0].split("=")[1];
    cookies.forEach(function(cookie){
        trade.setCookie(cookie);
    });
});

/* ============== TRADE ============== */

var traderID = null;

client.on("tradeRequest", function(steamID, respond){
    console.log("New TradeRequest with " + steamID);
    traderID = steamID;
    respond(true);
});

client.on("tradeStarted", function(steamID){
    trade.open(steamID);    
});

trade.on('end', function(status, getItems) {
    if (status == 'complete') {
        console.log(status);
        getItems(function(items) {
            console.log(items);
        });
    }
});

trade.on('offerChanged', function(added, item) {
    console.log('they ' + (added ? 'added ' : 'removed '));
    console.log(item);
    console.log(trade.themAssets);
    //console.log(inventory);
});

trade.on('ready', function() {
    console.log("READY");

    trade.ready(function(){
        trade.confirm();
    })
});

trade.on('chatMsg', function(msg) {
    console.log(msg);
});

trade.on("debug", function(msg){
    console.log("DEBUG: " + msg);
});
seishun commented 8 years ago

trade.open must be called with a SteamID string, but steam-user's "tradeStarted" event passes some kind of a SteamID object.

chrom007 commented 8 years ago

Thanks <3