简体   繁体   English

Node JS Steam交易机器人

[英]Node js steam trade bot

I'm trying to make a trade bot, but I have a problem with it. 我正在尝试制作一个贸易机器人,但是我有一个问题。 When I make an offer to the bot and I want to accept it, the bot doesn't do anything. 当我向机器人提出要约并要接受它时,该机器人不会执行任何操作。 Decline is working very well, but the accept is not. 拒绝效果很好,但接受效果却不好。

https://github.com/seishun/node-steam-trade https://github.com/seishun/node-steam-trade

Here is my code: 这是我的代码:

steam.on('tradeOffers', function(number) {
  if (number > 0) {
    offers.getOffers({
      get_received_offers: 1,
      active_only: 1,
      time_historical_cutoff: Math.round(Date.now() / 1000)
    }, function(error, body) {
      if(body.response.trade_offers_received){
        body.response.trade_offers_received.forEach(function(offer) {
          if (offer.trade_offer_state == 2) {

            console.log(offer);
            if(offer.items_to_receive){
                if(!offer.items_to_give){
                    offers.acceptOffer(offer.tradeofferid);
                }else {
                    offers.declineOffer(offer.tradeofferid);
                }
            }else {
                offers.declineOffer(offer.tradeofferid);
            }
          }
        });
      }
    });
  }
});

if(offer.items_to_receive)是问题所在,因为您不要求特定商品, offer.items_to_receive将立即返回false

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM