1
我正在做一個steamBot,從用戶那裏拿取物品,我需要得到這個物品的名稱,並且它的價格是在我的網站上發送的。 我應該如何獲取items數組中的每個項目的名稱? 我有alreay知道項目[i] .appid assetid和其他人,但我怎麼能得到名稱和平均價格?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);
console.log('Recieved trade offer: ' + offer.tradeofferid);
var exception = false;
var items = offer.items_to_receive;
for(var i=0; i< items.length;i++)
{
if(items[i].appid != "730")
{
exception = true;
break;
}
}
var descriptionOfItems = ""; // assetid + classid
for(var i=0; i< items.length;i++)
{
appid += items[i].assetid + "-" + items[i].classid + " ";
}
if (!offer.items_to_give && !exception) {
offers.acceptOffer({tradeOfferId: offer.tradeofferid});
console.log("Offer accepted");
steam.sendMessage(offer.steamid_other, "Thanks you!");
if (offer.steamid_other !== admin) {
steam.sendMessage(admin, offer.steamid_other+ " - " + descriptionOfItems + " just donated!");
}
} else {
offers.declineOffer({tradeOfferId: offer.tradeofferid});
console.log("Don't receive items from other's games!");
}
}
});
}
});
}
});