Jessecar96 / SteamBot

Automated bot software for interacting with Steam Trade
http://scrap.tf
MIT License
1.33k stars 910 forks source link

Bot crashes if trade cancelled right after it started. #104

Closed lazy1 closed 11 years ago

lazy1 commented 11 years ago

Bot crashes if trade with bot is initiated and canceled before the bot can send welcome message.

The error log:

Unhandled Exception: SteamTrade.Exceptions.TradeException: The web command to send the trade message failed.
   at SteamTrade.Trade.SendMessage(String msg) in D:\dev\sb\SteamBot\SteamTrade\Trade.cs:line 426
   at SteamBot.AdminUserHandler.OnTradeInit() in D:\dev\sb\SteamBot\SteamBot\AdminUserHandler.cs:line 85
   at SteamBot.Bot.OpenTrade(SteamID other) in D:\dev\sb\SteamBot\SteamBot\Bot.cs:line 170
   at SteamBot.Bot.<HandleSteamMessage>b__b(SessionStartCallback callback) in D:\dev\sb\SteamBot\SteamBot\Bot.cs:line 305
   at SteamKit2.CallbackMsg.Handle[T](Action`1 handler) in D:\dev\sb\SteamBot\Lib\SteamKit2\SteamKit2\Steam3\SteamClient\CallbackMgr\CallbackMsg.cs:line 72
   at SteamBot.Bot.HandleSteamMessage(CallbackMsg msg) in D:\dev\sb\SteamBot\SteamBot\Bot.cs:line 303
   at SteamBot.Bot.<.ctor>b__1() in D:\dev\sb\SteamBot\SteamBot\Bot.cs:line 119
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()
cwhelchel commented 11 years ago

I think this is a bit of known issue. There is a "Success. Put up items" type message sent over trade chat that causes this to fail.

All the methods that provide the public interface should check the ''OtherUserCancelled'' field before doing work.

teliosdev commented 11 years ago

Shouldn't it be added in the method Poll instead, to prevent cluttering up the event callbacks?

teliosdev commented 11 years ago

Is this still an issue?

waylaidwanderer commented 11 years ago

You can also check if CurrentTrade == null or not.