mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-23 04:19:27 +01:00
Plugins/Wttr: return result as-is if JSON decode fails
This commit is contained in:
parent
0e1a496001
commit
0dce5861f3
@ -123,7 +123,8 @@ sub get_wttr {
|
||||
if ($response->is_success) { $json = $response->decoded_content; }
|
||||
else { return "Failed to fetch weather data: " . $response->status_line; }
|
||||
|
||||
my $wttr = decode_json $json;
|
||||
my $wttr = eval { decode_json $json };
|
||||
return $json if $@; # error decoding json so it must not be json -- return as-is
|
||||
|
||||
if (exists $wttr->{nearest_area}) {
|
||||
my $areaName = $wttr->{nearest_area}->[0]->{areaName}->[0]->{value};
|
||||
|
Loading…
Reference in New Issue
Block a user