Jump to content

How to track my trade offer status?


Not_a_good_sniper

Recommended Posts

If you dont understand this is a question about coding a steam trade bot.

The problem is I know how to catch errors when accepting trade offers and alert users about them. But what about succesfull trades?

offer.accept((err, status) => {
	// do stuff;
});

I am using steam-tradeoffer-manager module. Here I have 2 variables: err and status. Its easy to detect an error here, but a bit harder to detect status of a trade. Let me explain

offer.accept((err, status) => {
	if (err) {
		// error while accepting, classic stuff
	} else {
		console.log(status); // possible output: accepted; pending
    };
};

If status = accepted then all items have been given/taken successfully, but I also sometimes got status = pending, which means pretty nothing.

Some bots do send you a message when trade offer finished (including trade sites, like scrap.tf), I want to do the same. Tried to find in wiki, but not found. Google search also gave me nothing useful. Am I am doing it right? Mb I am missing something? Or I have to do something like record all incomming trades, check something every 10 seconds and then send a message. Tried to use some events from wiki, but nothing helped me.

 

offer.accept((err, status) => {
	if (err) {
		// error while accepting
	} else {
		sendAMessage(offer.partner.getSteamID64(), "Trade offer went through successfully"); // a function to send messages
	};
};

Doing something like this is not the best idea since the status can be pending, and the user might thing something went wrong

 

offer.accept((err, status) => {
	if (err) {
		// error while accepting
	} else {
		if (status == "accepted"){
			sendAMessage(offer.partner.getSteamID64(), "Trade offer went through successfully");
		} else {
			console.log(status);
		};
	};
};

This might work, but sometimes users will never be alerted about successfull trades.  I dont know an event (or a function, anything) which showing a status of a trade. This is not really nescessary, but I like to add small features to my bot

Link to comment
Share on other sites

Incoming Trades

Are you sending trades to the bot that have an item from their side?

 

If the offer that you are sending to the bot contains at least one item on the bot's side of the trade, then the status of the offer is set to pending because the bot has to mobile confirm the trade. Only after doing the mobile confirmation will the status of the offer change to "Accepted".

 

If the offer doesn't contain any items on the bot's side, the status of the offer will change to "Accepted" immediately.

 

offer.accept((err, status) => {
	if (offer.itemsToGive.length != 0) {
		// offer.status = "pending"

		CONFIRM OFFER via acceptConfirmationForObject
			// offer.status = "accepted"
			do any remaining things within callback / after promise
	} else {
		// offer.status = "accepted"
		do any remaining things
	}
});

 

Outgoing Trades

If you wish for your bot to react to the event of a trade offer sent from them being declined / accepted / items missing, then you should make use of the sentOfferChanged event to listen to. The callback will contain the Offer object that has changed state, which you can compare to decide what to do next.

Link to comment
Share on other sites

7 hours ago, FcK said:

If I understand well, just send a message in your last else. Something like


sendAMessage(steamId, 'Trade status: ' + status)

 

The users will receive Trade status: pending and nothing else. If you dont know, it takes a while to trade offer to be accepted (all items from both inventories have been given/taken)

 

7 hours ago, Mengh. said:

then you should make use of the sentOfferChanged event to listen to

I think you found it! But can I use receivedOfferChanged event to listen for status of incoming trades?

 

7 hours ago, Mengh. said:

Only after doing the mobile confirmation will the status of the offer change to "Accepted".

My bot already can confirm trade offers using identity secret

Link to comment
Share on other sites

  • Not_a_good_sniper locked and unlocked this topic
  • Not_a_good_sniper locked and unlocked this topic

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...