Jump to content
McKay Development

SteamBot doesn't process trade offers


BMO_Bot

Recommended Posts

When I send a trade offer to my bot, it doesn't process it. I tried to check the code but I can't find anything wrong. Pls help!

Here the bot trades code:

function acceptOffer(offer) {
    offer.accept((err) => {
        community.checkConfirmations();
        console.log(`\x1b[32m%s\x1b[0m` ,`Il Bot ha accettato un'offerta di scambio Id: ${offer.id} .`);
        if (err) console.log(`\x1b[41m%s\x1b[0m` ,`C'è stato un errore nell'accettare un'offerta di scambio Id: ${offer.id} .`);
    });
}

function declineOffer(offer) {
    offer.decline((err) => {
        console.log(`\x1b[33m%s\x1b[0m` ,`Abbiamo rifiutato un'offerta di scambioId: ${offer.id} .`);
        if (err) console.log(`\x1b[41m%s\x1b[0m` ,`C'è stato un errore nel declino un'offerta di scambio Id: ${offer.id} .`);
    });
}

function processOffer(offer) {
    if (offer.isGlitched() || offer.state === 11) {
        console.log(`\x1b[41m%s\x1b[0m` ,`L'offerta ${offer.id} ha avuto un problema, declino in corso....`);
        declineOffer(offer);
    } else if (offer.partner.getSteamID64() === config.ownerid64) {
        acceptOffer(offer);
    }else {
        var itemsBot = offer.itemsToGive;
        var userItems = offer.itemsToReceive;
        var valoreItemBot = 0;
        var valoreUserItem = 0;
        for (var i in itemsBot) {
            var item = itemsBot.market_name;
            if(prezzi[item]) {
                valoreItemBot += prezzi[item].sell;
            } else {
                console.log(`\x1b[41m%s\x1b[0m` ,`Valore invalido offerta Id: ${offer.id} .`);
                valoreItemBot += 9999999999999999;
            }
        }
        for(var i in userItems) {
            var item = userItems.market_name;
            if(prezzi[item]) {
                valoreUserItem += prezzi[item].buy;
            } else {
            console.log(`\x1b[41m%s\x1b[0m` ,`L'utente non aveva abbastanza metallo, offerta Id: ${offer.id} .`);
            }
        }

    console.log(`\x1b[41m%s\x1b[0m` ,"Valore Degli Items Del Bot: "+ valoreItemBot);
    console.log(`\x1b[32m%s\x1b[0m`, "Valore Degli Items Dell'Utente: "+ valoreUserItem);

    if (valoreItemBot <= valoreUserItem) {
        acceptOffer(offer);
    } else {
        declineOffer(offer);
    }
  }
}

client.setOption("promptSteamGuardCode", false);

manager.on('newOffer', (offer) => {
     processOffer(offer);
});

 

Sorry if the console log are in italian, Prezzi means Prices.

Edited by BMO_Bot
Link to comment
Share on other sites

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