Beispiel #1
0
 static void Open(object sender, EventArgs e)
 {
     died    = false;
     opening = false;
     Log.Success("Connection opened!");
     Tasking.Run((Action)SocketPinger, "Balancer");
     socket.Send("newitems_go");
     socket.Send("history_go");
     //start = DateTime.Now;
 }
Beispiel #2
0
        private void Delayer()
        {
            while (!bot.IsLoggedIn)
            {
                Thread.Sleep(10);
            }

            ReadyToRun = true;
            Tasking.Run(Restarter, botName);
        }
Beispiel #3
0
        public Logic(TMBot bot)
        {
            botName         = bot.config.Username;
            parent          = bot;
            PREFIXPATH      = Path.Combine("CS", botName);
            UNSTICKEREDPATH = Path.Combine(PREFIXPATH, "emptystickered.txt");

            __database__       = new SalesDatabase(PREFIXPATH);
            __emptystickered__ = new EmptyStickeredDatabase();

            DATABASEJSONPATH = Path.Combine(PREFIXPATH, "database.json");
            BLACKLISTPATH    = Path.Combine(PREFIXPATH, "blackList.txt");
            MONEYTPATH       = Path.Combine(PREFIXPATH, "money.txt");
            if (!Directory.Exists(PREFIXPATH))
            {
                Directory.CreateDirectory(PREFIXPATH);
            }
            Tasking.Run(StartUp, botName);
        }
Beispiel #4
0
        public void Init()
        {
            if (Log == null)
            {
                Log = new NewMarketLogger(this);
            }
            Log.Info("Initializing TMBot " + bot.DisplayName);
            logic    = new Logic(this);
            protocol = new Protocol(this);

            logic.Log    = Log;
            protocol.Log = Log;

            logic.Protocol    = protocol;
            protocol.Logic    = logic;
            WaitingForRestart = false;

            Tasking.Run(Delayer, botName);
        }
Beispiel #5
0
 private void StartUp()
 {
     while (!parent.ReadyToRun)
     {
         Thread.Sleep(10);
     }
     FulfillBlackList();
     __emptystickered__.Load();
     __database__.Load();
     Tasking.Run(parent.InventoryFetcher, botName);
     RefreshConfig();
     Tasking.Run((Action)ParsingCycle, botName);
     Tasking.Run((Action)SaveDataBaseCycle, botName);
     Tasking.Run((Action)SellFromQueue, botName);
     Tasking.Run((Action)AddNewItems, botName);
     Tasking.Run((Action)UnstickeredRefresh, botName);
     Tasking.Run((Action)SetNewOrder, botName);
     if (!sellOnly)
     {
         Tasking.Run((Action)SetOrderForUnstickered, botName);
     }
     Tasking.Run((Action)RefreshConfigThread, botName);
 }
Beispiel #6
0
 static VK()
 {
     Tasking.Run((Action)Refresher);
     Tasking.Run((Action)Listener);
 }
Beispiel #7
0
 public void CheckApiBackGround(string s)
 {
     Tasking.Run(() => CheckApi(s));
 }
Beispiel #8
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();
            bool loadedOk  = false;
            bool primetime = LocalRequest.IsPrimeTime();

            if (!primetime)
            {
                return;
            }
            if (!File.Exists("settings.json"))
            {
                try {
                    loadedOk = manager.LoadConfigurationFromData(LocalRequest.GetConfig());
                } catch (Exception e) {
                    Console.WriteLine(
                        "Config file is missing and all instances are working.");
                    Console.Write("Press Enter to exit...");
                    Console.ReadLine();
                    return;
                }
            }
            else
            {
                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();
                return;
            }
            else
            {
                if (manager.ConfigObject.UseSeparateProcesses)
                {
                    SetConsoleCtrlHandler(ConsoleCtrlCheck, true);
                }
                Consts.Endpoints.juggler = manager.ConfigObject.JugglerEndpoint ?? "http://steambot.noobgam.me";
                Tasking.Run(manager.Nanny);

                if (manager.ConfigObject.AutoStartAllBots)
                {
                    var startedOk = manager.StartBots();

                    if (!startedOk)
                    {
                        Console.WriteLine(
                            "Error starting the bots because either the configuration was bad or because the log file was not opened.");
                        Console.Write("Press Enter to exit...");
                        Console.ReadLine();
                    }
                }
                else
                {
                    foreach (var botInfo in manager.ConfigObject.Bots)
                    {
                        if (botInfo.AutoStart)
                        {
                            // auto start this particual bot...
                            manager.StartBot(botInfo.Username);
                        }
                    }
                }

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

                var bmi = new BotManagerInterpreter(manager);

                // command interpreter loop.
                do
                {
                    Console.Write("botmgr > ");
                    string inputText = Console.ReadLine();
                    if (inputText == null)
                    {
                        waitHandle.WaitOne();
                        return;
                    }

                    if (!String.IsNullOrEmpty(inputText))
                    {
                        bmi.CommandInterpreter(inputText);
                    }
                } while (!isclosing);
            }
        }