Beispiel #1
0
        public async Task Location(string ipAddress)
        {
            if (!IPAddress.TryParse(ipAddress, out _))
            {
                await ReplyAsync("Invalid ip format :(");

                return;
            }

            var ipInfo = await $"http://ip-api.com/json/{ipAddress}".GetJsonAsync <IpApiResult>();

            if (ipInfo == null)
            {
                await ReplyAsync($"Cannot find ip {ipAddress}");

                return;
            }

            var staticMap = await _mapBoxStaticMapService.GetImageStream(ipInfo.Lat, ipInfo.Lon);

            // await GetStaticImageUrlMapBox(ipInfo).GetStreamAsync();
            await base.Context.Channel.SendFileAsync(staticMap, "map.png", $"{ipInfo.Country} - {ipInfo.City}");
        }
Beispiel #2
0
        public async Task Location(string ipAddress)
        {
            if (!IPAddress.TryParse(ipAddress, out _))
            {
                await ReplyAsync("Ungültiges IP-Format!");

                return;
            }

            var ipInfo = await $"http://ip-api.com/json/{ipAddress}".GetJsonAsync <IpApiResult>();

            if (ipInfo == null)
            {
                await ReplyAsync($"IP-Adresse {ipAddress} konnte nicht gefunden werden!");

                return;
            }

            var staticMap = await _mapBoxStaticMapService.GetImageStream(ipInfo.Lat, ipInfo.Lon);

            // await GetStaticImageUrlMapBox(ipInfo).GetStreamAsync();
            await base.Context.Channel.SendFileAsync(staticMap, "map.png", $"{ipInfo.Country} - {ipInfo.City}");
        }