private async Task <string> GetStock(string StockSymbol) { double?dblStockValue = await MengmengBotTask.GetStockRateAsync(StockSymbol); if (dblStockValue == null) { return(string.Format("呃。。。\"{0}\"这个貌似不是股票代码呢", StockSymbol)); } else { return($"{StockSymbol}这个股票现在的价格是{dblStockValue}美元啦!"); } }
private async Task <string> GetWeather(string cityname) { WeatherData weatherdata = await MengmengBotTask.GetWeatherAsync(cityname); if (weatherdata == null || weatherdata.HeWeatherdataservice30 == null) { return(string.Format("呃。。。萌萌不知道\"{0}\"这个城市的天气信息", cityname)); } else { HeweatherDataService30[] weatherServices = weatherdata.HeWeatherdataservice30; if (weatherServices.Length <= 0) { return(string.Format("呃。。。萌萌不知道\"{0}\"这个城市的天气信息", cityname)); } Basic cityinfo = weatherServices[0].basic; if (cityinfo == null) { return(string.Format("呃。。。萌萌目测\"{0}\"这个应该不是一个城市的名字。。不然我咋不知道呢。。。", cityname)); } String cityinfoString = "城市信息:" + cityinfo.city + "\r\n" + "更新时间:" + cityinfo.update.loc + "\r\n" + "经纬度:" + cityinfo.lat + "," + cityinfo.lon + "\r\n"; Aqi cityAirInfo = weatherServices[0].aqi; String airInfoString = "空气质量指数:" + cityAirInfo.city.aqi + "\r\n" + "PM2.5 1小时平均值:" + cityAirInfo.city.pm25 + "(ug/m³)\r\n" + "PM10 1小时平均值:" + cityAirInfo.city.pm10 + "(ug/m³)\r\n" + "二氧化硫1小时平均值:" + cityAirInfo.city.so2 + "(ug/m³)\r\n" + "二氧化氮1小时平均值:" + cityAirInfo.city.no2 + "(ug/m³)\r\n" + "一氧化碳1小时平均值:" + cityAirInfo.city.co + "(ug/m³)\r\n"; Suggestion citySuggestion = weatherServices[0].suggestion; String suggestionString = "生活指数:" + "\r\n" + "穿衣指数:" + citySuggestion.drsg.txt + "\r\n" + "紫外线指数:" + citySuggestion.uv.txt + "\r\n" + "舒适度指数:" + citySuggestion.comf.txt + "\r\n" + "旅游指数:" + citySuggestion.trav.txt + "\r\n" + "感冒指数:" + citySuggestion.flu.txt + "\r\n"; Daily_Forecast[] cityDailyForecast = weatherServices[0].daily_forecast; Now cityNowStatus = weatherServices[0].now; String nowStatusString = "天气实况:" + "\r\n" + "当前温度(摄氏度):" + cityNowStatus.tmp + "\r\n" + "体感温度:" + cityNowStatus.fl + "\r\n" + "风速:" + cityNowStatus.wind.spd + "(Kmph)\r\n" + "湿度:" + cityNowStatus.hum + "(%)\r\n" + "能见度:" + cityNowStatus.vis + "(km)\r\n"; return(string.Format("现在{0}天气实况:\r\n{1}", cityname, cityinfoString + nowStatusString + airInfoString + suggestionString)); } }