Пример #1
0
        private static void Start()
        {
            Console.Title = "Akarr's steambot";

            Console.ForegroundColor = ConsoleColor.White;

            Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");

            config = new Config();
            if (!config.LoadConfig())
            {
                Console.WriteLine("Config file (config.cfg) can't be found or is corrupted ! Bot can't start.");
                Console.ReadKey();
                return;
            }

            PrintWelcomeMessage();

            Updater updater = new Updater(config.DisableAutoUpdate, BUILD_VERSION);

            LoadModules();

            Task.WaitAll(updater.Update());

            httpsrv = new HTTPServer(config.WebinterfacePort);
            httpsrv.Listen();

            if (config.DisplayLocation)
            {
                SendLocation();
            }

            steambotManager = new Manager(config);
            threadManager   = new Thread(new ThreadStart(steambotManager.Start));
            threadManager.CurrentUICulture = new CultureInfo("en-US");
            threadManager.Start();

            AttemptLoginBot(config.SteamUsername, config.SteamPassword, config.SteamAPIKey);

            while (steambotManager.OnlineBots.Count < 1)
            {
                Thread.Sleep(TimeSpan.FromSeconds(3));
            }

            steambotManager.SelectFirstBot();

            string command = "";

            do
            {
                Console.Write("> ");
                command = Console.ReadLine();
                steambotManager.Command(command);
            } while(command != "quit");

            httpsrv.Stop();
            steambotManager.Stop();
        }
Пример #2
0
        static void Main(string[] args)
        {
            Console.Title = "Akarr's steambot";

            PrintWelcomeMessage();

            config = new Config();
            if (!config.LoadConfig())
            {
                Console.WriteLine("Config file (config.cfg) can't be found or is corrupted ! Bot can't start.");
                Console.ReadKey();
                return;
            }

            steambotManager = new Manager(config);
            threadManager   = new Thread(new ThreadStart(steambotManager.Start));
            threadManager.Start();

            AttemptLoginBot(config.SteamUsername, config.SteamPassword, config.SteamAPIKey);

            while (steambotManager.OnlineBots.Count < 1)
            {
                Thread.Sleep(TimeSpan.FromSeconds(3));
            }

            steambotManager.SelectFirstBot();

            string command = "";

            while (command != "quit")
            {
                Console.Write("> ");
                command = Console.ReadLine();
                steambotManager.Command(command);
            }
        }
Пример #3
0
        static void Main(string[] args)
        {
            Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");

            AppDomain currentDomain = default(AppDomain);

            currentDomain = AppDomain.CurrentDomain;
            currentDomain.UnhandledException += GlobalUnhandledExceptionHandler;

            Console.Title = "Akarr's steambot";

            config = new Config();
            if (!config.LoadConfig())
            {
                Console.WriteLine("Config file (config.cfg) can't be found or is corrupted ! Bot can't start.");
                Console.ReadKey();
                return;
            }

            PrintWelcomeMessage();

            if (config.DisplayLocation)
            {
                SendLocation();
            }

            if (config.DisableAutoUpdate)
            {
                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.WriteLine("Updater disabled. Not fetching for last updates.");
                Console.ForegroundColor = ConsoleColor.White;
            }
            else
            {
                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.WriteLine("Searching for updates...");
                Console.ForegroundColor = ConsoleColor.White;

                Console.WriteLine("Creating update directory : " + Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)));
                if (!Directory.Exists(Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + "/updater")))
                {
                    Directory.CreateDirectory(Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + "/updater"));
                }

                try
                {
                    using (var client = new WebClient())
                    {
                        Console.ForegroundColor = ConsoleColor.Cyan;
                        Console.WriteLine("Downloading updater...");
                        Console.ForegroundColor = ConsoleColor.White;

                        client.DownloadFile("https://raw.githubusercontent.com/Arkarr/ASteambot/master/BINARIES/updater/updater.zip", Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + "/updater.zip"));
                    }

                    Console.WriteLine("Extracting updater...");
                    Console.WriteLine(Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + "/updater.zip"));
                    //ZipFile.ExtractToDirectory("updater.zip", "./updater");
                    using (FileStream zipToOpen = new FileStream(Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + "/updater.zip"), FileMode.Open))
                    {
                        using (ZipArchive archive = new ZipArchive(zipToOpen, ZipArchiveMode.Update))
                        {
                            foreach (ZipArchiveEntry file in archive.Entries)
                            {
                                string completeFileName = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + "/updater/", file.FullName);
                                file.ExtractToFile(completeFileName, true);
                            }
                        }
                    }
                    File.Delete("updater.zip");
                }
                catch (Exception e)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("Error while downloading the updater, aborting update process.");
                    Console.WriteLine(e.Message);
                    Console.ForegroundColor = ConsoleColor.White;
                }

                if (File.Exists(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + "/updater/ASteambotUpdater.exe"))
                {
                    var proc = new Process
                    {
                        StartInfo = new ProcessStartInfo
                        {
                            FileName               = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + "/updater/ASteambotUpdater.exe",
                            Arguments              = BUILD_VERSION.Split(' ')[0],
                            UseShellExecute        = false,
                            RedirectStandardOutput = true,
                            CreateNoWindow         = true
                        }
                    };

                    proc.Start();

                    bool updateRequired = false;
                    while (!proc.StandardOutput.EndOfStream)
                    {
                        string line = proc.StandardOutput.ReadLine();
                        if (line != "OK")
                        {
                            updateRequired = true;
                        }
                    }

                    if (updateRequired)
                    {
                        Console.ForegroundColor = ConsoleColor.Cyan;
                        Console.WriteLine("Starting updater...");
                        Console.ForegroundColor = ConsoleColor.White;

                        Thread.Sleep(1000);

                        Console.WriteLine("Executing : " + Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + "/updater/ASteambotUpdater.exe");
                        Process p = new Process();
                        p.StartInfo.FileName  = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + "/updater/ASteambotUpdater.exe";
                        p.StartInfo.Arguments = BUILD_VERSION.Split(' ')[0];
                        p.Start();

                        Environment.Exit(0);
                    }
                    else
                    {
                        Console.WriteLine("Already to the last version ! (" + BUILD_VERSION + ")");
                    }
                }
            }

            steambotManager = new Manager(config);
            threadManager   = new Thread(new ThreadStart(steambotManager.Start));
            threadManager.CurrentUICulture = new CultureInfo("en-US");
            threadManager.Start();

            AttemptLoginBot(config.SteamUsername, config.SteamPassword, config.SteamAPIKey);

            while (steambotManager.OnlineBots.Count < 1)
            {
                Thread.Sleep(TimeSpan.FromSeconds(3));
            }

            steambotManager.SelectFirstBot();

            if (!IsLinux())
            {
                string path = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location));
                if (File.Exists("website.zip"))
                {
                    Console.WriteLine("Website not extracted ! Doing that now...");
                    ZipFile.ExtractToDirectory("website.zip", path);

                    File.Delete("website.zip");
                    Console.WriteLine("Done !");
                }

                if (Directory.Exists(path + "/website"))
                {
                    //Webinteface are shit anyway... Worst idea ever!
                    //httpsrv = new HTTPServer("/website", 85);
                    //Console.WriteLine("HTTP Server started on port : " + httpsrv.Port + ">>> http://localhost:" + httpsrv.Port + "/index.html");
                    Console.WriteLine("I gave up for now on the webinterface. Worst idea ever.");
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("Website folder not present, can't start web interface. Re-download ASteambot from original github.");
                    Console.ForegroundColor = ConsoleColor.White;
                }
            }
            else
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("HTTP Server disabled for UNIX users. Wait for a fix :) !");
                Console.ForegroundColor = ConsoleColor.White;
            }

            Console.Title = "Akarr's steambot";

            string command = "";

            while (command != "quit")
            {
                Console.Write("> ");
                command = Console.ReadLine();
                steambotManager.Command(command);
            }

            if (httpsrv != null)
            {
                httpsrv.Stop();
            }
        }
Пример #4
0
        static void Main(string[] args)
        {
            Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");

            AppDomain currentDomain = default(AppDomain);

            currentDomain = AppDomain.CurrentDomain;
            currentDomain.UnhandledException += GlobalUnhandledExceptionHandler;

            Console.Title = "Akarr's steambot";

            config = new Config();
            if (!config.LoadConfig())
            {
                Console.WriteLine("Config file (config.cfg) can't be found or is corrupted ! Bot can't start.");
                Console.ReadKey();
                return;
            }

            PrintWelcomeMessage();

            if (config.DisplayLocation)
            {
                SendLocation();
            }

            if (args.Count() >= 1)
            {
                if (args[0] == "-update" && Directory.GetCurrentDirectory().ToString().EndsWith("tmp"))
                {
                    string destination = Directory.GetParent(Directory.GetCurrentDirectory()).ToString();
                    foreach (string newPath in Directory.GetFiles(Directory.GetCurrentDirectory(), "*.*", SearchOption.AllDirectories))
                    {
                        string update = destination + "\\" + Path.GetFileName(newPath);
                        File.Copy(newPath, update, true);
                    }
                    string process = Directory.GetParent(Directory.GetCurrentDirectory()) + @"\ASteambot.exe";
                    Console.WriteLine("ASteambot UPDATED ! Restarting...");
                    Console.WriteLine(process);
                    Thread.Sleep(5000);
                    Process newAS = new Process();
                    newAS.StartInfo.WorkingDirectory = Directory.GetParent(Directory.GetCurrentDirectory()).ToString();
                    newAS.StartInfo.FileName         = process;
                    newAS.StartInfo.Arguments        = "";
                    newAS.Start();
                    Environment.Exit(0);
                }
            }

            updater = new Updater();

            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine("Searching for updates...");
            Console.ForegroundColor = ConsoleColor.White;

            /*if(IsLinux() && !config.DisableAutoUpdate)
             * {
             *  Console.ForegroundColor = ConsoleColor.Red;
             *  Console.WriteLine("Updater has been reported to not work on Linux, updated manually.");
             *  Console.WriteLine("You can download the last release here :");
             *  Console.WriteLine("https://github.com/Arkarr/ASteambot/releases/latest");
             *  Console.ForegroundColor = ConsoleColor.White;
             * }*/

            if (File.Exists("./update.sh"))
            {
                File.Delete("./update.sh");
            }

            if (config.DisableAutoUpdate)
            {
                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.WriteLine("Updater disabled. Not fetching for last updates.");
                Console.ForegroundColor = ConsoleColor.White;
            }
            else if (!updater.CheckVersion(Regex.Match(BUILD_VERSION, "([^\\s]+)").Value))
            {
                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.WriteLine("Update found ! Updating...");
                Console.ForegroundColor = ConsoleColor.White;
                Console.Title           = "Akarr's steambot - Updating...";

                updater.Update();

                string  path      = Directory.GetCurrentDirectory() + "/ASteambot.exe";
                Process asteambot = new Process();

                asteambot.StartInfo.WorkingDirectory = Directory.GetCurrentDirectory();

                if (IsLinux())
                {
                    asteambot.StartInfo.FileName = "setsid " + path + " '-update'";
                }
                else
                {
                    asteambot.StartInfo.FileName  = path;
                    asteambot.StartInfo.Arguments = "-update";
                }

                Thread.Sleep(3000);

                asteambot.Start();

                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("Update done ! Restarting...");
                Console.ForegroundColor = ConsoleColor.White;

                Environment.Exit(0);
            }
            else
            {
                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.WriteLine("Already up to date !");
                Console.ForegroundColor = ConsoleColor.White;
            }

            //WebInterfaceHelper.AddTrade(new SteamTrade.TradeOffer.TradeOffer(null, new SteamKit2.SteamID()));

            steambotManager = new Manager(config);
            threadManager   = new Thread(new ThreadStart(steambotManager.Start));
            threadManager.CurrentUICulture = new CultureInfo("en-US");
            threadManager.Start();

            AttemptLoginBot(config.SteamUsername, config.SteamPassword, config.SteamAPIKey);

            while (steambotManager.OnlineBots.Count < 1)
            {
                Thread.Sleep(TimeSpan.FromSeconds(3));
            }

            steambotManager.SelectFirstBot();

            if (!IsLinux())
            {
                if (File.Exists("website.zip"))
                {
                    Console.WriteLine("Website not extracted ! Doing that now...");
                    if (!Directory.Exists("website"))
                    {
                        Directory.CreateDirectory("website");
                    }
                    ZipFile.ExtractToDirectory("website.zip", "./website");
                    File.Delete("website.zip");
                    Console.WriteLine("Done !");
                }

                if (Directory.Exists("/website/"))
                {
                    httpsrv = new HTTPServer("/website/", 85);
                    Console.WriteLine("HTTP Server started on port : " + httpsrv.Port + ">>> http://localhost:" + httpsrv.Port + "/index.html");
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("Website folder not present, can't start web interface. Re-download ASteambot from original github.");
                    Console.ForegroundColor = ConsoleColor.White;
                }
            }
            else
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("HTTP Server disabled for UNIX users. Wait for a fix :) !");
                Console.ForegroundColor = ConsoleColor.White;
            }

            Console.Title = "Akarr's steambot";

            string command = "";

            while (command != "quit")
            {
                Console.Write("> ");
                command = Console.ReadLine();
                steambotManager.Command(command);
            }

            if (httpsrv != null)
            {
                httpsrv.Stop();
            }
        }
Пример #5
0
        static void Main(string[] args)
        {
            DEBUG = false;

            Console.Title = "Akarr's steambot";

            Console.ForegroundColor = ConsoleColor.White;

            Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");

            AppDomain currentDomain = default(AppDomain);

            currentDomain = AppDomain.CurrentDomain;
            currentDomain.UnhandledException += GlobalUnhandledExceptionHandler;

            Console.Title = "Akarr's steambot";

            config = new Config();
            if (!config.LoadConfig())
            {
                Console.WriteLine("Config file (config.cfg) can't be found or is corrupted ! Bot can't start.");
                Console.ReadKey();
                return;
            }

            PrintWelcomeMessage();

            Updater updater = new Updater(config.DisableAutoUpdate, BUILD_VERSION);

            Task.WaitAll(updater.Update());

            if (config.DisplayLocation)
            {
                SendLocation();
            }

            steambotManager = new Manager(config);
            threadManager   = new Thread(new ThreadStart(steambotManager.Start));
            threadManager.CurrentUICulture = new CultureInfo("en-US");
            threadManager.Start();

            AttemptLoginBot(config.SteamUsername, config.SteamPassword, config.SteamAPIKey);

            while (steambotManager.OnlineBots.Count < 1)
            {
                Thread.Sleep(TimeSpan.FromSeconds(3));
            }

            steambotManager.SelectFirstBot();

            /*if (!IsLinux())
             * {
             *  string path = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location));
             *  if (File.Exists("website.zip"))
             *  {
             *      Console.WriteLine("Website not extracted ! Doing that now...");
             *      //ZipFile.ExtractToDirectory("website.zip", path);
             *
             *      File.Delete("website.zip");
             *      Console.WriteLine("Done !");
             *  }
             *
             *  if (Directory.Exists(path + "/website"))
             *  {
             *      //Webinteface are shit anyway... Worst idea ever!
             *      //httpsrv = new HTTPServer("/website", 85);
             *      //Console.WriteLine("HTTP Server started on port : " + httpsrv.Port + ">>> http://localhost:" + httpsrv.Port + "/index.html");
             *  }
             *  else
             *  {
             *      Console.ForegroundColor = ConsoleColor.Red;
             *      Console.WriteLine("Website folder not present, can't start web interface. Re-download ASteambot from original github.");
             *      Console.ForegroundColor = ConsoleColor.White;
             *  }
             * }
             * else
             * {
             *  Console.ForegroundColor = ConsoleColor.Red;
             *  Console.WriteLine("HTTP Server disabled for UNIX users. Wait for a fix :) !");
             *  Console.ForegroundColor = ConsoleColor.White;
             * }*/

            Console.WriteLine("I gave up for now on the webinterface. Worst idea ever.");

            string command = "";

            while (command != "quit")
            {
                Console.Write("> ");
                command = Console.ReadLine();
                steambotManager.Command(command);
            }

            if (httpsrv != null)
            {
                httpsrv.Stop();
            }
        }