Jump to content


Photo

sentOfferChanged not emitted

node.js node-steam-tradeoffer-manager

  • Please log in to reply
6 replies to this topic

#1 cockroach

cockroach

    Newbie

  • Member
  • Pip
  • 4 posts

Posted 06 November 2018 - 03:35 AM

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.



#2 Dr. McKay

Dr. McKay

    Developer

  • Administrator
  • 1,810 posts

Posted 06 November 2018 - 05:39 PM

Can you add this code and provide the output?

manager.on('debug', console.log);

  • cockroach likes this

#3 cockroach

cockroach

    Newbie

  • Member
  • Pip
  • 4 posts

Posted 09 November 2018 - 01:44 PM

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?



#4 Dr. McKay

Dr. McKay

    Developer

  • Administrator
  • 1,810 posts

Posted 09 November 2018 - 10:46 PM

Attach a callback to setCookies and see if you get an error back.


  • cockroach likes this

#5 cockroach

cockroach

    Newbie

  • Member
  • Pip
  • 4 posts

Posted 10 November 2018 - 08:22 AM

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 have

authenticator 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. 



#6 Dr. McKay

Dr. McKay

    Developer

  • Administrator
  • 1,810 posts

Posted 12 November 2018 - 12:57 AM

Can you try calling manager.doPoll() yourself?


  • cockroach likes this

#7 cockroach

cockroach

    Newbie

  • Member
  • Pip
  • 4 posts

Posted 12 November 2018 - 02:45 AM

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. 







Also tagged with one or more of these keywords: node.js, node-steam-tradeoffer-manager

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users