예제 #1
0
        // Method that runs update process
        public static void processUpdateRequest()
        {
            if (Common.Raffle != null && Common.Raffle.raffleIsActive())
            {
                Console.WriteLine("Update request placed in command queue.");
                return;
            }
            UpdateDetails details = WebCalls.downloadUpdateDetails().Result;

            if (!details.RequestSuccessful || !details.UpdateAvailable)
            {
                Console.WriteLine("RequestSuccessful: " + details.RequestSuccessful + ", UpdateAvailable: " + details.UpdateAvailable);
                return;
            }
            Console.WriteLine("Downloading new bot and updater...");
            WebCalls.downloadFile(details.DownloadLocation, "bot.exe");
            Console.WriteLine("new bot downloaded");
            WebCalls.downloadFile(details.UpdaterLocation, "updater.exe");
            Console.WriteLine("Finished! Starting updater and exiting.");
            System.Diagnostics.ProcessStartInfo pInfo = new System.Diagnostics.ProcessStartInfo();
            pInfo.FileName               = "updater.exe";
            pInfo.ErrorDialog            = true;
            pInfo.UseShellExecute        = false;
            pInfo.RedirectStandardOutput = true;
            pInfo.RedirectStandardError  = true;
            pInfo.WorkingDirectory       = Path.GetDirectoryName("updater.exe");
            System.Diagnostics.Process.Start(pInfo);
            Environment.Exit(1);
        }
예제 #2
0
 // Method called if updater.exe exists, and announces changes if instructed to do so
 public static void afterUpdate()
 {
     if (File.Exists("updater.exe"))
     {
         File.Delete("updater.exe");
         Common.UpdateDatas = new Common.UpdateData(WebCalls.downloadUpdateDetails().Result);
         Common.notify("Update successful!", "Changes: " + Common.UpdateDatas.Details.Changes);
         Console.WriteLine("Waiting for connected state...");
         while (!Events.connected)
         {
         }
         Console.WriteLine("Connected to chat confirmed!");
         if (Common.UpdateDatas.Details.Announce)
         {
             Common.ChatClient.SendMessage(string.Format("Updated! Changes: {0}", Common.UpdateDatas.Details.Changes), Common.DryRun);
         }
     }
 }