mirror of
https://github.com/pragma-/pbot.git
synced 2024-12-23 19:22:40 +01:00
Fix "keys on scalar" deprecation warning on newer perl. (#3)
This patch fixes the warning "Experimental keys on scalar is now forbidden" which appears when running pbot on newer versions of perl.
This commit is contained in:
parent
f65f6df116
commit
382e47d971
@ -111,7 +111,7 @@ sub adminrem {
|
||||
|
||||
if (exists $self->{pbot}->{admins}->{admins}->hash->{$channel}) {
|
||||
if (not exists $self->{pbot}->{admins}->{admins}->hash->{$channel}->{$hostmask}) {
|
||||
foreach my $mask (keys $self->{pbot}->{admins}->{admins}->hash->{$channel}) {
|
||||
foreach my $mask (keys %{ $self->{pbot}->{admins}->{admins}->hash->{$channel} }) {
|
||||
if ($self->{pbot}->{admins}->{admins}->hash->{$channel}->{$mask}->{name} eq $hostmask) {
|
||||
$hostmask = $mask;
|
||||
last;
|
||||
@ -143,7 +143,7 @@ sub adminset {
|
||||
|
||||
if (exists $self->{pbot}->{admins}->{admins}->hash->{$channel}) {
|
||||
if (not exists $self->{pbot}->{admins}->{admins}->hash->{$channel}->{$hostmask}) {
|
||||
foreach my $mask (keys $self->{pbot}->{admins}->{admins}->hash->{$channel}) {
|
||||
foreach my $mask (keys %{ $self->{pbot}->{admins}->{admins}->hash->{$channel} }) {
|
||||
if ($self->{pbot}->{admins}->{admins}->hash->{$channel}->{$mask}->{name} eq $hostmask) {
|
||||
$hostmask = $mask;
|
||||
last;
|
||||
@ -171,7 +171,7 @@ sub adminunset {
|
||||
|
||||
if (exists $self->{pbot}->{admins}->{admins}->hash->{$channel}) {
|
||||
if (not exists $self->{pbot}->{admins}->{admins}->hash->{$channel}->{$hostmask}) {
|
||||
foreach my $mask (keys $self->{pbot}->{admins}->{admins}->hash->{$channel}) {
|
||||
foreach my $mask (keys %{ $self->{pbot}->{admins}->{admins}->hash->{$channel} }) {
|
||||
if ($self->{pbot}->{admins}->{admins}->hash->{$channel}->{$mask}->{name} eq $hostmask) {
|
||||
$hostmask = $mask;
|
||||
last;
|
||||
|
@ -328,7 +328,7 @@ sub remove {
|
||||
delete $self->hash->{$primary}->{$secondary};
|
||||
|
||||
# remove primary group if no more secondaries
|
||||
if(scalar keys $self->hash->{$primary} == 0) {
|
||||
if(scalar keys %{ $self->hash->{$primary} } == 0) {
|
||||
delete $self->hash->{$primary};
|
||||
}
|
||||
|
||||
|
@ -124,7 +124,7 @@ sub remove_factoid {
|
||||
|
||||
delete $self->{factoids}->hash->{$channel}->{$trigger};
|
||||
|
||||
if(not scalar keys $self->{factoids}->hash->{$channel}) {
|
||||
if(not scalar keys %{ $self->{factoids}->hash->{$channel} }) {
|
||||
delete $self->{factoids}->hash->{$channel};
|
||||
}
|
||||
|
||||
|
@ -98,7 +98,7 @@ sub get_channels {
|
||||
|
||||
$nick = lc $nick;
|
||||
|
||||
foreach my $channel (keys $self->{nicklist}) {
|
||||
foreach my $channel (keys %{ $self->{nicklist} }) {
|
||||
if (exists $self->{nicklist}->{$channel}->{$nick}) {
|
||||
push @channels, $channel;
|
||||
}
|
||||
@ -140,7 +140,7 @@ sub is_present_similar {
|
||||
$percentage = 0.20 if not defined $percentage;
|
||||
|
||||
my $now = gettimeofday;
|
||||
foreach my $person (sort { $self->{nicklist}->{$channel}->{$b}->{timestamp} <=> $self->{nicklist}->{$channel}->{$a}->{timestamp} } keys $self->{nicklist}->{$channel}) {
|
||||
foreach my $person (sort { $self->{nicklist}->{$channel}->{$b}->{timestamp} <=> $self->{nicklist}->{$channel}->{$a}->{timestamp} } keys %{ $self->{nicklist}->{$channel} }) {
|
||||
return 0 if $now - $self->{nicklist}->{$channel}->{$person}->{timestamp} > 3600; # 1 hour
|
||||
my $distance = fastdistance($nick, $person);
|
||||
my $length = length $nick > length $person ? length $nick : length $person;
|
||||
@ -165,7 +165,8 @@ sub random_nick {
|
||||
|
||||
if (exists $self->{nicklist}->{$channel}) {
|
||||
my $now = gettimeofday;
|
||||
my @nicks = grep { $now - $self->{nicklist}->{$channel}->{$_}->{timestamp} < 3600 * 2 } keys $self->{nicklist}->{$channel};
|
||||
my @nicks = grep { $now - $self->{nicklist}->{$channel}->{$_}->{timestamp} < 3600 * 2 } keys %{ $self->{nicklist}->{$channel} };
|
||||
|
||||
my $nick = $nicks[rand @nicks];
|
||||
return $self->{nicklist}->{$channel}->{$nick}->{nick};
|
||||
} else {
|
||||
@ -210,7 +211,7 @@ sub on_quit {
|
||||
my ($self, $event_type, $event) = @_;
|
||||
my ($nick, $user, $host) = ($event->{event}->nick, $event->{event}->user, $event->{event}->host);
|
||||
|
||||
foreach my $channel (keys $self->{nicklist}) {
|
||||
foreach my $channel (keys %{ $self->{nicklist} }) {
|
||||
if ($self->is_present($channel, $nick)) {
|
||||
$self->remove_nick($channel, $nick);
|
||||
}
|
||||
@ -230,7 +231,7 @@ sub on_nickchange {
|
||||
my ($self, $event_type, $event) = @_;
|
||||
my ($nick, $user, $host, $newnick) = ($event->{event}->nick, $event->{event}->user, $event->{event}->host, $event->{event}->args);
|
||||
|
||||
foreach my $channel (keys $self->{nicklist}) {
|
||||
foreach my $channel (keys %{ $self->{nicklist} }) {
|
||||
if ($self->is_present($channel, $nick)) {
|
||||
$self->remove_nick($channel, $nick);
|
||||
$self->add_nick($channel, $newnick);
|
||||
|
@ -154,7 +154,7 @@ sub list_cmd {
|
||||
my $count = 0;
|
||||
my $comma = '';
|
||||
|
||||
foreach my $plugin (sort keys $self->{plugins}) {
|
||||
foreach my $plugin (sort keys %{ $self->{plugins} }) {
|
||||
$result .= $comma . $plugin;
|
||||
$count++;
|
||||
$comma = ', ';
|
||||
|
@ -97,7 +97,7 @@ sub remove {
|
||||
|
||||
delete $self->{registry}->hash->{$section}->{$item};
|
||||
|
||||
if(not scalar keys $self->{registry}->hash->{$section}) {
|
||||
if(not scalar keys %{ $self->{registry}->hash->{$section} }) {
|
||||
delete $self->{registry}->hash->{$section};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user