From a21b27a11f4c939208c6378280cf1b7cfe98fcce Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Mon, 10 Apr 2017 19:15:08 -0700 Subject: [PATCH] $randomnick now limited to nicks who have spoken in last 2 hours --- PBot/NickList.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/PBot/NickList.pm b/PBot/NickList.pm index 4c9c4908..769f577c 100644 --- a/PBot/NickList.pm +++ b/PBot/NickList.pm @@ -164,7 +164,8 @@ sub random_nick { $channel = lc $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]; return $self->{nicklist}->{$channel}->{$nick}->{nick}; } else {