Jump to content
McKay Development

Recommended Posts

Posted
 
 


Hello,

I got a node.js bot from someone on my friendlist.


What it does / should do:


    Instantly accept donations (offers, that don't take anything from my inventory)
    Ignore every offer that is not a donation (just don't decline it)
    Decline offers from people who have escrow
    Send a notification to my smartphone

It worked without problems for days on my RaspberryPI. Suddenly, I saw some declined trades and checked my bot.


The error log:

Bot connected to Steam!

Got API key for bot: 792A6EBE693DE91876804BXXXXX

Received new offer from 76561198293XXXXXX
Accepting offer from 76561198293XXXXXX
Sending notification!

Received new offer from 765611982934XXXXX
Accepting offer from 765611982934XXXXX
Sending notification!

Received new offer from 76561198292XXXXXX
[Error: Not Logged In]
Declined cause escrow - 76561198292XXXXXX - undefined - undefined

Received new offer from 76561198292XXXXXX
[Error: Not Logged In]
Declined cause escrow - 76561198292XXXXXX - undefined - undefined

Received new offer from 76561198292XXXXXX
[Error: Not Logged In]
Declined cause escrow - 76561198292XXXXXX - undefined - undefined

Received new offer from 76561198292XXXXXX
[Error: Not Logged In]
Declined cause escrow - 76561198292XXXXXX - undefined - undefined

Received new offer from 76561198292XXXXXX
[Error: Not Logged In]
Declined cause escrow - 76561198292XXXXXX - undefined - undefined

Received new offer from 765611982931XXXXX
[Error: Not Logged In]
Declined cause escrow - 765611982931XXXXX - undefined - undefined

Received new offer from 76561198292XXXXXX
[Error: Not Logged In]
Declined cause escrow - 76561198292XXXXXX - undefined - undefined

Received new offer from 765611982934XXXXX
[Error: Not Logged In]
Declined cause escrow - 765611982934XXXXX - undefined - undefined

Received new offer from 765611982934XXXXX
[Error: Not Logged In]
Declined cause escrow - 765611982934XXXXX - undefined - undefined

Received new offer from 765611982934XXXXX
[Error: Not Logged In]
Declined cause escrow - 765611982934XXXXX - undefined - undefined

Received new offer from 765611982934XXXXX
[Error: Not Logged In]
Declined cause escrow - 765611982934XXXXX - undefined - undefined


I greyed out the IDs for privacy reasons. He accepted two offers, then he declined ALL offers from four different accounts. Three tradebots (which belong together with the first two he accepted) and my roommates account, who 100% sure is not on escrow.


I am kind of new to JS and SteamBots in general, but I got the feeling, that there is an error in my SteamBot causing it not to be able to read the "daysTheirEscrow" and "daysMyEscrow" variable (they appear to be "undefined" in the error).



Here is my Node.JS script:
 

var Pushover = require('node-pushover');
var fs =                require('fs');
var util =              require('util');
var SteamUser =         require('steam-user');
var TradeOfferManager = require('steam-tradeoffer-manager');
var SteamCommunity =    require('steamcommunity');
var SteamTotp =         require('steam-totp');
var community =         new SteamCommunity();
var client =            new SteamUser();
var manager =           new TradeOfferManager({
    "steam": client,
    "domain": "localhost",
    "language": "en",
});
var ConfirmationChecker = false;
var shared_secret = 'x=';
var identity_secret = 'x';
 
var timekey = Math.round(Date.now() / 1000);
var code = SteamTotp.generateAuthCode(shared_secret);
 
var logOnOptions = {
    accountName: 'x',
    password: 'x',
    twoFactorCode: code
};
 
var push = new Pushover({
    token: "x",
    user: "x"
});
 
client.logOn(logOnOptions);
client.on('loggedOn', function(details) {
    console.log("Bot connected to Steam!");
});
 
client.on('webSession', function(sessionID, cookies) {
    manager.setCookies(cookies, function(err) {
        if(err) {
            console.log(err);
            process.exit(1);
            return;
        }
 
        console.log("Got API key for bot: " + manager.apiKey);
       
        community.setCookies(cookies);
        var identity_hashed = identity_secret.toString('base64');
       
        var poll_interval = setInterval( function() {
            manager.doPoll();
        }, 1000);
    });
});
 
manager.on('pollData', function(pollData) {
    fs.writeFile('polldata.json', JSON.stringify(pollData));
});
 
manager.on('newOffer', function(offer) {
    var steamID = offer.partner.getSteamID64();
   
    console.log("Received new offer from " + steamID);
    offer.getEscrowDuration(function(_err, daysTheirEscrow, daysMyEscrow) {
        if (daysTheirEscrow != 0 || daysMyEscrow != 0 || _err)
        {
            offer.decline( function() {
                console.log('Declined cause escrow - ' + steamID + ' - ' + daysTheirEscrow + ' - ' + daysMyEscrow);
            });
            console.log(_err);
        }
        else
        {
            if (!offer.itemsToGive.length || steamID == "76561198046273125")
            {
                console.log("Accepting offer from " + steamID);
                console.log("Sending notification!");
                var newItemsReceive = [];
                offer.itemsToReceive.forEach(item => newItemsReceive.push(item.market_hash_name));
                push.send("Bot accepted!", offer.message + "\nItem: " + newItemsReceive[0] + " [" + newItemsReceive.length + "]");
                offer.accept();
            }
            else
            {
                var newItems = [];
                offer.itemsToReceive.forEach(item => newItems.push(item.market_hash_name));
                var newItemsReceive = [];
                offer.itemsToReceive.forEach(item => newItemsReceive.push(item.market_hash_name));
                var newItemsGive = [];
                offer.itemsToGive.forEach(item => newItemsGive.push(item.market_hash_name));
                push.send("New offer!", "Give: " + newItemsGive + "! " + "Receive: " + newItemsReceive + "!");
                console.log("Ignoring an offer from " + steamID);
            }
        }
    });
});
 
community.on('confKeyNeeded', function(tag, callback) {
    var time = Math.floor(Date.now() / 1000);
    console.log('Conf Key Needed');
    callback(null, time, SteamTotp.generateAuthCode(shared_secret, time, tag));
});



Any help is appreciated! Thank you in advance! :)
 

 
Posted (edited)
 
 

Ah, thanks for the answer. I had an interval doing this in my code:

setInterval( function() {
	client.webLogOn();
}, 1000*60*10);

I removed these lines after a friend told me to do so to solve it. My bot was crashing a few times with the following error.

 

I am really sorry about the bad "screenshot". It was running on my Raspberry Pi and i was a bit in a rush to resart it, so i just took a photo with my phone.

 

http://imgur.com/hf0Jw1Z

 

Could you tell me what this error is about? I got it a few times before I removed the webLogOn. After I did this, I was only getting the escrow error.

Edited by Mr. Inka
Posted (edited)
 
 
 
 

Thank you!

 

I added an interval with the webLogOn after client.on('webSession', . . .

var Pushover = require('node-pushover');
var fs =                require('fs');
var util =              require('util');
var SteamUser =         require('steam-user');
var TradeOfferManager = require('steam-tradeoffer-manager');
var SteamCommunity =    require('steamcommunity');
var SteamTotp =         require('steam-totp');
var community =         new SteamCommunity();
var client =            new SteamUser();
var manager =           new TradeOfferManager({
    "steam": client,
    "domain": "localhost",
    "language": "en",
});
var ConfirmationChecker = false;
var shared_secret = 'x';
var identity_secret = 'x';
 
var timekey = Math.round(Date.now() / 1000);
var code = SteamTotp.generateAuthCode(shared_secret);
 
var logOnOptions = {
    accountName: 'x',
    password: 'x',
    twoFactorCode: code
};
 
var push = new Pushover({
    token: "x",
    user: "x"
});
 
client.logOn(logOnOptions);
client.on('loggedOn', function(details) {
    console.log("Bot connected to Steam!");
});
 
client.on('webSession', function(sessionID, cookies) {
 
//////////////////////////////////////////////////////////////////////////////


    setInterval( function() {
        client.webLogOn();
    }, 1000*60*5);
 

//////////////////////////////////////////////////////////////////////////////
 
    manager.setCookies(cookies, function(err) {
        if(err) {
            console.log(err);
            process.exit(1);
            return;
        }
 
        console.log("Got API key for bot: " + manager.apiKey);
       
        community.setCookies(cookies);
        var identity_hashed = identity_secret.toString('base64');
       
        var poll_interval = setInterval( function() {
            manager.doPoll();
        }, 1000);
    });
});
 
manager.on('pollData', function(pollData) {
    fs.writeFile('polldata.json', JSON.stringify(pollData));
});
 
manager.on('newOffer', function(offer) {
    var steamID = offer.partner.getSteamID64();
   
    console.log("Received new offer from " + steamID);
    offer.getEscrowDuration(function(_err, daysTheirEscrow, daysMyEscrow) {
        if (daysTheirEscrow != 0 || daysMyEscrow != 0 || _err)
        {
            offer.decline( function() {
                console.log('Declined cause escrow - ' + steamID + ' - ' + daysTheirEscrow + ' - ' + daysMyEscrow);
                push.send("CrashBot declined!", "Error! Error! Error!\n" + offer.message + "\nError! Error! Error!");
            });
            console.log(_err);
        }
        else
        {
            if (!offer.itemsToGive.length || steamID == "76561198046273125")
            {
                console.log("Accepting offer from " + steamID);
                console.log("Sending notification!");
                var newItemsReceive = [];
                offer.itemsToReceive.forEach(item => newItemsReceive.push(item.market_hash_name));
                push.send("CrashBot accepted!", offer.message + "\nItem: " + newItemsReceive[0] + " [" + newItemsReceive.length + "]");
                offer.accept();
            }
            else
            {
                var newItems = [];
                offer.itemsToReceive.forEach(item => newItems.push(item.market_hash_name));
                var newItemsReceive = [];
                offer.itemsToReceive.forEach(item => newItemsReceive.push(item.market_hash_name));
                var newItemsGive = [];
                offer.itemsToGive.forEach(item => newItemsGive.push(item.market_hash_name));
                push.send("New offer!", "Give: " + newItemsGive + "! " + "Receive: " + newItemsReceive + "!");
                console.log("Ignoring an offer from " + steamID);
                console.log("Give: " + newItemsGive);
                console.log("Receive: " + newItemsReceive);
            }
        }
    });
});
 
community.on('confKeyNeeded', function(tag, callback) {
    var time = Math.floor(Date.now() / 1000);
    console.log('Conf Key Needed');
    callback(null, time, SteamTotp.generateAuthCode(shared_secret, time, tag));
});

Now I am somehow getting this error right after the bot connected to Steam and reacted to an already existing offer:

Bot connected to Steam!

Got API key for bot: 792A6EBEXXXXXDE91876804B40EA1B856F

Received new offer from 76561198078452185

{ [Error: socket hang up] code: 'ECONNRESET' }

Declined cause escrow - 76561198078452185 - undefined - undefined
Edited by Mr. Inka
Posted

Okay, makes sense. I don't know enough about coding to implement a check like this myself. Will ask a friend who knows a bit more than I do. ;)

 

Additionaly information: I just realized, that whenever I get those escrow errors, I can't acces Steam through the browser or through Steam itself.

 

If I try to go to my inventory for example (Chrome / Steam Client / Android App), I get this:

 

"You don't have permission to access "http://steamcommunity.com/" on this server."

 

After a few minutes it's gone. On the phone: If i switch to mobile data instead of WiFi, it works.

 

 

This seems a bit like Steam is blocking my connection. Am I somewhere spamming them with something so an automatic block kicks in?

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