view teh-lol.pl @ 4:64eeadb27362

Fix relol typo, decrease echo time.
author Jordi Gutiérrez Hermoso <jordigh@gmail.com>
date Wed, 12 Aug 2009 18:30:53 -0500
parents 6c34daa0afb0
children 8f209cd0a7b6
line wrap: on
line source

#Copyright © 2009 Jordi Gutiérrez Hermoso
#
#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
#the Free Software Foundation, either version 3 of the License, or
#(at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.
#
#You should have received a copy of the GNU General Public License
#along with this program.  If not, see <http://www.gnu.org/licenses/>.

Xchat::register('teh lol', '0.1.3', 'lols back');

Xchat::hook_print('Channel Message', \&check_lol);

my %timestamp;

sub check_lol {
  my $chan = Xchat::get_info("channel");

  if ($_[0][1] =~ /\b(lo+l)\b/i) {

    my $lol = $1;

    my $relol;

    #Mimic long lols
    if (length $lol > 3 ) {
      my $numos = int rand(3);
      $numos += 3;
      $relol = "l".("o" x $numos)."l";
    }
    else {
      $relol = "lol";
    }

    sleep(rand(5));

    if (time - $timestamp{$chan} > 59 or
        undef $timestamp{$chan}
        ) {

      #Delay the response a little, for maximum annoyance.
      sleep (rand(3)+2);

      Xchat::command("say $relol");
    }

    $timestamp{$chan} = time;
  }
  return Xchat::EAT_NONE;
}