Steam Nodejs - 检查是否已接受已发送的要约

时间:2016-07-24 15:39:16

标签: node.js steam

我正在尝试使用Tradeoffer构建一个Steam交易机器人。 我正在使用此代码检查我发送的优惠的状态:

manager.getOffer({"tradeofferid": 1414463195}, function(err, offer) {
  if (err) {
    console.log(err);
  }
  console.log(offer);
});

...但是我得到一个error说没有API KEY,即使我有它

这是完整的文件:

var SteamUser           = require('steam-user');
var SteamCommunity      = require('steamcommunity');
var SteamTotp           = require('steam-totp');
var TradeOfferManager   = require('steam-tradeoffer-manager'); // use require('steam-tradeoffer-manager') in production
var fs                  = require('fs');

var client = new SteamUser();
var manager = new TradeOfferManager({
    "steam": client, // Polling every 30 seconds is fine since we get notifications from Steam
    "domain": "localhost", // Our domain is example.com
    "language": "en" // We want English item descriptions
});
var community = new SteamCommunity();

// Steam logon options
var logOnOptions = {
    "accountName": "xxxxxxx",
    "password": "xxxxxx",
    "twoFactorCode": SteamTotp.getAuthCode("xxxxxxxx")
};

if (fs.existsSync('polldata.json')) {
    manager.pollData = JSON.parse(fs.readFileSync('polldata.json'));
}

client.logOn(logOnOptions);

client.on('loggedOn', function() {
    console.log("Logged into Steam");
});

client.on('webSession', function(sessionID, cookies) {
    manager.setCookies(cookies, function(err) {
        if (err) {
            console.log(err);
            process.exit(1); // Fatal error since we couldn't get our API key
            return;
        }

        console.log("Got API key: " + manager.apiKey);
    });

    community.setCookies(cookies);
    community.startConfirmationChecker(30000, "xxxxxxxx"); // Checks and accepts confirmations every 30 seconds
});


manager.getOffer({"tradeofferid": 1414463195}, function(err, offer){
    if(err){
    console.log(err);
    }
    console.log(offer);
    });


manager.on('pollData', function(pollData) {
    fs.writeFile('polldata.json', JSON.stringify(pollData));
});

我希望你能帮助我

0 个答案:

没有答案