comparison teh-lol.pl @ 15:0d8587643fc6

Initial lolcombo implementation
author Jordi Gutiérrez Hermoso <jordigh@gmail.com>
date Sun, 30 Jan 2011 15:37:58 -0600
parents e9348ac85d5c
children 895bcfde1df4
comparison
equal deleted inserted replaced
14:e9348ac85d5c 15:0d8587643fc6
1 #Copyright © 2009, 2010 Jordi Gutiérrez Hermoso <jordigh@gmail.com> 1 #Copyright © 2009 - 2011 Jordi Gutiérrez Hermoso <jordigh@gmail.com>
2 # 2 #
3 #teh-lol.pl is free software: you can redistribute it and/or modify 3 #teh-lol.pl is free software: you can redistribute it and/or modify
4 #it under the terms of the GNU General Public License as published by 4 #it under the terms of the GNU General Public License as published by
5 #the Free Software Foundation, either version 3 of the License, or 5 #the Free Software Foundation, either version 3 of the License, or
6 #(at your option) any later version. 6 #(at your option) any later version.
15 15
16 use strict; 16 use strict;
17 17
18 Xchat::register('teh lol', '0.1.3', 'lols back'); 18 Xchat::register('teh lol', '0.1.3', 'lols back');
19 19
20 #Check if it's time to relol
20 Xchat::hook_print('Channel Message', \&check_lol); 21 Xchat::hook_print('Channel Message', \&check_lol);
21 Xchat::hook_print('Your Message', \&update_tstamp); 22 Xchat::hook_print('Your Message', \&update_tstamp);
23
24 #Report lol combos
25 Xchat::hook_print('Channel Message', \&check_combo);
26 Xchat::hook_print('Your Message', \&check_combo);
22 27
23 my %timestamp; 28 my %timestamp;
24 29
25 sub update_tstamp{ 30 sub update_tstamp{
26 if( $_[0][1] eq "lol" ){ 31 if( $_[0][1] eq "lol" ){
80 $timestamp{$chan} = time; 85 $timestamp{$chan} = time;
81 } 86 }
82 return Xchat::EAT_NONE; 87 return Xchat::EAT_NONE;
83 } 88 }
84 89
90 my $prev_msg = "";
91 my %chan_combo_count;
92
93 sub check_combo {
94 my $chan = Xchat::get_info("channel");
95 my $msg = $_[0][1];
96 my $islol = $msg =~ /^\s*l((o|(?<!l)lo)+)l/i;
97 if(not $islol) {
98 my $combo = $chan_combo_count{$chan};
99
100 # We have a combo to report!
101 if($combo > 2) {
102 my $qualifier;
103 if($combo == 3){
104 $qualifier = "Good";
105 }
106 else if ($combo > 3 and $combo < 5) {
107 $qualifier = "Great";
108 }
109 else{
110 $qualifier = "Marvelous";
111 }
112 my $report = "$combo-lol combo! $qualifier!";
113 Xchat::command("say $report");
114 return Xchat::REMOVE;
115 }
116 $chan_combo_count{$chan} = 0;
117 }
118 else {
119 $chan_combo_count{$chan}++;
120 }
121 return Xchat::EAT_NONE;
122 }
123
85 # lolololol 124 # lolololol
86 # lol 125 # lol
87 # loooooooool 126 # loooooooool