Mercurial > hg > scripts
changeset 9:037012a17457
An attempt to reset timestamps when manually lolling and change sleep with Xchat::hook_timer
author | Jordi Gutiérrez Hermoso <jordigh@gmail.com> |
---|---|
date | Mon, 24 May 2010 10:58:16 -0500 |
parents | 2b8b0412096a |
children | c1bbeff37875 |
files | teh-lol.pl |
diffstat | 1 files changed, 13 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- 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; }