From 8842a86b30f8e1bf1b27fc6d07a971d420ca481e Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 20 Sep 2017 20:32:25 -0500 Subject: [PATCH] Adding Weather Changes to include Fehrenheit as well as Celsius? --- src/NadekoBot/Modules/Searches/Searches.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/NadekoBot/Modules/Searches/Searches.cs b/src/NadekoBot/Modules/Searches/Searches.cs index 0738414a..2c872d02 100644 --- a/src/NadekoBot/Modules/Searches/Searches.cs +++ b/src/NadekoBot/Modules/Searches/Searches.cs @@ -43,7 +43,11 @@ namespace NadekoBot.Modules.Searches string response; response = await _service.Http.GetStringAsync($"http://api.openweathermap.org/data/2.5/weather?q={query}&appid=42cd627dd60debf25a5739e50a217d74&units=metric").ConfigureAwait(false); + string responsef; + responsef = await _service.Http.GetStringAsync($"http://api.openweathermap.org/data/2.5/weather?q={query}&appid=42cd627dd60debf25a5739e50a217d74&units=imperial").ConfigureAwait(false); + var data = JsonConvert.DeserializeObject(response); + var dataf = JsonConvert.DeserializeObject(responsef); var embed = new EmbedBuilder() .AddField(fb => fb.WithName("🌍 " + Format.Bold(GetText("location"))).WithValue($"[{data.Name + ", " + data.Sys.Country}](https://openweathermap.org/city/{data.Id})").WithIsInline(true)) @@ -51,8 +55,11 @@ namespace NadekoBot.Modules.Searches .AddField(fb => fb.WithName("☁ " + Format.Bold(GetText("condition"))).WithValue(string.Join(", ", data.Weather.Select(w => w.Main))).WithIsInline(true)) .AddField(fb => fb.WithName("😓 " + Format.Bold(GetText("humidity"))).WithValue($"{data.Main.Humidity}%").WithIsInline(true)) .AddField(fb => fb.WithName("💨 " + Format.Bold(GetText("wind_speed"))).WithValue(data.Wind.Speed + " m/s").WithIsInline(true)) + .AddField(fb => fb.WithName("💨 " + Format.Bold(GetText("wind_speed"))).WithValue(dataf.Wind.Speed + " mph").WithIsInline(true)) .AddField(fb => fb.WithName("🌡 " + Format.Bold(GetText("temperature"))).WithValue(data.Main.Temp + "°C").WithIsInline(true)) + .AddField(fb => fb.WithName("🌡 " + Format.Bold(GetText("temperature"))).WithValue(dataf.Main.Temp + "°F").WithIsInline(true)) .AddField(fb => fb.WithName("🔆 " + Format.Bold(GetText("min_max"))).WithValue($"{data.Main.TempMin}°C - {data.Main.TempMax}°C").WithIsInline(true)) + .AddField(fb => fb.WithName("🔆 " + Format.Bold(GetText("min_max"))).WithValue($"{dataf.Main.TempMin}°F - {dataf.Main.TempMax}°F").WithIsInline(true)) .AddField(fb => fb.WithName("🌄 " + Format.Bold(GetText("sunrise"))).WithValue($"{data.Sys.Sunrise.ToUnixTimestamp():HH:mm} UTC").WithIsInline(true)) .AddField(fb => fb.WithName("🌇 " + Format.Bold(GetText("sunset"))).WithValue($"{data.Sys.Sunset.ToUnixTimestamp():HH:mm} UTC").WithIsInline(true)) .WithOkColor()