Esempio n. 1
0
        public override void OnNewTradeOffer(TradeOffer offer)
        {
            //receiving a trade offer
            if (IsAdmin)
            {
                //parse inventories of bot and other partner
                //either with webapi or generic inventory
                //Bot.GetInventory();
                //Bot.GetOtherInventory(OtherSID);

                var myItems    = offer.Items.GetMyItems();
                var theirItems = offer.Items.GetTheirItems();
                Log.Info("They want " + myItems.Count + " of my items.");
                Log.Info("And I will get " + theirItems.Count + " of their items.");

                //do validation logic etc
                if (DummyValidation(myItems, theirItems))
                {
                    string tradeid;
                    if (offer.Accept(out tradeid))
                    {
                        Bot.AcceptAllMobileTradeConfirmations();
                        Log.Success("Accepted trade offer successfully : Trade ID: " + tradeid);
                    }
                }
                else
                {
                    // maybe we want different items or something

                    //offer.Items.AddMyItem(0, 0, 0);
                    //offer.Items.RemoveTheirItem(0, 0, 0);
                    if (offer.Items.NewVersion)
                    {
                        string newOfferId;
                        string tradeError;
                        if (offer.CounterOffer(out newOfferId, out tradeError))
                        {
                            Bot.AcceptAllMobileTradeConfirmations();
                            Log.Success("Counter offered successfully : New Offer ID: " + newOfferId);
                        }
                    }
                }
            }
            else
            {
                //we don't know this user so we can decline
                if (offer.Decline())
                {
                    Log.Info("Declined trade offer : " + offer.TradeOfferId + " from untrusted user " + OtherSID.ConvertToUInt64());
                }
            }
        }
Esempio n. 2
0
        public override void OnNewTradeOffer(TradeOffer offer)
        {
            //receiving a trade offer 
            if (IsAdmin)
            {
                //parse inventories of bot and other partner
                //either with webapi or generic inventory
                //Bot.GetInventory();
                //Bot.GetOtherInventory(OtherSID);

                var myItems = offer.Items.GetMyItems();
                var theirItems = offer.Items.GetTheirItems();
                Log.Info("They want " + myItems.Count + " of my items.");
                Log.Info("And I will get " +  theirItems.Count + " of their items.");

                //do validation logic etc
                if (DummyValidation(myItems, theirItems))
                {                    
                    TradeOfferAcceptResponse acceptResp = offer.Accept();
                    if (acceptResp.Accepted)
                    {                        
                        Bot.AcceptAllMobileTradeConfirmations();
                        Log.Success("Accepted trade offer successfully : Trade ID: " + acceptResp.TradeId);
                    }
                }
                else
                {
                    // maybe we want different items or something

                    //offer.Items.AddMyItem(0, 0, 0);
                    //offer.Items.RemoveTheirItem(0, 0, 0);
                    if (offer.Items.NewVersion)
                    {
                        string newOfferId;
                        if (offer.CounterOffer(out newOfferId))
                        {
                            Bot.AcceptAllMobileTradeConfirmations();
                            Log.Success("Counter offered successfully : New Offer ID: " + newOfferId);
                        }
                    }
                }
            }
            else
            {
                //we don't know this user so we can decline
                if (offer.Decline())
                {
                    Log.Info("Declined trade offer : " + offer.TradeOfferId + " from untrusted user " + OtherSID.ConvertToUInt64());
                }
            }
        }
Esempio n. 3
0
        public override void OnNewTradeOffer(TradeOffer offer)
        {
            //receiving a trade offer 
            if (IsAdmin)
            {
                //parse inventories of bot and other partner
                //either with webapi or generic inventory
                //Bot.GetInventory();
                //Bot.GetOtherInventory(OtherSID);

                var myItems = offer.Items.GetMyItems();
                var theirItems = offer.Items.GetTheirItems();
                Log.Info("They want " + myItems.Count + " of my items.");
                Log.Info("And I will get " +  theirItems.Count + " of their items.");

                //do validation logic etc
                if (DummyValidation(myItems, theirItems))
                {
                    string tradeid;
                    if (offer.Accept(out tradeid))
                    {
                        if (myItems.Count > 0 && Bot.SteamGuardAccount != null)
                        {
                            // confirmation is needed if bot is giving away items and mobile auth is linked
                            if (Bot.AcceptTradeConfirmation(tradeid))
                            {
                                Log.Success("Accepted trade offer successfully : Trade ID: " + tradeid);
                            }
                            else
                            {
                                Log.Error("Failed to confirm trade offer #{0}!", tradeid);
                            }
                        }
                        else if (Bot.SteamGuardAccount == null)
                        {
                            Log.Success("Accepted trade offer successfully : Trade ID: " + tradeid);
                        }
                    }
                }
                else
                {
                    // maybe we want different items or something

                    //offer.Items.AddMyItem(0, 0, 0);
                    //offer.Items.RemoveTheirItem(0, 0, 0);
                    if (offer.Items.NewVersion)
                    {
                        string newOfferId;
                        if (offer.CounterOffer(out newOfferId))
                        {
                            if (myItems.Count > 0 && Bot.SteamGuardAccount != null)
                            {
                                // confirmation is needed if bot is giving away items and mobile auth is linked
                                if (Bot.AcceptTradeConfirmation(newOfferId))
                                {
                                    Log.Success("Counter offered successfully : New Offer ID: " + newOfferId);
                                }
                                else
                                {
                                    Log.Error("Failed to confirm trade offer #{0}!", newOfferId);
                                }
                            }
                            else if (Bot.SteamGuardAccount == null)
                            {
                                Log.Success("Counter offered successfully : New Offer ID: " + newOfferId);
                            }
                        }
                    }
                }
            }
            else
            {
                //we don't know this user so we can decline
                if (offer.Decline())
                {
                    Log.Info("Declined trade offer : " + offer.TradeOfferId + " from untrusted user " + OtherSID.ConvertToUInt64());
                }
            }
        }