cockroach Posted November 6, 2018 Report Share Posted November 6, 2018 Hello I guess i can`t manage to setup sentOfferChanged event. This is my code: const SteamUser = require('steam-user'); const TradeOfferManager = require('steam-tradeoffer-manager'); const fs = require('fs') // steam 2fa. generate steam guard code for login. const SteamTotp = require('steam-totp'); const bot = new SteamUser(); const manager = new TradeOfferManager({ steam: bot, language: 'en' }); if (fs.existsSync('polldata.json')) { manager.pollData = JSON.parse(fs.readFileSync('polldata.json').toString('utf8')); } bot.logOn({ accountName: 'user', password: 'password', twoFactorCode: SteamTotp.generateAuthCode('secret') }); bot.on('webSession', (sessionid, cookies) => { manager.setCookies(cookies); sendRandomItem(); }); function sendRandomItem() { console.log('Sending the offer') const partner = 'trade_url'; const offer = manager.createOffer(partner); offer.addTheirItem({ assetid: "id", appid: 730, contextid: 2 }); offer.setMessage( `HIIII` ); offer.send((err, status) => { if (err) { console.log({err}); } else { console.log(`Sent offer. Status: ${status}.`); } }); }; manager.on('sentOfferChanged', function (offer, oldState) { console.log(`Offer #${offer.id} changed: ${TradeOfferManager.ETradeOfferState[oldState]} -> ${TradeOfferManager.ETradeOfferState[offer.state]}`); }); manager.on('pollFailure', function (err) { console.log({err}) }) manager.on('pollData', function (pollData) { fs.writeFileSync('polldata.json', JSON.stringify(pollData)); }); This is polldata.json {"sent":{"3358172656":2}} Console log $ node ./modules/bot Sending the offer Sent offer. Status: sent. But when i accept or decline the offer sentOfferChanged doesnt fire up. Quote Link to comment Share on other sites More sharing options...
Dr. McKay Posted November 6, 2018 Report Share Posted November 6, 2018 Can you add this code and provide the output? manager.on('debug', console.log); cockroach 1 Quote Link to comment Share on other sites More sharing options...
cockroach Posted November 9, 2018 Author Report Share Posted November 9, 2018 not even the 'debug' event firing. looks like the only even fire up is 'pollData'.also i didn't set the API key on the bot Steam account. can it be the problem? Quote Link to comment Share on other sites More sharing options...
Dr. McKay Posted November 10, 2018 Report Share Posted November 10, 2018 Attach a callback to setCookies and see if you get an error back. cockroach 1 Quote Link to comment Share on other sites More sharing options...
cockroach Posted November 10, 2018 Author Report Share Posted November 10, 2018 No Error. Steam Guard App Code: DFCD5 Sending the offer Sent offer. Status: pending. I used another account that i'm sure is not limited and has active API key. the pending status is because i haveauthenticator on my phone. i confirm the trade request then on the second account i decline the offer. no log. on sending the offer pollData fire up and pollData.json modified. but no other events fired. i'm confused. Quote Link to comment Share on other sites More sharing options...
Dr. McKay Posted November 12, 2018 Report Share Posted November 12, 2018 Can you try calling manager.doPoll() yourself? cockroach 1 Quote Link to comment Share on other sites More sharing options...
cockroach Posted November 12, 2018 Author Report Share Posted November 12, 2018 bot.on('webSession', (sessionid, cookies) => { manager.setCookies(cookies, function(err) { if (err) { console.log("set Cookies", err); // process.exit(1); // Fatal error since we couldn't get our API key return; }}); sendRandomItem(); setInterval(() => doPollCustom(), 2000); }); function doPollCustom() { manager.doPoll(); console.log('polling') }this console out put. polling polling polling polling polling polling polling polling polling polling polling polling polling polling polling polling polling offer sent successfully. pollData.json : {"sent":{"3363776113":2}} no change. i declined and accepted the offer. not a single even fire. pollData seems not working for me. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.