changeset 10:c1bbeff37875

Bugfixes to last commit
author Jordi Gutiérrez Hermoso <jordigh@gmail.com>
date Mon, 24 May 2010 11:27:19 -0500
parents 037012a17457
children 2f298f94a096
files teh-lol.pl
diffstat 1 files changed, 10 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/teh-lol.pl
+++ b/teh-lol.pl
@@ -20,12 +20,10 @@
 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 ){
+  if( $_[0][1] eq "lol" ){
     my $chan = Xchat::get_info("channel");
     $timestamp{$chan} = time;
   }
@@ -62,15 +60,20 @@
 
       #Delay the response a little, for maximum annoyance.
       #( theoros's algorithm from #not-math )
-      my $delay = 2.8;
+      my $delay = 1.8;
       if (length($relol) > 3){
         $delay += ((length $relol) - 3 + rand(5)) * 0.069;
       }
 
-      #Convert to microseconds.
-      $delay *= 1e6;
+      #Convert to milliseconds.
+      $delay *= 1e3;
 
-      Xchat::hook_timer($delay, sub { Xchat::command("say $relol"); });
+      Xchat::hook_timer($delay,
+                        sub {
+                          Xchat::command("say $relol");
+                          return Xchat::REMOVE;
+                        }
+                        );
     }
     $timestamp{$chan} = time;
   }