3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-10-05 10:58:44 +02:00

$randomnick now limited to nicks who have spoken in last 2 hours

This commit is contained in:
Pragmatic Software 2017-04-10 19:15:08 -07:00
parent cf4478c1a4
commit a21b27a11f

View File

@ -164,7 +164,8 @@ sub random_nick {
$channel = lc $channel; $channel = lc $channel;
if (exists $self->{nicklist}->{$channel}) { if (exists $self->{nicklist}->{$channel}) {
my @nicks = keys $self->{nicklist}->{$channel}; my $now = gettimeofday;
my @nicks = grep { $now - $self->{nicklist}->{$channel}->{$_}->{timestamp} < 3600 * 2 } keys $self->{nicklist}->{$channel};
my $nick = $nicks[rand @nicks]; my $nick = $nicks[rand @nicks];
return $self->{nicklist}->{$channel}->{$nick}->{nick}; return $self->{nicklist}->{$channel}->{$nick}->{nick};
} else { } else {