Exemplo n.º 1
0
        private async Task ReportIncursion(JsonClasses.IncursionData incursion, JsonClasses.ConstellationData c, IMessageChannel channel)
        {
            var result = await SQLHelper.SQLiteDataQuery <int>("incursions", "constId", "constId", incursion.constellation_id);

            //skip existing incursion report
            var isUpdate = result > 0 && Settings.Core.ReportIncursionStatusAfterDT;

            if (!isUpdate && result > 0)
            {
                return;
            }

            if (!isUpdate)
            {
                await SQLHelper.SQLiteDataInsertOrUpdate("incursions", new Dictionary <string, object>
                {
                    { "constId", incursion.constellation_id }
                });
            }

            c = c ?? await APIHelper.ESIAPI.GetConstellationData(Reason, incursion.constellation_id);

            var r = await APIHelper.ESIAPI.GetRegionData(Reason, c.region_id);

            var sb = new StringBuilder();

            foreach (var system in incursion.infested_solar_systems)
            {
                sb.Append((await APIHelper.ESIAPI.GetSystemData(Reason, system)).name);
                sb.Append(" | ");
            }
            sb.Remove(sb.Length - 3, 2);

            var x = new EmbedBuilder().WithTitle(isUpdate ? string.Format(LM.Get("incursionUpdateHeader"), c.name, r.name) : string.Format(LM.Get("incursionNewHeader"), c.name, r.name))
                    .WithColor(isUpdate ? new Color(0x000045) : new Color(0xdd5353))
                    .WithThumbnailUrl(SettingsManager.Get("resources", "imgIncursion"))
                    .AddField(LM.Get("incursionInfestedSystems"), sb.ToString())
                    .AddInlineField(LM.Get("incursionInfluence"), (incursion.influence).ToString("P"))
                    .AddInlineField(LM.Get("incursionBoss"), incursion.has_boss ? LM.Get("Alive") : LM.Get("Defeated"))
                    .WithCurrentTimestamp()
                    .Build();
            await APIHelper.DiscordAPI.SendMessageAsync(channel, "@everyone", x);
        }
Exemplo n.º 2
0
        private async Task ReportIncursion(JsonClasses.IncursionData incursion, JsonClasses.ConstellationData c, IMessageChannel channel)
        {
            var result = await SQLHelper.IsIncurionExists(incursion.constellation_id);

            //skip existing incursion report
            var isUpdate = result && Settings.IncursionNotificationModule.ReportIncursionStatusAfterDT;

            if (!isUpdate && result)
            {
                return;
            }

            if (!isUpdate)
            {
                await SQLHelper.AddIncursion(incursion.constellation_id);
            }

            c = c ?? await APIHelper.ESIAPI.GetConstellationData(Reason, incursion.constellation_id);

            var r = await APIHelper.ESIAPI.GetRegionData(Reason, c.region_id);

            var sb = new StringBuilder();

            foreach (var system in incursion.infested_solar_systems)
            {
                sb.Append((await APIHelper.ESIAPI.GetSystemData(Reason, system)).name);
                sb.Append(" | ");
            }
            sb.Remove(sb.Length - 3, 2);

            var x = new EmbedBuilder().WithTitle(isUpdate ? LM.Get("incursionUpdateHeader", c.name, r.name) : LM.Get("incursionNewHeader", c.name, r.name))
                    .WithColor(isUpdate ? new Color(0x000045) : new Color(0xdd5353))
                    .WithThumbnailUrl(Settings.Resources.ImgIncursion)
                    .AddField(LM.Get("incursionInfestedSystems"), sb.ToString())
                    .AddField(LM.Get("incursionInfluence"), (incursion.influence).ToString("P"), true)
                    .AddField(LM.Get("incursionBoss"), incursion.has_boss ? LM.Get("Alive") : LM.Get("Defeated"), true)
                    .WithCurrentTimestamp()
                    .Build();
            await APIHelper.DiscordAPI.SendMessageAsync(channel, Settings.IncursionNotificationModule.DefaultMention ?? "", x);
        }