예제 #1
0
        public async Task WeatherAsync([Remainder] string city)
        {
            var forecast = await _weather.GetForecastAsync(city, WeatherUnit.Imperial);

            if (forecast == null)
            {
                await ReplyAsync($"Could not find a city like `{city}`");

                return;
            }

            var weather = forecast.Weather.First();

            var embed = new EmbedBuilder()
                        .WithColor(Color.Blue)
                        .WithImageUrl(WeatherApiService.GetIconUrl(weather.IconId))
                        .WithTitle(forecast.Name + "'s Weather")
                        .WithDescription(weather.Description)
                        .WithCurrentTimestamp()
                        .AddField("Pressure", forecast.Measurements.Pressure + " hPa", true)
                        .AddField("Humidity", forecast.Measurements.Humidity + "%", true)
                        .AddField("Temp", MathHelper.KelvinToFahrenheit(forecast.Measurements.Temperature) + "f", true)
                        .AddField("Temp Range", MathHelper.KelvinToFahrenheit(forecast.Measurements.TemperatureMin) + "f -> " + MathHelper.KelvinToFahrenheit(forecast.Measurements.TemperatureMax) + 'f', true);

            await ReplyEmbedAsync(embed);
        }
예제 #2
0
 public static async Task RunScheduledTask(
     [TimerTrigger("0 */1 * * * *")] TimerInfo timer,
     ILogger log)
 {
     foreach (var city in Cities)
     {
         JObject weather = await WeatherApiService.GetWeather(city);
     }
 }
예제 #3
0
 public WeatherCommands(WeatherApiService weather)
 {
     weatherApi = weather;
 }
예제 #4
0
 public WeatherModule(WeatherApiService weather, RootController root)
     : base(root)
 {
     _weather = weather;
 }