alex7kom / node-steam-tradeoffers

Steam Trade Offers for Node.js **NO LONGER MAINTAINED**
MIT License
287 stars 100 forks source link

getOffers empty #265

Closed Jallvar closed 8 years ago

Jallvar commented 8 years ago

I send yourself 1 tradeoffer. and I call to get Offer method on the event ( 'trade offers')

error = '' body = '{response : {}}'

Trade offer exactly there! Why is this happening? Using standard code

steamUser.on('tradeOffers', function (number) {
    console.log('new trades: '+number);

    if(number > 0)
        handleOffers();
});

function handleOffers() {
  offers.getOffers({
    get_received_offers: 1,
    active_only: 1,
    time_historical_cutoff: Math.round(Date.now() / 1000)
  }, function(error, body) {
    if (error) {
      return log(error);
    }

      console.log(body);

    if (
      body
      && body.response
      && body.response.trade_offers_received
    ) {

      body.response.trade_offers_received.forEach(function (offer) {
        if (offer.trade_offer_state !== 2) {
          return;
        }

        if (offer.items_to_give) {
          offers.acceptOffer({
            tradeOfferId: offer.tradeofferid
          }, function (error, result) {
            if (error) {
                if(debug)
                    console.log(error);
                return;
            }

            if(debug)
                console.log('Offer ' + offer.tradeofferid + ' accepted');

            offers.getOffer({
              tradeofferid: offer.tradeofferid
            }, function (error, result) {
              if (error) {
                return log(error);
              }

              if (result
                && result.response
                && result.response.offer
                && result.response.offer.tradeid
              ) {
                offers.getItems({
                  tradeId: result.response.offer.tradeid
                }, function (error, result) {
                  if (error) {
                    return log(error);
                  }

                });
              }
            });
          });
        } else {
          offers.declineOffer({
            tradeOfferId: offer.tradeofferid
          }, function (error, result) {
            if (error) {
              return log(error);
            }

          });
        }
      });
    }
  });
}
ghost commented 8 years ago

Maybe something bad with date on your server? Try to remove

 time_historical_cutoff: Math.round(Date.now() / 1000)
Jallvar commented 8 years ago

No. the date is configured correctly date (current / 1000) http://SSmaker.ru/de0707ed.png - query http://SSmaker.ru/1d5491b8.jpg - tradeoffer

alex7kom commented 8 years ago

This is not a library error.