1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | class weatherbot { function weather(&$irc, &$data) { global $wdc; $zip = $data->messageex[1]; $irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, "Yeah, weather for $zip"); $fc = $wdc->getForecast( $zip, 1 ); foreach( $fc['days'] as $day ) { $irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, "Condition: ".$day['day'][ 'condition' ] ); $irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, "High: ".$day[ 'temperatureHigh' ] ); $irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, "Low: ".$day[ 'temperatureLow' ] ); $irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, "Wind: ".$day['day'][ 'wind' ] ); $irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, "Wind Degrees: ".$day['day'][ 'windDegrees' ] ); $irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, "Wind Direction: ".$day['day'][ 'windDirection' ] ); $irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, "Precipitation: ".$day['day'][ 'precipitation' ] ); $irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, "Humidity: ".$day['day'][ 'humidity' ] ); } } } |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |