# HG changeset patch # User Jordi GutiƩrrez Hermoso # Date 1274716696 18000 # Node ID 037012a17457bd802847cde3affe1b0e7040895a # Parent 2b8b0412096aec6bd0639b2a23335d9e3b5935a0 An attempt to reset timestamps when manually lolling and change sleep with Xchat::hook_timer diff --git a/teh-lol.pl b/teh-lol.pl --- a/teh-lol.pl +++ b/teh-lol.pl @@ -18,16 +18,26 @@ Xchat::register('teh lol', '0.1.3', 'lols back'); Xchat::hook_print('Channel Message', \&check_lol); +Xchat::hook_print('Your Message', \&update_tstamp); use Time::HiRes; my %timestamp; +sub update_tstamp{ + if( $_[0][1] =~ /\b(lo+l)\b/i ){ + my $chan = Xchat::get_info("channel"); + $timestamp{$chan} = time; + } + return Xchat::EAT_NONE; +} + sub check_lol { my $chan = Xchat::get_info("channel"); my $timesince_lasttalk = time - Xchat::user_info -> {'lasttalk'}; - #Thirty minutes of not saying anything in the channel counts as idling + #Two minutes of not saying anything in the channel counts as idling, + #so don't pester when idling if ($_[0][1] =~ /\b(lo+l)\b/i and $timesince_lasttalk < 120) { my $lol = $1; @@ -52,7 +62,7 @@ #Delay the response a little, for maximum annoyance. #( theoros's algorithm from #not-math ) - my $delay = 0.8; + my $delay = 2.8; if (length($relol) > 3){ $delay += ((length $relol) - 3 + rand(5)) * 0.069; } @@ -60,9 +70,7 @@ #Convert to microseconds. $delay *= 1e6; - Time::HiRes::usleep($delay); - - Xchat::command("say $relol"); + Xchat::hook_timer($delay, sub { Xchat::command("say $relol"); }); } $timestamp{$chan} = time; }