#!/usr/bin/perl # based on standard idea and standard implementation by CyBeR # moduled by Alberto Simões (albie@alfarrabio.di.uminho.pt) package Insults; use cybot; @insults = load_list("data/insults"); register_command("insult", sub { my ($bot,$chan,$nick,$host, @commands) = @_; if ($commands[0] eq "reload"){ @insults = load_list("data/insults"); $bot->message ($chan, $#insults+1 . " insults loaded."); } elsif ($commands[0] eq "me") { my $x = random($#insults); $insult = $insults[$x]; $insult =~ s//$nick/; $insult =~ s//$chan/; @insultfoo = split("\\\\n", $insult); for (0..$#insultfoo){ if ($insultfoo[$_] =~ /^me (.*)/){ $bot->action($chan, $1); } else { $bot->message ($chan, $insultfoo[$_]); } } } else { my $x = random($#insults); $insult = $insults[$x]; $insult =~ s//join(" ",@commands)/e; $insult =~ s//$chan/; @insultfoo = split("\\\\n", $insult); for (0..$#insultfoo){ if ($insultfoo[$_] =~ /^me (.*)/){ $bot->action($chan, $1); } else { $bot->message ($chan, $insultfoo[$_]); } } } }, "insults... [reload - reloads insults]"); 1;