# HG changeset patch # User Jordi GutiƩrrez Hermoso # Date 1250795011 18000 # Node ID 6999ba7bf22b9859e2961e748d5bfda606335d84 # Parent 8f209cd0a7b6aa0742c331e996f047e03f8053aa Don't relol while idling (2 minutes of not participating in discussion) diff --git a/teh-lol.pl b/teh-lol.pl --- a/teh-lol.pl +++ b/teh-lol.pl @@ -13,6 +13,8 @@ #You should have received a copy of the GNU General Public License #along with this program. If not, see . +use strict; + Xchat::register('teh lol', '0.1.3', 'lols back'); Xchat::hook_print('Channel Message', \&check_lol); @@ -23,8 +25,10 @@ sub check_lol { my $chan = Xchat::get_info("channel"); + my $timesince_lasttalk = time - Xchat::user_info -> {'lasttalk'}; - if ($_[0][1] =~ /\b(lo+l)\b/i) { + #Two minutes of not saying anything in the channel counts as idling + if ($_[0][1] =~ /\b(lo+l)\b/i and $timesince_lasttalk < 120) { my $lol = $1; @@ -40,10 +44,10 @@ $relol = "lol"; } - sleep(rand(5)); + - if (time - $timestamp{$chan} > 59 or - undef $timestamp{$chan} + if ( time - $timestamp{$chan} > 59 or + undef $timestamp{$chan} ) { #Delay the response a little, for maximum annoyance. @@ -53,11 +57,10 @@ $delay += ((length $relol) - 3 + rand(5)) * 0.069; } - Time::HiRes::usleep($delay); + Time::HiRes::usleep($delay+2); Xchat::command("say $relol"); } - $timestamp{$chan} = time; } return Xchat::EAT_NONE;