<commit_before>﻿using System;
using System.Collections.Generic;
using System.Net.Http;
using Newtonsoft.Json;
using ZKill.Discord.Logging;

namespace ZKill.Discord.ZKill
{
    public class ZKillboardClient
    {
        private readonly ILogger _logger;
        private static readonly HttpClient httpClient = new HttpClient();

        public ZKillboardClient(ILogger logger)
        {
            _logger = logger;
            httpClient.BaseAddress = new Uri("https://redisq.zkillboard.com");
        }

        public KillMail GetNextKillMail()
        {
            KillMail result = null;

            do
            {
                var httpResult = httpClient.GetAsync("/listen.php").Result;
                if (!httpResult.IsSuccessStatusCode)
                {
                    _logger.Log(LoggingEventType.Error, "HttpClient Error.");
                    continue;
                }

                var resultString = httpResult.Content.ReadAsStringAsync().Result;
                dynamic dynamicResult = JsonConvert.DeserializeObject(resultString);
                if (dynamicResult.package == null)
                {
                    //_logger.Log("No new kill mail.");
                    continue;
                }

                var killMail = new KillMail();
                killMail.KillId = dynamicResult.package.killID;
                killMail.KillTime = dynamicResult.package.killmail.killTime;
                killMail.SystemName = dynamicResult.package.killmail.solarSystem.name;
                killMail.FittedValue = dynamicResult.package.zkb.fittedValue;
                killMail.TotalValue = dynamicResult.package.zkb.totalValue;
                killMail.KbUrl = $"https://zkillboard.com/kill/{(string)dynamicResult.package.killID}/";
                killMail.ShipTypeName = dynamicResult.package.killmail.victim.shipType.name;
                killMail.DamageTaken = dynamicResult.package.killmail.victim.damageTaken;
                killMail.CharacterId = dynamicResult.package.killmail.victim.character != null ? dynamicResult.package.killmail.victim.character.id : null;

                if (dynamicResult.package.killmail.victim.character != null)
                    killMail.VictimName = (string)dynamicResult.package.killmail.victim.character.name;
                else if (dynamicResult.package.killmail.victim.aliance != null)
                    killMail.VictimName =
                        $"(Alliance) {(string)dynamicResult.package.killmail.victim.aliance.name}";
                else
                    killMail.VictimName =
                        $"(Corporation) {(string)dynamicResult.package.killmail.victim.corporation.name}";

                killMail.Attackers = new List<Attacker>();

                foreach (var attacker in dynamicResult.package.killmail.attackers)
                {
                    killMail.Attackers.Add(new Attacker
                    {
                        Name = attacker.character != null ? attacker.character.name : "(Unknown)",
                        ShipTypeName = attacker.shipType != null ? attacker.shipType.name : "(Unknown)",
                        CharacterId = attacker.character != null ? attacker.character.id : null
                    });
                }
                    ;

                result = killMail;
            } while (result == null);
            return result;
        }
    }
}
<commit_msg>* Fixed a bug with fetching the killmail time<commit_after>﻿using System;
using System.Collections.Generic;
using System.Net.Http;
using Newtonsoft.Json;
using ZKill.Discord.Logging;

namespace ZKill.Discord.ZKill
{
    public class ZKillboardClient
    {
        private readonly ILogger _logger;
        private static readonly HttpClient httpClient = new HttpClient();

        public ZKillboardClient(ILogger logger)
        {
            _logger = logger;
            httpClient.BaseAddress = new Uri("https://redisq.zkillboard.com");
        }

        public KillMail GetNextKillMail()
        {
            KillMail result = null;

            do
            {
                var httpResult = httpClient.GetAsync("/listen.php").Result;
                if (!httpResult.IsSuccessStatusCode)
                {
                    _logger.Log(LoggingEventType.Error, "HttpClient Error.");
                    continue;
                }

                var resultString = httpResult.Content.ReadAsStringAsync().Result;
                dynamic dynamicResult = JsonConvert.DeserializeObject(resultString);
                if (dynamicResult.package == null)
                {
                    //_logger.Log("No new kill mail.");
                    continue;
                }

                var killMail = new KillMail();
                killMail.KillId = dynamicResult.package.killID;
                killMail.KillTime = dynamicResult.package.killmail.killTime != null ? dynamicResult.package.killmail.killTime : DateTime.MinValue;
                killMail.SystemName = dynamicResult.package.killmail.solarSystem.name;
                killMail.FittedValue = dynamicResult.package.zkb.fittedValue;
                killMail.TotalValue = dynamicResult.package.zkb.totalValue;
                killMail.KbUrl = $"https://zkillboard.com/kill/{(string)dynamicResult.package.killID}/";
                killMail.ShipTypeName = dynamicResult.package.killmail.victim.shipType.name;
                killMail.DamageTaken = dynamicResult.package.killmail.victim.damageTaken;
                killMail.CharacterId = dynamicResult.package.killmail.victim.character != null ? dynamicResult.package.killmail.victim.character.id : null;

                if (dynamicResult.package.killmail.victim.character != null)
                    killMail.VictimName = (string)dynamicResult.package.killmail.victim.character.name;
                else if (dynamicResult.package.killmail.victim.aliance != null)
                    killMail.VictimName =
                        $"(Alliance) {(string)dynamicResult.package.killmail.victim.aliance.name}";
                else
                    killMail.VictimName =
                        $"(Corporation) {(string)dynamicResult.package.killmail.victim.corporation.name}";

                killMail.Attackers = new List<Attacker>();

                foreach (var attacker in dynamicResult.package.killmail.attackers)
                {
                    killMail.Attackers.Add(new Attacker
                    {
                        Name = attacker.character != null ? attacker.character.name : "(Unknown)",
                        ShipTypeName = attacker.shipType != null ? attacker.shipType.name : "(Unknown)",
                        CharacterId = attacker.character != null ? attacker.character.id : null
                    });
                }
                    ;

                result = killMail;
            } while (result == null);
            return result;
        }
    }
}

{'fraction_non_alphanumeric': 0.0922833285344083, 'fraction_numerical': 0.0, 'mean_word_length': 1.7339630066902794, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6530186', 'n_tokens_mistral': 1844, 'n_tokens_neox': 1684, 'n_words': 285}