Jump to content
McKay Development

Recommended Posts

Posted

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.

Posted

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. 

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

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...