/// <summary> /// Delete provided secrets. /// </summary> /// <param name="secrets">secrets to delete</param> /// <param name="orgId">the organization for delete secrets</param> /// <returns>keys successfully patched</returns> public async Task DeleteSecretsAsync(SecretKeys secrets, string orgId) { Arguments.CheckNotNull(secrets, nameof(secrets)); Arguments.CheckNonEmptyString(orgId, nameof(orgId)); await _service.PostOrgsIDSecretsAsync(orgId, secrets); }
public static async Task FetchOverlayData() { try { #if DEBUG Dictionary <string, string> data = new Dictionary <string, string>(); string route = DiscordOAuth.AccessCode.series_name; if (route.Contains("vrml")) { route = "vrml"; } else if (route.Contains("vrsn")) { route = "nepatv"; } string folder = @"S:\git_repo\IgniteVR-Overlays\SparkOverlays\" + route; if (Directory.Exists(folder)) { foreach (string file in Directory.EnumerateFiles(folder, "*.*", SearchOption.AllDirectories)) { if (file.EndsWith(".png")) { string tempFolder = Path.Combine(Path.GetTempPath(), "Spark", "img"); Directory.CreateDirectory(tempFolder); string tempFilePath = Path.Combine(tempFolder, SecretKeys.Hash(file) + ".png"); File.Copy(file, tempFilePath, true); data[file.Substring(folder.Length + 1)] = tempFilePath; } else { data[file.Substring(folder.Length + 1)] = await File.ReadAllTextAsync(file); } } } overlayData = data; #else overlayData = await GetOverlays(); #endif } catch (Exception e) { Logger.LogRow(Logger.LogType.Error, e.ToString()); } // write out overlayData to a temp folder // foreach (KeyValuePair<string, string> file in overlayData) // { // file.Value // } }
public MainWindow() { // Load the Keys SecretKeys keys = SecretKeys.Load("Secret.txt"); // Create the Bot Bot = new KellyHoshiraBot(keys); Bot.OnMessageReceived += Bot_OnMessageReceived; Bot.OnLogReceived += Bot_OnLogReceived; Bot.NetworkChanged += Bot_NetworkChanged; // Initialize the Program InitializeComponent(); }
public async Task MainAsync() { // Load the Secret Keys SecretKeys keys = SecretKeys.Load("Secret.txt"); // Create the Bot Bot = new KellyHoshiraBot(keys); await Bot.InitializeAsync(); Bot.OnMessageReceived += Bot_OnMessageReceived; Bot.OnLogReceived += Bot_OnLogReceived; await Bot.ConnectAsync(); await Task.Delay(-1); }
public static async Task <Dictionary <string, string> > GetOverlays() { if (DiscordOAuth.Personal) { return(null); } try { Dictionary <string, string> data = new Dictionary <string, string>(); using HttpClient webClient = new HttpClient(); byte[] result = await webClient.GetByteArrayAsync($"{Program.APIURL}/get_overlays/{DiscordOAuth.AccessCode.series_name}/{DiscordOAuth.oauthToken}"); await using MemoryStream file = new MemoryStream(result); using ZipArchive zip = new ZipArchive(file, ZipArchiveMode.Read); foreach (ZipArchiveEntry entry in zip.Entries) { await using Stream stream = entry.Open(); if (entry.Name.EndsWith(".png")) { string tempFolder = Path.Combine(Path.GetTempPath(), "Spark", "img"); Directory.CreateDirectory(tempFolder); string tempFilePath = Path.Combine(tempFolder, SecretKeys.Hash(entry.Name) + ".png"); await using MemoryStream reader = new MemoryStream(); await stream.CopyToAsync(reader); byte[] bytes = reader.ToArray(); await File.WriteAllBytesAsync(tempFilePath, bytes); data[entry.Name] = tempFilePath; } else { using StreamReader reader = new StreamReader(stream); data[entry.Name] = await reader.ReadToEndAsync(); } } return(data); } catch (Exception e) { Logger.LogRow(Logger.LogType.Error, e.ToString()); return(null); } }
private void StartButtonClicked(object sender, RoutedEventArgs e) { string username = accessCodeComboBox.SelectedValue.ToString(); Program.currentAccessCodeUsername = username; Settings.Default.accessCode = SecretKeys.Hash(DiscordOAuth.AccessCode); Settings.Default.Save(); if (Program.liveWindow == null) { Program.liveWindow = new LiveWindow(); Program.liveWindow.Closed += (sender, args) => Program.liveWindow = null; Program.liveWindow.Show(); } Close(); }
private void DiscordLoginButtonClicked(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(DiscordOAuth.DiscordUsername)) { DiscordOAuth.OAuthLogin(force: true); } else { DiscordOAuth.Unlink(); } Refresh(); string username = accessCodeComboBox.SelectedValue.ToString(); Program.currentAccessCodeUsername = username; Settings.Default.accessCode = SecretKeys.Hash(DiscordOAuth.AccessCode); Settings.Default.Save(); }
public SecretKeyService() { IAmazonSecretsManager client = new AmazonSecretsManagerClient(awsAccessKey, awsSecretKey, RegionEndpoint.GetBySystemName(awsRegion)); GetSecretValueRequest request = new GetSecretValueRequest { SecretId = awsSecretKeysName, VersionStage = "AWSCURRENT" }; GetSecretValueResponse response; try { response = client.GetSecretValueAsync(request).Result; } catch (Exception) { throw; } if (response.SecretString != null) { _secretKeys = JsonConvert.DeserializeObject <SecretKeys>(response.SecretString); } }
public static void ProcessDiscordPresence(Frame frame) { if (SparkSettings.instance.discordRichPresence) { if (discordClient == null || discordClient.IsDisposed) { //InitializeDiscord(); LogRow(LogType.Error, "Discord RP client disposed while in normal thread."); return; } RichPresence rp = new RichPresence(); if (frame == null) { try { discordClient.SetPresence(null); return; } catch (Exception) { LogRow(LogType.Error, "Discord RP client error when setting null presence."); return; } } StringBuilder details = new StringBuilder(); switch (frame.map_name) { case "mpl_arena_a": { if (frame.teams[2].players.Find(p => p.name == frame.client_name) != null) { details.Append("Spectating "); } else { details.Append("Playing "); } details.Append("Arena "); if (frame.private_match) { details.Append("pvt."); rp.WithSecrets(new Secrets { JoinSecret = "spark://c/" + SecretKeys.Hash(frame.sessionid), SpectateSecret = "spark://s/" + SecretKeys.Hash(frame.sessionid), }); } else { details.Append("pub."); } rp.State = "Score: " + frame.orange_points + " - " + frame.blue_points; rp.Timestamps = new Timestamps { End = frame.game_status == "post_match" ? DateTime.UtcNow : DateTime.UtcNow.AddSeconds(frame.game_clock) }; rp.WithParty(new Party { ID = frame.sessionid, Size = frame.GetAllPlayers().Count, Max = frame.private_match ? 15 : 8 }); break; } case "mpl_lobby_b2": { details.Append("in EchoVR Lobby"); // how long have we been in the lobby? if (!inLobby) { inLobby = true; lobbyEntryTime = DateTime.UtcNow; } rp.Timestamps = new Timestamps { Start = lobbyEntryTime }; break; } // if (frame.map_name == "whatever combat is") default: details.Append("Playing Combat"); break; } rp.Details = details.ToString(); rp.Assets = new Assets { LargeImageKey = "echo_arena_store_icon", LargeImageText = SparkSettings.instance.discordRichPresenceServerLocation && !string.IsNullOrEmpty(Program.CurrentRound?.serverLocation) ? Program.CurrentRound.serverLocation : "Rich presence from Spark" }; discordClient.SetPresence(rp); } else { if (discordClient != null && !discordClient.IsDisposed) { discordClient.Dispose(); } } }