Search the Community
Showing results for tags 'filter items'.
-
I have this code here mostly from the example in the steam trade offer manager. It accepts all trade offers fine (without any exceptions). I added some code where the bot would skip the trade offer if the bot didn't receive any items (a gift offer). I'm struggling to create the part of code where I can filter items and create the prices for them for buy orders and sell orders. Could anyone tell me the syntax for that? CODE SO FAR //TF2 TRADE BOTvar SteamUser = require('steam-user'); var SteamCommunity = require('steamcommunity'); var SteamTotp = require('steam-totp'); var TradeOfferManager = require('steam-tradeoffer-manager'); var fs = require('fs'); require('consoleplusplus') var client = new SteamUser(); var manager = new TradeOfferManager({ "steam": client, "domain": "example.com", "language": "en" }) var community = new SteamCommunity(); // Steam logon var logOnOptions = { "accountName": "username", "password": "password", "twoFactorCode": SteamTotp.getAuthCode("sharedSecret") }; if (fs.existsSync('polldata.json')) { manager.pollData = JSON.parse(fs.readFileSync('polldata.json')); } client.logOn(logOnOptions); client.on('loggedOn', function() { var logonmessage = "#magenta{LOGGED INTO STEAM SUCCESSFULLY}" console.info(logonmessage); }); client.on('webSession', function(sessionID, cookies) { manager.setCookies(cookies, function(err) { if (err) { console.error(err); process.exit(1); return; } console.info("Got API key: " + manager.apiKey); console.log("________________________________________________________________________________") }); community.setCookies(cookies); community.startConfirmationChecker(30000, "identitySecret"); }); manager.on('newOffer', function(offer) { console.info("New offer #" + offer.id + " from " + offer.partner.getSteam3RenderedID()); offer.accept(function(err) { if (err) { console.error("Unable to accept offer: " + err.message); } else { if(offer.itemsToReceive.length === 0) { // Gift offer console.info(offer.partner.getSteam3RenderedID() + " Offer #" + offer.id + " is a gift offer, skipping"); return; }else{ community.checkConfirmations(); console.log("Offer accepted"); } } }); }); manager.on('receivedOfferChanged', function(offer, oldState) { console.info(`Offer #${offer.id} changed: ${TradeOfferManager.ETradeOfferState[oldState]} -> ${TradeOfferManager.ETradeOfferState[offer.state]}`); if (offer.state == TradeOfferManager.ETradeOfferState.Accepted) { offer.getReceivedItems(function(err, items) { if (err) { console.error("Couldn't get received items: " + err); } else { var names = items.map(function(item) { return item.name; }); console.log("Received: " + names.join(', ')); console.log("________________________________________________________________________________") } }); } }); manager.on('pollData', function(pollData) { fs.writeFile('polldata.json', JSON.stringify(pollData)); });
-
- node.js
- javascript
-
(and 4 more)
Tagged with: