public override async Task <int> Execute() { var keys = await _sql.GetNexusApiKeysWithCounts(0); _logger.Log(LogLevel.Information, $"Verifying {keys.Count} API Keys"); foreach (var key in keys) { try { var client = new TrackingClient(_sql, key); var status = await client.GetUserStatus(); if (!status.is_premium) { await _sql.DeleteNexusAPIKey(key.Key); continue; } var(daily, hourly) = await client.GetRemainingApiCalls(); await _sql.SetNexusAPIKey(key.Key, daily, hourly); } catch (Exception ex) { _logger.Log(LogLevel.Warning, "Update error, purging API key"); await _sql.DeleteNexusAPIKey(key.Key); } } return(keys.Count); }
public async Task <NexusApiClient> GetClient() { var keys = await _sql.GetNexusApiKeysWithCounts(1500); foreach (var key in keys.Where(k => k.Key != _selfKey)) { try { var client = new TrackingClient(_sql, key); if (await client.IsPremium()) { return(client); } _logger.LogWarning($"Purging non premium key"); await _sql.DeleteNexusAPIKey(key.Key); continue; } catch (Exception ex) { Utils.Log($"Error getting tracking client: {ex}"); } } var bclient = await NexusApiClient.Get(); await bclient.GetUserStatus(); return(bclient); }
public async Task <NexusApiClient> GetClient() { var keys = await _sql.GetNexusApiKeysWithCounts(1500); foreach (var key in keys.Where(k => k.Key != _selfKey)) { var client = new TrackingClient(_sql, key); if (!await client.IsPremium()) { _logger.LogWarning($"Purging non premium key"); await _sql.DeleteNexusAPIKey(key.Key); continue; } return(client); } return(await NexusApiClient.Get()); }