Jump to content
McKay Development

Recommended Posts

Posted

The bot do the logon() and webLogon() with sucess, and use methods like getUserInventoryContents() with no problems, but every time the bot try to accept a confirmation for a trade offer (acceptConfirmationForObject()), the event sessionExpired is fired, and the offer is not accepted, any idea of how can i fix and why is that happening?

 

This is my code:

var client = new SteamUser();

var community = new SteamCommunity();
var manager = new TradeOfferManager({ "steam": client, "language": "en", "community":community });

client.on('webSession', function(sessionID, newCookie) { 
	log('Loading APIKey..');
	community.setCookies(newCookie);
	manager.setCookies(newCookie, function(err){
		if(err){ logError(err, "webSession"); return; }
		log('Got APIKey: '+manager.apiKey);
	});	
});

community.on('sessionExpired', function(err) { log('sessionExpired!, WebRelogin..');
	if(err){ logError(err, 'sessionExpired'); }
	client.webLogOn();
});
manager.on('newOffer', function(offer) {
	var partner=offer.partner.getSteamID64();
	
	if(partner==admin){ log("New offer #" + offer.id + " from owner");
		offer.accept(function(err, res) {
			if (err) { Message(admin, "Unable to accept offer: " + err.message); } 
			else { 
				if(res == "pending"){
					community.acceptConfirmationForObject(identity, offer.id, function(err, responsecm){
						if (err){ Message(admin, "" + err); return;}
						log("Offer accepeted!");
					});
				} else {
					log("Offer accepeted!");
				}
			}
		});
	}	
});
function makeOffer(target, itemsFromMe, itemsFromThem){
	var offer = manager.createOffer(target);
	offer.addMyItems(itemsFromMe);
	offer.addTheirItems(itemsFromThem);
	offer.send(function(err, status) {
		if (err){ Message(target, ""+err); } 
		if (status == 'pending') {
			community.acceptConfirmationForObject(identity, offer.id, function(err) {
				if (err) {
					logError(err, "acceptConfirmationForObject");
				} else {
					Message(target, "Trade offer sent!!");
				}
			});
		} else {
			Message(target, "Trade offer sent!!");
		}
	});
}

the function Message, log, and logError is already defined and working fine, so i have no clue what is going on zZzZzZzz

 

some help here  -_-

Posted

Problem Fixed!

 

Cause: i was running ASF, and when i closed ASF all the problems got fixed, its probably cuz i cant have more than 1 WebSessions

 

Tips: when you're running your bot make sure you dont have another WebSessions it may cause anoying bugs

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