Jump to content
McKay Development

manic

Member
  • Posts

    11
  • Joined

  • Last visited

Posts posted by manic

  1. I occasionally get trades go to the Canceled state with rollback and updated item IDs. I assume this is because cancelTime is set, the trade has been accepted by the recipient and steam is processing it when the cancelTime elapses, however I'm not sure why Steam allows it to be cancelled at that point (I think this because it used to happen more frequently until I increased the cancelTime). It's definitely not to do with escrow because trades aren't sent if it would have an escrow period and I've checked manually that the recipient doesn't have any escrow. Just letting you know because it's not one of your cases.

  2. Thinking on this again, I guess that when the offer rolls back it was technically accepted, so that might cause the tradeID property to be defined. In that case, is the only way to differentiate between a rollback and a standard cancelled offer to check if the tradeID property is defined? (Talking about offers that rolled back due to being cancelled after the receiver has accepted and confirmed the offer)

    Thanks

  3. The getExchangeDetails documentation implies that it works for trades that weren't successful 

    Quote

    If false and the trade's state is anything but Complete, InEscrow, or EscrowRollback, then the callback will report an error instead of returning the data to you. This is intended to prevent ignorant developers from blindly trusting the data they get without verifying that the trade has completed successfully. Defaults to false.

    However, it also requires the tradeID property to be defined

    Quote

    This can be called for any trade offer that has a tradeID property defined that isn't null, including those that are in escrow or have failed.

    which is described as 

    Quote

    A numeric trade ID, represented as a string, if the offer was accepted. null otherwise. This value won't be very useful to you.

    This seems contradictory, and means I can't get call getExchangeDetails on an offer that has been cancelled by the sender, which I require. (I get the error  Error: No trade ID; unable to get trade details)

     

    Am I doing something wrong or is this a bug? Thanks

  4. I'm running a bot and the majority of trade offers are not going through. 

     

    The bot logs in and handles expired sessions like this:

    let client = new SteamUser();
    let community = new SteamCommunity();
    let manager = new TradeOfferManager({
        community: community,
        steam: client, 
        domain: "example.com", 
        language: "en", 
        pollInterval: 2000
    });
    
    
    
    let logOnOptions = {
        "accountName": data.username,
        "password": data.password,
        "twoFactorCode": SteamTotp.getAuthCode(data.shared_secret)
    };
    
    client.logOn(logOnOptions);
    
    client.on('loggedOn', function() {
        console.log("Logged into Steam");
        client.setPersona(SteamUser.EPersonaState.Online);
    });
    
    client.on('webSession', function(sessionID, cookies) {
        manager.setCookies(cookies);
        community.setCookies(cookies);
        console.log("weblogon")
    });
    
    community.on("sessionExpired", function(err) {
        console.log("## Session Expired");
        client.webLogOn();
    });
    

    The bot gets new offers with 

    manager.on('newOffer', function(offer) {
    

    , makes a simple request using https://www.npmjs.com/package/request and calls offer.getUserDetails. An offer is accepted like this:

    offer.accept(accept(offer, 1));
    

    These are the two functions that handle accepting and confirming trades:

    function confirm(offer, count) {
        return function(err) {
            if (err) {
                if (count < 20) {
                    console.log(err);
                    setTimeout(community.acceptConfirmationForObject, 10000, data.identity_secret, offer.id, confirm(offer, count + 1));
                } else {
                    console.error("CONFIRM FUNCTION: ");
                    console.error(err);
                }
            }
        }
    }
    
    function accept(offer, count) {
        return function(err, status) {
            if (err) {
                if (count < 20) {
                    console.log(err);
                    setTimeout(offer.accept, 10000, accept(offer, count + 1));
                } else {
                    console.error("ACCEPT FUNCTION: ");
                    console.error(err);
                }
    
            } else {
                if (status === "pending") {
                    community.acceptConfirmationForObject(data.identity_secret, offer.id, confirm(offer, 1));
                }
    
            }
        }
    }
    

    Whenever I run the code it works for a few hours accepting offers and confirming them. Then offer comes in and the sessionExpired and webSession events are emitted twice. Error: Cannot accept an unsent offer happens every time it tries to accept the offer.

    This from stdout (it also logs the timestamp):

    16:31:23
    Error: Not Logged In
        at SteamCommunity._checkCommunityError (/home/user/bot/node_modules/steamcommunity/components/http.js:128:9)
        at Request._callback (/home/user/bot/node_modules/steamcommunity/components/http.js:51:88)
        at Request.self.callback (/home/user/bot/node_modules/request/request.js:185:22)
        at emitTwo (events.js:126:13)
        at Request.emit (events.js:214:7)
        at Request.<anonymous> (/home/user/bot/node_modules/request/request.js:1161:10)
        at emitOne (events.js:116:13)
        at Request.emit (events.js:211:7)
        at Gunzip.<anonymous> (/home/user/bot/node_modules/request/request.js:1083:12)
        at Object.onceWrapper (events.js:313:30)
    16:31:23
    ## Session Expired
    16:31:23
    ## Session Expired
    16:31:23
    Error: Not Logged In
        at SteamCommunity.manager._community.httpRequestPost (/home/user/bot/node_modules/steam-tradeoffer-manager/lib/classes/TradeOffer.js:483:25)
        at Request._callback (/home/user/bot/node_modules/steamcommunity/components/http.js:67:15)
        at Request.self.callback (/home/user/bot/node_modules/request/request.js:185:22)
        at emitTwo (events.js:126:13)
        at Request.emit (events.js:214:7)
        at Request.<anonymous> (/home/user/bot/node_modules/request/request.js:1161:10)
        at emitOne (events.js:116:13)
        at Request.emit (events.js:211:7)
        at IncomingMessage.<anonymous> (/home/user/bot/node_modules/request/request.js:1083:12)
        at Object.onceWrapper (events.js:313:30)
    16:31:23
    weblogon
    16:31:24
    weblogon
    16:31:33
    Error: Cannot accept an unsent offer
        at Timeout.TradeOffer.accept [as _onTimeout] (/home/user/bot/node_modules/steam-tradeoffer-manager/lib/classes/TradeOffer.js:451:23)
        at ontimeout (timers.js:502:15)
        at tryOnTimeout (timers.js:323:5)
        at Timer.listOnTimeout (timers.js:290:5)
    16:31:43
    Error: Cannot accept an unsent offer
        at Timeout.TradeOffer.accept [as _onTimeout] (/home/user/bot/node_modules/steam-tradeoffer-manager/lib/classes/TradeOffer.js:451:23)
        at ontimeout (timers.js:502:15)
        at tryOnTimeout (timers.js:323:5)
        at Timer.listOnTimeout (timers.js:290:5)
    
    ... etc
    

    What am I doing wrong?

  5. post-4078-0-40469400-1526401952_thumb.png

    I get this error every so often, I don't know where it's coming from so I don't know how to log in once it happens. This isn't part of the sessionExpired event, as I have this in my code:

    community.on("sessionExpired", function(err) {
        console.log("## Session Expired, relogging.");
        client.logOn(logOnOptions);
    });
    

    help?

×
×
  • Create New...