Jump to content
McKay Development

Sending offer and check If he have mobile authentificator


Recommended Posts

Hello, this is my code

var offer = manager.createOffer(row.trade_url);
offer.addTheirItem({"appid": 730, "contextid": 2, "assetid": row.assetid});
offer.send(function(err, status) {
   if (err) {
      console.log("[ERROR] Sending offer - " + err);
   } else {
      console.log("Offer #" + offer.id + " " + status);
   }
   console.log(status);
});

Everything works, but can I check If he have mobile authentificator on? 

Link to comment
Share on other sites

getUserDetails will tell you whether or not a trade would go into escrow.

Thanks, but that is only 1 answer. You probably dont understand what I mean. This is my block of code

repeat(20000, function() {
            //TRADE REQUEST
            objConn.query('SELECT * from trade_request', function(err, rows, fields) {
                if (!err){
                    if (rows.length > 0) {
                        var time = new Date().toISOString().replace(/T/, ' ').replace(/\..+/, '');
                        console.log("[" + time + "] " + "[INFO] There is " + rows.length + " new requests (TRADE)");
                        for (var i = 0; i < rows.length; i++) {
                            var row = rows[i];
                            if (row.type == 1) {
                                var time = new Date().toISOString().replace(/T/, ' ').replace(/\..+/, '');
                                console.log("[" + time + "] " + "[INFO] New deposit request from " + row.steamID + " (request id: " + row.ID + ")");
                                if(row.status == 1) {
                                    //send offer
                                    var offer = manager.createOffer(row.trade_url);
                                        offer.addTheirItem({"appid": 730, "contextid": 2, "assetid": row.assetid});
                                        offer.send(function(err, status) {
                                            if (err) {
                                                console.log("[ERROR] Sending offer - " + err);
                                            } else {
                                                console.log("Offer #" + offer.id + " " + status);
                                                //SET STATUS = 2
                                                objConn.query('UPDATE trade_request SET status=2 WHERE ID='+row.ID, function(err, rows, fields) {
                                                    if (!err){
                                                        console.log("[INFO] Trade request for " + row.ID + " updated to: 2.");
                                                    } else {
                                                        console.log("[INFO] Error updating status " + err);
                                                    }
                                                });
                                            }
                                            console.log(status);
                                        });
                                }
                            } else if (row.status == 2) {
                                //check sent offer
                            } else {
                                //del request
                            }
                        }

The bot check MySQL table If there is some new deposit request. In status 1, the bot will check if he have mobile authentificator, send offer and update status for deposit status to 2 and also in console I'll see 'sent' + Offer.id. And I want to ask If there is any option to check the status after like manager.checkOfferStatus(Offer.id) ?

Edited by tchosniper
Link to comment
Share on other sites

About escrow, is this code right? Because I'm getting always 0

offer.getUserDetails(function (err, them) {
                                          if(!err) {
                                            console.log(them['escrowDays']);

And I think you dont understand to my question (Its maybe because my english) but I'm need to check from offer.id if the offer is sent/confirmed/declined/(changed - counter offer) 

Link to comment
Share on other sites

Yes, that's correct.

 

You can determine when an offer changes state with the sentOfferChanged event.

Oh, thanks. But If its correct why I get 0, If the trade will be holded for 1 day? (=I had authentificator, but I removed it and now I again activate so I'm need wait 7 days to instant trades, but why I getting 0 If I should get 1?)

Link to comment
Share on other sites

Thanks, but If I fix something, I must get new error.. And now I think that is not in documentation (Atleast I didn't found it)

 offer.getUserDetails(function (err, them, me, escrowDays) {
                                          if(!err) {
                                            console.log("[INFO] Trade escrow(buddy): " + them['escrowDays'] + ", me: " + me['escrowDays']);
                                            // more code
                                          } else {
                                            console.log("[ERROR] Error - loading user data. " + err);
                                            if(err == "Error: Not Logged In") {
                                                console.log("[INFO] Reason: not login, trying relog");
                                                client.logOn({
                                                    "accountName": config.username,
                                                    "password": config.password
                                                });
                                            }
                                          }
                                        });

From this code, I was getting "[ERROR] Error - loading user data. Error: Not Logged In" so I tried add code to login 

client.logOn({
   "accountName": config.username,
   "password": config.password
});

But after I get this in console:

/root/node_modules/steam-user/components/logon.js:11
                throw new Error("Already logged on, cannot log on again");
                ^

Error: Already logged on, cannot log on again
    at SteamUser.logOn (/root/node_modules/steam-user/components/logon.js:11:9)
    at /root/bot2/ust.js:246:56
    at Object.exports.makeAnError (/root/node_modules/steam-tradeoffer-manager/lib/helpers.js:33:4)
    at manager._community.httpRequestGet (/root/node_modules/steam-tradeoffer-manager/lib/classes/TradeOffer.js:801:12)
    at SteamCommunity._checkCommunityError (/root/node_modules/steamcommunity/components/http.js:129:3)
    at Request._callback (/root/node_modules/steamcommunity/components/http.js:51:88)
    at Request.self.callback (/root/node_modules/request/request.js:186:22)
    at emitTwo (events.js:106:13)
    at Request.emit (events.js:191:7)
    at Request.<anonymous> (/root/node_modules/request/request.js:1081:10)

So I'm dont understand to "Error: Not Logged In"

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