/// <summary> /// Editing Twitter Configuration Tokens /// </summary> private static void EditTwitterToken() { string url = "https://developer.twitter.com/en/apps/13667962"; try { Process.Start(url); } catch { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { url = url.Replace("&", "^&"); Process.Start(new ProcessStartInfo("cmd", $"/c start {url}") { CreateNoWindow = true }); } else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { Process.Start("xdg-open", url); } else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { Process.Start("open", url); } else { throw; } } Logger.Log(Logger.Neutral, "Please enter the bot's API key below.\n", "Eva Login"); var answer = Console.ReadLine(); Configuration["tokens:TwitterApiKey"] = answer?.Trim(); Logger.Log(Logger.Neutral, "Please enter the bot's API secret below.\n", "Eva Login"); answer = Console.ReadLine(); Configuration["tokens:TwitterApiSecret"] = answer?.Trim(); Logger.Log(Logger.Neutral, "Please enter the bot's Access Token below.\n", "Eva Login"); answer = Console.ReadLine(); Configuration["tokens:TwitterToken"] = answer?.Trim(); Logger.Log(Logger.Neutral, "Please enter the bot's Token Secret below.\n", "Eva Login"); answer = Console.ReadLine(); Configuration["tokens:TwitterTokenSecret"] = answer?.Trim(); var filePath = Path.Combine(AppContext.BaseDirectory, "config.json"); object config = new EvaConfig(Configuration["prefix"], new Tokens(Configuration["tokens:Discord"], Configuration["tokens:TwitterApiKey"], Configuration["tokens:TwitterApiSecret"], Configuration["tokens:TwitterToken"], Configuration["tokens:TwitterTokenSecret"])); var json = JsonConvert.SerializeObject(config, Formatting.Indented); File.Delete(filePath); File.WriteAllText(filePath, json); Configuration.Reload(); }
private static void TryGenerateConfiguration() { var filePath = Path.Combine(AppContext.BaseDirectory, "config.json"); if (File.Exists(filePath)) { return; } object config = new EvaConfig(); var json = JsonConvert.SerializeObject(config, Formatting.Indented); File.WriteAllText(filePath, json); }