public void CheckBackpackTfPrices()
        {
            double MinutesToCheck = 60;

            while (true)
            {
                Thread.Sleep(TimeSpan.FromMinutes(MinutesToCheck));
                Console.WriteLine("Updating backpack.tf pricelist...");
                clsFunctions.backpackPrices = BackpackTF.FetchSchema();
                if (clsFunctions.backpackPrices != null && clsFunctions.backpackPrices["response"]["success"] == 1)
                {
                    Console.WriteLine("Update successful.");
                    MinutesToCheck = 60;
                }
                else
                {
                    Console.WriteLine("Update failed!");
                    MinutesToCheck = 10;
                }
            }
        }
Beispiel #2
0
        // This mode is to manage child bot processes and take use command line inputs
        private static void BotManagerMode()
        {
            Console.Title = "Bot Manager";

            manager = new BotManager();

            var loadedOk = manager.LoadConfiguration("settings.json");

            if (!loadedOk)
            {
                Console.WriteLine(
                    "Configuration file Does not exist or is corrupt. Please rename 'settings-template.json' to 'settings.json' and modify the settings to match your environment");
                Console.Write("Press Enter to exit...");
                Console.ReadLine();
            }
            else
            {
                if (manager.ConfigObject.UseSeparateProcesses)
                {
                    SetConsoleCtrlHandler(ConsoleCtrlCheck, true);
                }
                clsFunctions.WepBlackList   = manager.ConfigObject.WepBlackList;
                clsFunctions.ScammerList    = manager.ConfigObject.Scammers;
                clsFunctions.backpackPrices = BackpackTF.FetchSchema();
                if (clsFunctions.backpackPrices != null && clsFunctions.backpackPrices["response"]["success"] == 1)
                {
                    Console.WriteLine("Backpack.tf prices successfully received.");
                    clsFunctions.KEY_BUY_VALUE  = new TF2Currency(clsFunctions.GetKeyBuyPrice());
                    clsFunctions.KEY_SELL_VALUE = new TF2Currency(clsFunctions.GetKeySellPrice());
                }
                else
                {
                    Console.WriteLine("Backpack.tf prices not received!");
                }

                foreach (var botInfo in manager.ConfigObject.Bots)
                {
                    if (botInfo.Start)
                    {
                        // auto start this particular bot...
                        manager.StartBot(botInfo.Username);
                    }
                }


                Console.WriteLine("Type help for bot manager commands. ");
                Console.Write("botmgr > ");

                var bmi = new BotManagerInterpreter(manager);

                // command interpreter loop.
                do
                {
                    string inputText = Console.ReadLine();

                    if (String.IsNullOrEmpty(inputText))
                    {
                        continue;
                    }

                    bmi.CommandInterpreter(inputText);

                    Console.Write("botmgr > ");
                } while (!isclosing);
            }
        }
Beispiel #3
0
        public void TradeCountInventory()
        {
            Bot.main.Invoke((Action)(() =>
            {
                ShowTrade = new ShowTrade(Bot, Bot.SteamFriends.GetFriendPersonaName(OtherSID));
                ShowTrade.Show();
                ShowTrade.Activate();
            }));
            BackpackTF.CurrentSchema = BackpackTF.FetchSchema();
            // Let's count our inventory
            Thread loadInventory = new Thread(() =>
            {
                Console.WriteLine("Trade window opened.");
                Console.WriteLine("Loading all inventory items.");
                if (Bot.CurrentTrade == null)
                {
                    return;
                }
                Inventory.Item[] inventory = Trade.MyInventory.Items;
                foreach (Inventory.Item item in inventory)
                {
                    if (!item.IsNotTradeable)
                    {
                        var currentItem  = Trade.CurrentSchema.GetItem(item.Defindex);
                        string name      = "";
                        string itemValue = "";
                        var type         = Convert.ToInt32(item.Quality.ToString());
                        if (QualityToName(type) != "Unique")
                        {
                            name += QualityToName(type) + " ";
                        }
                        name += currentItem.ItemName;
                        if (QualityToName(type) == "Unusual")
                        {
                            try
                            {
                                for (int count = 0; count < item.Attributes.Length; count++)
                                {
                                    if (item.Attributes[count].Defindex == 134)
                                    {
                                        name += " (Effect: " + EffectToName(item.Attributes[count].FloatValue) + ")";
                                    }
                                }
                            }
                            catch (Exception)
                            {
                            }
                        }
                        if (currentItem.CraftMaterialType == "supply_crate")
                        {
                            for (int count = 0; count < item.Attributes.Length; count++)
                            {
                                name += " #" + (item.Attributes[count].FloatValue);
                                if (item.Attributes[count].Defindex == 186)
                                {
                                    name += " (Gifted)";
                                }
                            }
                        }
                        name += " (Level " + item.Level + ")";
                        try
                        {
                            int size = item.Attributes.Length;
                            for (int count = 0; count < size; count++)
                            {
                                if (item.Attributes[count].Defindex == 261)
                                {
                                    string paint = ShowBackpack.PaintToName(item.Attributes[count].FloatValue);
                                    name        += " (Painted: " + paint + ")";
                                }
                                if (item.Attributes[count].Defindex == 186)
                                {
                                    name += " (Gifted)";
                                }
                            }
                        }
                        catch
                        {
                            // Item has no attributes... or something.
                        }
                        if (item.IsNotCraftable)
                        {
                            name += " (Uncraftable)";
                        }
                        if (currentItem.Name == "Wrapped Gift")
                        {
                            // Untested!
                            try
                            {
                                var containedItem = Trade.CurrentSchema.GetItem(item.ContainedItem.Defindex);
                                var containedName = GetItemName(containedItem, item.ContainedItem, out itemValue);
                                name += " (Contains: " + containedName + ")";
                            }
                            catch (Exception ex)
                            {
                                Bot.Print(ex);
                                // Guess this doesn't work :P.
                            }
                        }
                        string price = Util.GetPrice(item.Defindex, currentItem.ItemQuality, item);
                        ListInventory.Add(name, item.Id, currentItem.ImageURL, price);
                    }
                }
                try
                {
                    ShowTrade.loading = false;
                    Bot.main.Invoke((Action)(() => ShowTrade.list_inventory.SetObjects(ListInventory.Get())));
                }
                catch
                {
                }
            });

            loadInventory.Start();
        }