protected async Task <int> OnExecute(CommandLineApplication app) { Console.WriteLine("Please provide information to login on the SSCAIT server"); string login = null; while (string.IsNullOrWhiteSpace(login)) { Console.Write("Enter email: "); login = Console.ReadLine(); } SecureString password = null; while (password == null || password.Length == 0) { Console.Write("Enter password: "******"Server return error: {responseObject.Message}"); return(1); } var bwbotDirectory = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), ".bwbot"); var cookiesFile = Path.Combine( bwbotDirectory, ".auth"); Console.WriteLine($"Authentication information saved to {cookiesFile}"); } catch (Exception ex) { Console.WriteLine($"Error connecting to server"); Console.WriteLine(ex.Message); return(1); } return(0); }
protected async Task <int> OnExecute(CommandLineApplication app) { Console.WriteLine($"Uploading bot to server from file {this.FileName}"); var bwbotDirectory = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), ".bwbot"); var cookiesFile = Path.Combine( bwbotDirectory, ".auth"); if (!File.Exists(cookiesFile)) { Console.WriteLine("Please authenticate using bwbot login"); return(2); } var repository = new SSCAITRepository(); try { var responseObject = await repository.UploadAsync(this.BotName, this.FileName); if (responseObject.Status == 0) { Console.WriteLine($"Server return error: {responseObject.Message}"); return(1); } Console.WriteLine($"Bot uploaded"); return(0); } catch (Exception ex) { Console.WriteLine($"Error connecting to server"); Console.WriteLine(ex.Message); return(1); } }