我试图制作交易机器人,但我遇到了问题。当我向机器人提出要约并且我想接受它时,机器人没有做任何事情。衰退工作得非常好,但接受不是。
https://github.com/seishun/node-steam-trade
这是我的代码:
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);
}
}
});
}
});
}
});
答案 0 :(得分:2)
if(offer.items_to_receive)
问题是,offer.items_to_receive
会立即返回false
,因为您没有要求提供特定项目。