public static String[] FindOutWeather() { string url = "http://api.openweathermap.org/data/2.5/weather?q=Chita&units=metric&appid=2856fc0f74411cd143093c7ac9b9a7a0"; HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(url); HttpWebResponse httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse(); string responce; using (StreamReader streamReader = new StreamReader(httpWebResponse.GetResponseStream())) { responce = streamReader.ReadToEnd(); } WeatherInfo weather = JsonConvert.DeserializeObject <WeatherInfo>(responce); String[] infoWeather = { weather.Name, weather.Main.Temp.ToString(), weather.Wind.Speed.ToString() }; return(infoWeather); }
//Бот покажет текущую погоду за окном static string WeatherPls(string question) { String[] infoWeather = WeatherInfo.FindOutWeather(); return("Погода в городе " + infoWeather[0] + " " + infoWeather[1] + " °C" + ". Ветер " + infoWeather[2] + " м/c"); }