SteamBot icon indicating copy to clipboard operation
SteamBot copied to clipboard

On User Accept Trade Offer

Open Modestas opened this issue 10 years ago • 15 comments

Is it not possible to handle event when user accepts trade offer that bot sent?

I'm only getting ClientItemsChanged and Multi notifications.

Modestas avatar Mar 17 '15 22:03 Modestas

The only semi-reliable way I know of is to check trade offer status in a loop.

scholtzm avatar Mar 17 '15 23:03 scholtzm

I had an idea of calling web api every 30 s for sent offers and checking their status for completed. Then I would save last call time and do next time call with time historical cutoff, but it seems that cutting by timestamp does something I didn't expect.

time_historical_cutoff - a unix time value. when active_only is set, inactive offers will be returned if their state was updated since this time. Useful to get delta updates on what has changed.

Modestas avatar Mar 17 '15 23:03 Modestas

You would still need to schedule a timer to send a request with a specified time. And for each offer you would have to use a different query, unless you take the lowest cutoff from all and then use it every n seconds. A better option for me is to save a list of offerID strings outputted by offer.send and periodically fetch every single one of them and see their status. Even scrap.tf does this, so this seems to be the best way

bartico6 avatar Mar 21 '15 15:03 bartico6

You wouldn't need polling if there's a Steam message for this (meaning we'd need to handle it through SteamKit). Is there not one?

BlueRaja avatar Mar 21 '15 18:03 BlueRaja

Of course not. :smile:

scholtzm avatar Mar 21 '15 19:03 scholtzm

But Steam users do get mail icon notification (in top of steam UI) that offer was completed. So why can't we parse that?

periodically fetch every single one of them

Do you do that on separate thread? And what would be the right periodic time to fetch them? 30 s? I mean if I had 60 uncompleted offers, my bot would do 60 different calls to TradeOffers API every 30 s.

Modestas avatar Mar 22 '15 20:03 Modestas

So why can't we parse that?

You can't reliably identify those items. This would only work if you used original_id which some items don't have and it seems to be deprecated.

if I had 60 uncompleted offers

There's a limit for this. And it's pretty low... like 5-10 or so.

scholtzm avatar Mar 22 '15 22:03 scholtzm

You get the "new items" notification however you would have to compare your backpack from before this notification and after you receive one and keep a couple copies of said backpack in case of concurrent trades etc. Just Fetch offers using a "List offerIDs". I'd do it, and I do. Works flawlessly.

bartico6 avatar Mar 23 '15 10:03 bartico6

Thanks, I'll try :+1:

Modestas avatar Mar 28 '15 16:03 Modestas

@BlueRaja private List<string> outgoingOffers = new List<string>(); This + add the outputted offer ID when you send an offer + timer + fetchOffer = profit

bartico6 avatar Apr 03 '15 13:04 bartico6

I was more interested in the case where a normal trade gets turned into a trade offer due to email confirmation; but it turns out the offer-id is the same as the trade-id you get during the trade.

BlueRaja avatar Apr 03 '15 13:04 BlueRaja

I have a question that pertains to this thread, so I didn't want to make a new thread/issue. Right now when i send a trade offer i save each offerID to a file, each offerID is on its own line. In the botManager class I load this file into a array of strings using System.IO.File.readAllLines("file path"). Then perform a foreach on the offerID's. Inside the loop I call

TaradeOffer offer; thisBot.TheBot.TryGetTradeOffer(ThisOfferID, out offer); Console.WriteLine(offer.OfferState.);

to check the offer state. Currently only trade offers that are decline return an offer state. Accepted and pending trade offers do not return anything. Any suggestions? Thanks for reading

Update: Ok I got this solved. I just had some of the code that saved it to the file wrong and it only messed up the ID's of the non declined offer's I used as a test.

Freakazoidile avatar May 25 '15 23:05 Freakazoidile

Seems like the TryGetTradeOffer call will randomly fail or randomly work. More specifically it seems like the call to IsOfferValid that GetTradeOffer calls seems to hang up/not return a value. Not sure why it sometimes fails. I only have 3-5 trade offers I'm trying to get. Anyone have any clues? I posted on reddit/r/steambot and did not get any replies. Any replies would be greatly appreciated.

Freakazoidile avatar May 28 '15 05:05 Freakazoidile

I have no answer for you due to not knowing very much but I thought you might want to know that someone is reading.

Just a word of warning, it seems the general rule here is that if your post gives users the impression that you haven't tried to solve it yourself or that it is due to lack of experience with c# or programming in general, you will likely see very little response from them. On github, they explicitly say that posting is only for bug reports, updates, and commits. You may want to consider testing, providing logs and exceptions or creating new exceptions based on your best guess at where things are failing, and come back with more info. You will likely receive a better response on /r/steambot and avoid getting your thread closed on this site.

If you're like me and are still learning c# while building a better bot, you may just consider getting help from friends at home. I buy my coding friend pizza when I need help. I never post here and have stopped posting on /r/steambot because I often am not aware of how amateur my questions are. On May 28, 2015 1:45 AM, "Freakazoidile" [email protected] wrote:

Seems like the TryGetTradeOffer call will randomly fail or randomly work. More specifically it seems like the call to IsOfferValid that GetTradeOffer calls seems to hang up/not return a value. Not sure why it sometimes fails. I only have 3-5 trade offers I'm trying to get. Anyone have any clues? I posted on reddit/r/steambot and did not get any replies. Any replies would be greatly appreciated.

— Reply to this email directly or view it on GitHub https://github.com/Jessecar96/SteamBot/issues/742#issuecomment-106184557 .

ThereWasADream avatar May 28 '15 17:05 ThereWasADream

I did read the sidebar rules and am very aware of keep questions to the subreddit rule. I've posted on reddit about this issue about a week ago and didn't get a reply so thought as a last resort I would try here.

I never thought about the possibility of posting this as a potential bug. I've put atleast 5-6 hrs into checking what part of the check offer code is failing and have it narrowed down to the isOfferValid method not returning for an unknown reason. Im by bypassing this issue for now and will come back to it later when. If I can't solve the issue then I will make detailed logs and post some more info if I feel this is a bug.

Thanks for the info and the reply!

Freakazoidile avatar May 28 '15 18:05 Freakazoidile