Пример #1
0
            public void OnTradeProposed(SteamTrading.TradeProposedCallback e)
            {
                if (!Bot._checkCookies())
                {
                    Bot.SteamTrade.RespondToTrade(e.TradeID, false);
                    Log.Warn("Trade proposal cookie check failed.");
                    return;
                }

                try
                {
                    Bot._tradeManager.InitializeTrade(Bot.SteamUser.SteamID, e.OtherClient);
                    Log.Debug("Trade proposal initialized");
                }
                catch (WebException we)
                {
                    Bot.SteamFriends.SendChatMessage(e.OtherClient, EChatEntryType.ChatMsg,
                                                     "Trade error: " + we.Message);
                    Log.Error("WebException occurred during trade: " + we.ToString());

                    Bot.SteamTrade.RespondToTrade(e.TradeID, false);
                    return;
                }
                catch (Exception ex)
                {
                    Bot.SteamFriends.SendChatMessage(e.OtherClient, EChatEntryType.ChatMsg,
                                                     "Trade declined. Could not correctly fetch your backpack.");
                    Log.Error("Exception occurred during trade: " + ex.ToString());

                    Bot.SteamTrade.RespondToTrade(e.TradeID, false);
                    return;
                }

                if (Bot._tradeManager.OtherInventory.IsPrivate)
                {
                    Bot.SteamFriends.SendChatMessage(e.OtherClient, EChatEntryType.ChatMsg,
                                                     "Trade declined. Your backpack cannot be private.");
                    Log.Warn("Trade declined as other backpack was private.");

                    Bot.SteamTrade.RespondToTrade(e.TradeID, false);
                    return;
                }

                if (Bot.CurrentTrade == null && Bot._getUserHandler(e.OtherClient).OnTradeRequest())
                {
                    Bot.SteamTrade.RespondToTrade(e.TradeID, true);
                }
                else
                {
                    Bot.SteamTrade.RespondToTrade(e.TradeID, false);
                }
            }
Пример #2
0
            public void OnNotification(SteamNotifications.NotificationCallback e)
            {
                //currently only appears to be of trade offer
                if (e.Notifications.Count != 0)
                {
                    foreach (var notification in e.Notifications)
                    {
                        Log.Info(notification.UserNotificationType + " notification");
                    }
                }

                // Get offers only if cookies are valid
                if (Bot._checkCookies())
                {
                    Log.Debug("Checking trade offers");
                    Bot._tradeOfferManager.GetOffers();
                }
                else
                {
                    Log.Error("Unable to fetch cookies!");
                }
            }