private function getWeatherString(array $data)
{
try {
if (!(isset($data['cod']) && $data['cod'] === 200)) {
return '';
}
//http://openweathermap.org/weather-conditions
$conditions = ['clear' => ' ☀️', 'clouds' => ' ☁️', 'rain' => ' ☔', 'drizzle' => ' ☔', 'thunderstorm' => ' ⚡️', 'snow' => ' ❄️'];
$conditions_now = strtolower($data['weather'][0]['main']);
return sprintf('The temperature in %s (%s) is %s°C' . "\n" . 'Current conditions are: %s%s', $data['name'], $data['sys']['country'], $data['main']['temp'], $data['weather'][0]['description'], isset($conditions[$conditions_now]) ? $conditions[$conditions_now] : '');
} catch (Exception $e) {
TelegramLog::error($e->getMessage());
return '';
}
}