mirror of
https://github.com/pragma-/pbot.git
synced 2024-12-23 19:22:40 +01:00
Plugins/Weather: fix -u user overriding
This commit is contained in:
parent
696742ad2b
commit
1817e9171c
@ -53,11 +53,16 @@ sub cmd_weather {
|
|||||||
return "/say $getopt_error -- $usage" if defined $getopt_error;
|
return "/say $getopt_error -- $usage" if defined $getopt_error;
|
||||||
$arguments = "@opt_args";
|
$arguments = "@opt_args";
|
||||||
|
|
||||||
my $hostmask = defined $user_override ? $user_override : $context->{hostmask};
|
if (defined $user_override) {
|
||||||
my $location_override = $self->{pbot}->{users}->get_user_metadata($context->{from}, $hostmask, 'location') // '';
|
my $userdata = $self->{pbot}->{users}->{users}->get_data($user_override);
|
||||||
$arguments = $location_override if not length $arguments;
|
return "No such user account $user_override." if not defined $userdata;
|
||||||
|
return "User account does not have `location` set." if not exists $userdata->{location};
|
||||||
if (defined $user_override and not length $location_override) { return "No location set or user account does not exist. They may use the `my` command to set the `location` user metadata their user account."; }
|
$arguments = $userdata->{location};
|
||||||
|
} else {
|
||||||
|
if (not length $arguments) {
|
||||||
|
$arguments = $self->{pbot}->{users}->get_user_metadata($context->{from}, $context->{hostmask}, 'location') // '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (not length $arguments) { return $usage; }
|
if (not length $arguments) { return $usage; }
|
||||||
return $self->get_weather($arguments);
|
return $self->get_weather($arguments);
|
||||||
|
Loading…
Reference in New Issue
Block a user