comparison teh-lol.pl @ 23:77444d749997

Use more meaningful variables names because jlf complained
author Jordi Gutiérrez Hermoso <jordigh@octave.org>
date Thu, 08 Sep 2011 14:29:31 -0500
parents 8ebcdfa03782
children 15b72cc602b4
comparison
equal deleted inserted replaced
22:8ebcdfa03782 23:77444d749997
26 Xchat::hook_print('Your Message', \&check_combo); 26 Xchat::hook_print('Your Message', \&check_combo);
27 27
28 my %timestamp; 28 my %timestamp;
29 29
30 sub update_tstamp{ 30 sub update_tstamp{
31 my @xchat_args = $_[0];
32 my $msg = $xchat_args[1];
31 if( $_[0][1] eq "lol" ){ 33 if( $_[0][1] eq "lol" ){
32 my $chan = Xchat::get_info("channel"); 34 my $chan = Xchat::get_info("channel");
33 $timestamp{$chan} = time; 35 $timestamp{$chan} = time;
34 } 36 }
35 return Xchat::EAT_NONE; 37 return Xchat::EAT_NONE;
44 } 46 }
45 close(FILE); 47 close(FILE);
46 } 48 }
47 49
48 sub check_lol { 50 sub check_lol {
51 my @xchat_args = $_[0];
52 my $chatter = $xchat_args[0];
53 my $msg = $xchat_args[1];
54
49 my $chan = Xchat::get_info("channel"); 55 my $chan = Xchat::get_info("channel");
50 my $timesince_lasttalk = time - Xchat::user_info -> {'lasttalk'}; 56 my $timesince_lasttalk = time - Xchat::user_info -> {'lasttalk'};
51 57
52 ## Chatter name without possible colour codes 58 ## Chatter name without possible colour codes
53 my $chatter = Xchat::strip_code($_[0][0]); 59 $chatter = Xchat::strip_code($chatter);
54 60
55 #Match stuff like "lol", "loool" and "lololol" 61 #Match stuff like "lol", "loool" and "lololol"
56 if ($_[0][1] =~ /\b(l((o|(?<!l)lo)+)l)\b/i 62 if ($msg =~ /\b(l((o|(?<!l)lo)+)l)\b/i
57 63
58 #Two minutes of not saying anything in the channel counts as 64 #Two minutes of not saying anything in the channel counts as
59 #idling, so don't pester when idling. 65 #idling, so don't pester when idling.
60 and $timesince_lasttalk < 120 66 and $timesince_lasttalk < 120
61 67
107 my %combo_count; 113 my %combo_count;
108 my %prev_loller; 114 my %prev_loller;
109 115
110 sub check_combo { 116 sub check_combo {
111 my $chan = Xchat::get_info("channel"); 117 my $chan = Xchat::get_info("channel");
118 my $loller = $_[0][0];
112 my $msg = $_[0][1]; 119 my $msg = $_[0][1];
113 my $islol = $msg =~ /^\s*l((o|(?<!l)lo)+)l\b/i; 120 my $islol = $msg =~ /^\s*l((o|(?<!l)lo)+)l\b/i;
121
114 if(not $islol) { 122 if(not $islol) {
115 my $combo = $combo_count{$chan}; 123 my $combo = $combo_count{$chan};
116 124
117 # We have a combo to report! 125 # We have a combo to report!
118 if($combo > 2) { 126 if($combo > 2) {
142 150
143 $combo_count{$chan} = 0; 151 $combo_count{$chan} = 0;
144 $prev_loller{$chan} = ""; 152 $prev_loller{$chan} = "";
145 } 153 }
146 else { 154 else {
147 my $loller = $_[0][0];
148
149 #A loller trying to cheat ruins the combo for everyone 155 #A loller trying to cheat ruins the combo for everyone
150 if( $loller eq $prev_loller{$chan}) { 156 if( $loller eq $prev_loller{$chan}) {
151 $combo_count{$chan} = 0; 157 $combo_count{$chan} = 0;
152 } 158 }
153 else { 159 else {