# HG changeset patch # User Jordi Gutiérrez Hermoso <jordigh@gmail.com> # Date 1296423478 21600 # Node ID 0d8587643fc660bdbb0dc3d024219b192c927717 # Parent e9348ac85d5c362714eafb92b215a582c74fd519 Initial lolcombo implementation diff --git a/teh-lol.pl b/teh-lol.pl --- a/teh-lol.pl +++ b/teh-lol.pl @@ -1,4 +1,4 @@ -#Copyright © 2009, 2010 Jordi Gutiérrez Hermoso <jordigh@gmail.com> +#Copyright © 2009 - 2011 Jordi Gutiérrez Hermoso <jordigh@gmail.com> # #teh-lol.pl is free software: you can redistribute it and/or modify #it under the terms of the GNU General Public License as published by @@ -17,9 +17,14 @@ Xchat::register('teh lol', '0.1.3', 'lols back'); +#Check if it's time to relol Xchat::hook_print('Channel Message', \&check_lol); Xchat::hook_print('Your Message', \&update_tstamp); +#Report lol combos +Xchat::hook_print('Channel Message', \&check_combo); +Xchat::hook_print('Your Message', \&check_combo); + my %timestamp; sub update_tstamp{ @@ -82,6 +87,40 @@ return Xchat::EAT_NONE; } +my $prev_msg = ""; +my %chan_combo_count; + +sub check_combo { + my $chan = Xchat::get_info("channel"); + my $msg = $_[0][1]; + my $islol = $msg =~ /^\s*l((o|(?<!l)lo)+)l/i; + if(not $islol) { + my $combo = $chan_combo_count{$chan}; + + # We have a combo to report! + if($combo > 2) { + my $qualifier; + if($combo == 3){ + $qualifier = "Good"; + } + else if ($combo > 3 and $combo < 5) { + $qualifier = "Great"; + } + else{ + $qualifier = "Marvelous"; + } + my $report = "$combo-lol combo! $qualifier!"; + Xchat::command("say $report"); + return Xchat::REMOVE; + } + $chan_combo_count{$chan} = 0; + } + else { + $chan_combo_count{$chan}++; + } + return Xchat::EAT_NONE; +} + # lolololol # lol # loooooooool