コード例 #1
0
            internal static string FormatWeatherResponse(CurrentWeatherModel.CurrentCondition currentWeather, CurrentWeatherModel.Location location, bool shortWeather = false)
            {
                var b = IrcConstants.IrcBold;
                var n = IrcConstants.IrcNormal; // Gets a bit repetitive (also I'm illiterate)

                if (shortWeather)
                {
                    return
                        ($"{b}{location.Name}, {location.Country}{n}: " +
                         $"{b}Temp:{n} {FormatTemperatureCelsius(currentWeather.Temperature)}°C " +
                         $"(feels like {FormatTemperatureCelsius(currentWeather.FeelsLike)}°C); " +
                         $"{b}Cond:{n} {currentWeather.WeatherDescriptions[0]}; " +
                         $"{b}Precip:{n} {currentWeather.Precipitation} mm; " +
                         $"{b}Humidity:{n} {currentWeather.Humidity}%; " +
                         $"at {currentWeather.ObservationTime} UTC");
                }
                return
                    ($"Weather at {b}{location.Name}, {location.Region}, {location.Country}{n}: " +
                     $"{b}Temp:{n} {FormatTemperatureCelsius(currentWeather.Temperature)}°C / {FormatTemperatureFahrenheit(ConversionHelpers.CelsiusToFahrenheit(currentWeather.Temperature))}°F " +
                     $"(feels like {FormatTemperatureCelsius(currentWeather.FeelsLike)}°C / {FormatTemperatureFahrenheit(ConversionHelpers.CelsiusToFahrenheit(currentWeather.FeelsLike))}°F); " +
                     $"{b}Condition:{n} {currentWeather.WeatherDescriptions[0]}; " +
                     $"{b}Wind:{n} {currentWeather.WindSpeed} Kph / {ConversionHelpers.KilometresToMiles(currentWeather.WindSpeed)} Mph {currentWeather.WindDirection}; " +
                     $"{b}Precipitation:{n} {currentWeather.Precipitation} mm / {ConversionHelpers.MmToInch(currentWeather.Precipitation)} in; " +
                     $"{b}Humidity:{n} {currentWeather.Humidity}%; " +
                     $"{b}Pressure:{n} {currentWeather.Pressure} mbars; " +
                     $"{b}Visibility:{n} {currentWeather.Visibility} km / {ConversionHelpers.KilometresToMiles( currentWeather.Visibility)} mi; " +
                     $"Observed at {currentWeather.ObservationTime} UTC");
            }