3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-20 02:49:49 +01:00

Plugins/Wttr: improve output

This commit is contained in:
Pragmatic Software 2020-04-08 00:57:56 -07:00
parent e3a7621073
commit 917ceb4912

View File

@ -165,9 +165,17 @@ sub get_wttr {
foreach my $option (@options) { foreach my $option (@options) {
given ($option) { given ($option) {
when ('default') { when ('default') {
$result .= "Currently: $c->{'weatherDesc'}->[0]->{'value'}: $c->{'temp_C'}C/$c->{'temp_F'}F; "; $result .= "Currently: $c->{'weatherDesc'}->[0]->{'value'}: $c->{'temp_C'}C/$c->{'temp_F'}F";
if ($c->{'FeelsLikeC'} != $c->{'temp_C'}) {
$result .= " (Feels like $c->{'FeelsLikeC'}C/$c->{'FeelsLikeF'}F); ";
} else {
$result .= '; ';
}
$result .= "Forecast: High: $w->{maxtempC}C/$w->{maxtempF}F, Low: $w->{mintempC}C/$w->{mintempF}F; "; $result .= "Forecast: High: $w->{maxtempC}C/$w->{maxtempF}F, Low: $w->{mintempC}C/$w->{mintempF}F; ";
$result .= "Condition changes: ";
my $conditions = "Condition changes: ";
my $last_condition = $c->{'weatherDesc'}->[0]->{'value'}; my $last_condition = $c->{'weatherDesc'}->[0]->{'value'};
my $sep = ''; my $sep = '';
@ -181,7 +189,7 @@ sub get_wttr {
if ($condition ne $last_condition) { if ($condition ne $last_condition) {
my ($hour, $minute) = split /:/, $time; my ($hour, $minute) = split /:/, $time;
if (($hour > $obshour) or ($hour == $obshour and $minute >= $obsminute)) { if (($hour > $obshour) or ($hour == $obshour and $minute >= $obsminute)) {
$result .= "$sep$time: $condition ($temp)"; $conditions .= "$sep$time: $condition ($temp)";
$sep = '-> '; $sep = '-> ';
$last_condition = $condition; $last_condition = $condition;
} }
@ -189,17 +197,11 @@ sub get_wttr {
} }
if ($sep eq '') { if ($sep eq '') {
$result = '';
$result .= "Current conditions: $c->{'weatherDesc'}->[0]->{'value'}: $c->{'temp_C'}C/$c->{'temp_F'}F";
if ($c->{'FeelsLikeC'} != $c->{'temp_C'}) {
$result .= " (Feels like $c->{'FeelsLikeC'}C/$c->{'FeelsLikeF'}F); ";
} else {
$result .= '; ';
}
$result .= "Forecast: High: $w->{maxtempC}C/$w->{maxtempF}F, Low: $w->{mintempC}C/$w->{mintempF}F; ";
$result .= "Cloud cover: $c->{'cloudcover'}%; Visibility: $c->{'visibility'}km; "; $result .= "Cloud cover: $c->{'cloudcover'}%; Visibility: $c->{'visibility'}km; ";
$result .= "Wind: $c->{'windspeedKmph'}kph/$c->{'windspeedMiles'}mph $c->{'winddirDegree'}°/$c->{'winddir16Point'}; "; $result .= "Wind: $c->{'windspeedKmph'}kph/$c->{'windspeedMiles'}mph $c->{'winddirDegree'}°/$c->{'winddir16Point'}; ";
$result .= "Humidity: $c->{'humidity'}%; Precip: $c->{'precipMM'}mm; Pressure: $c->{'pressure'}hPa; UV Index: $c->{'uvIndex'}"; $result .= "Humidity: $c->{'humidity'}%; Precip: $c->{'precipMM'}mm; Pressure: $c->{'pressure'}hPa; UV Index: $c->{'uvIndex'}";
} else {
$result .= $conditions;
} }
$result .= '; '; $result .= '; ';