public function getPrecipitation($match, $event)
    {
        $location = explode('@', $match);
        $where = trim($location[0]);
        $when  = trim($location[1]);

        if (!$found = $this->getLatLongForLocation($where)) {
            $this->addLatLongError($event);
            return;
        }

        try {
            $time = new \DateTime($when);
            list($lat, $long) = $found;
            $precipitation = $this->darksky->getPrecipitation(array(
                'lat'  => $lat,
                'long' => $long,
                'time' => $time->getTimestamp()
            ));

            $chanceOfRain = $precipitation['precipitation'][0]['probability'] * 100;
            $intensity = $precipitation['precipitation'][0]['intensity'];

            $event->addResponse(
                Response::msg(
                    $event->getRequest()->getSource(),
                    sprintf('[Weather for %s @ %s] %s (%d%% chance of rain)',
                        $where,
                        $time->format('g:ia'),
                        $this->getEnglishIntensity($intensity),
                        $chanceOfRain
                    )
                )
            );
        } catch (\Exception $ex) {
            $this->addErrorMsg($event, "Oops. I'm unable to get the precipitation for that location at that time...");
            return;
        }
    }
public function getPrecipitation($match, $event)
    {
        $location = explode('@', $match);
        $where = trim($location[0]);
        $when  = trim($location[1]);

        if (!$found = $this->getLatLongForLocation($where)) {
            $this->addLatLongError($event);
            return;
        }

        try {
            $time = new \DateTime($when);
            list($lat, $long) = $found;
            $precipitation = $this->darksky->getPrecipitation(array(
                'lat'  => $lat,
                'long' => $long,
                'time' => $time->getTimestamp()
            ));

            $chanceOfRain = $precipitation['precipitation'][0]['probability'] * 100;
            $intensity = $precipitation['precipitation'][0]['intensity'];

            $event->addResponse(
                Response::msg(
                    $event->getRequest()->getSource(),
                    sprintf('[Weather for %s @ %s] %s (%d%% chance of rain)',
                        $where,
                        $time->format('g:ia'),
                        $this->getEnglishIntensity($intensity),
                        $chanceOfRain
                    )
                )
            );
        } catch (\Exception $ex) {
            $this->addErrorMsg($event, "Oops. I'm unable to get the precipitation for that location at that time...");
            return;
        }
    }
public function getPrecipitation ( $ match , $ event ) { $ location = explode ( '@' , $ match ) ; $ where = trim ( $ location [ 0 ] ) ; $ when = trim ( $ location [ 1 ] ) ; if ( ! $ found = $ this -> getLatLongForLocation ( $ where ) ) { $ this -> addLatLongError ( $ event ) ; return ; } try { $ time = new \ DateTime ( $ when ) ; list ( $ lat , $ long ) = $ found ; $ precipitation = $ this -> darksky -> getPrecipitation ( array ( 'lat' => $ lat , 'long' => $ long , 'time' => $ time -> getTimestamp ( ) ) ) ; $ chanceOfRain = $ precipitation [ 'precipitation' ] [ 0 ] [ 'probability' ] * 100 ; $ intensity = $ precipitation [ 'precipitation' ] [ 0 ] [ 'intensity' ] ; $ event -> addResponse ( Response :: msg ( $ event -> getRequest ( ) -> getSource ( ) , sprintf ( '[Weather for %s @ %s] %s (%d%% chance of rain)' , $ where , $ time -> format ( 'g:ia' ) , $ this -> getEnglishIntensity ( $ intensity ) , $ chanceOfRain ) ) ) ; } catch ( \ Exception $ ex ) { $ this -> addErrorMsg ( $ event , "Oops. I'm unable to get the precipitation for that location at that time..." ) ; return ; } }
Gets the precipitation at a specific place and time.

@param string $match The remainder of the match (holds location info)
@param \Philip\IRC\Event $event The event to handle.

@return void
Gets the precipitation at a specific place and time .