From cae1df82b8fc9c7865435cdd2e46d6d186b04d8b Mon Sep 17 00:00:00 2001 From: Master Kwoth Date: Thu, 19 Oct 2017 08:11:47 +0200 Subject: [PATCH] Added fahrenheit to .weather command --- NadekoBot.Core/Modules/Searches/Searches.cs | 6 ++++-- NadekoBot.Core/Services/Impl/StatsService.cs | 2 +- NadekoBot.Core/Services/StandardConversions.cs | 16 ++++++++++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 NadekoBot.Core/Services/StandardConversions.cs diff --git a/NadekoBot.Core/Modules/Searches/Searches.cs b/NadekoBot.Core/Modules/Searches/Searches.cs index 083197d1..696cb449 100644 --- a/NadekoBot.Core/Modules/Searches/Searches.cs +++ b/NadekoBot.Core/Modules/Searches/Searches.cs @@ -97,14 +97,16 @@ namespace NadekoBot.Modules.Searches var data = JsonConvert.DeserializeObject(response); + Func f = StandardConversions.CelsiusToFahrenheit; + 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)) .AddField(fb => fb.WithName("📏 " + Format.Bold(GetText("latlong"))).WithValue($"{data.Coord.Lat}, {data.Coord.Lon}").WithIsInline(true)) .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("temperature"))).WithValue(data.Main.Temp + "°C").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("temperature"))).WithValue($"{data.Main.Temp:F1}°C / {f(data.Main.Temp):F1}°F").WithIsInline(true)) + .AddField(fb => fb.WithName("🔆 " + Format.Bold(GetText("min_max"))).WithValue($"{data.Main.TempMin:F1}°C - {data.Main.TempMax:F1}°C\n{f(data.Main.TempMin):F1}°F - {f(data.Main.TempMax):F1}°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() diff --git a/NadekoBot.Core/Services/Impl/StatsService.cs b/NadekoBot.Core/Services/Impl/StatsService.cs index b014f8a4..e67e88b4 100644 --- a/NadekoBot.Core/Services/Impl/StatsService.cs +++ b/NadekoBot.Core/Services/Impl/StatsService.cs @@ -23,7 +23,7 @@ namespace NadekoBot.Core.Services.Impl private readonly IBotCredentials _creds; private readonly DateTime _started; - public const string BotVersion = "2.0.0-alpha"; + public const string BotVersion = "2.0.0-beta"; public string Author => "Kwoth#2560"; public string Library => "Discord.Net"; diff --git a/NadekoBot.Core/Services/StandardConversions.cs b/NadekoBot.Core/Services/StandardConversions.cs new file mode 100644 index 00000000..77662da7 --- /dev/null +++ b/NadekoBot.Core/Services/StandardConversions.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace NadekoBot.Core.Services +{ + public class StandardConversions + { + public static double CelsiusToFahrenheit(double cel) + { + return cel * 1.8f + 32; + } + } +}