changeset 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
files teh-lol.pl
diffstat 1 files changed, 40 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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