################################ # Rude Module # ################################ # This module implements the same functionality as Insult.bm and # Excuse.bm but using remote servers. Those servers are currently (and # probably forever) down. This module is therefore mainly here for # historical interest, and may be removed from future distributions. # If you use, or need, this module, please let me know. - ian@hixie.ch package BotModules::Rude; use vars qw(@ISA); use Net::Telnet; @ISA = qw(BotModules); 1; sub Help { my $self = shift; my ($event) = @_; return { '' => 'The Rude Module is... rude. Very rude! So rude!!!', 'insult' => 'Insults someone. Syntax: \'insult \'', 'excuse' => 'Gives you an excuse for the system being down. Syntax: \'excuse\'', }; } # -- timeless was here -- # Rude module is missing a jar jar quote ~how wude~ # RegisterConfig - Called when initialised, should call registerVariables sub RegisterConfig { my $self = shift; $self->SUPER::RegisterConfig(@_); $self->registerVariables( # [ name, save?, settable? ] ['insultHost', 1, 1, 'insulthost.colorado.edu'], ['insultPort', 1, 1, '1695'], ['excuseHost', 1, 1, 'bofh.engr.wisc.edu'], # same host as bofh.jive.org ['excusePort', 1, 1, '666'], ['insultOverrides', 1, 1, { # overrides for the insults (keys must be lowercase) 'mozilla' => 'You are nothing but the best browser on the planet.', 'mozilla.org' => 'You are nothing but the best caretaker Mozilla ever had.', 'c++' => 'you are evil', }], ); } sub Told { my $self = shift; my ($event, $message) = @_; if ($message =~ /^\s*(?:will\s+you\s+)?(?:insult|harass)\s+(\S+?)(?:[\s,.]+please)?[\s.?!]*$/osi) { my $line; if (defined($self->{'insultOverrides'}->{lc $1})) { $line = "$1: ".$self->{'insultOverrides'}->{lc $1}; } else { eval { my $t = new Net::Telnet (Timeout => 3); $t->Net::Telnet::open(Host => $self->{'insultHost'}, Port => $self->{'insultPort'}); $line = "$1: ".$t->Net::Telnet::getline(Timeout => 4); }; } if ($line) { $self->say($event, $line); } else { $self->say($event, "$event->{'from'}: What have they ever done to you! Leave 'em alone!"); $self->debug("yikes, $self->{'insultHost'}:$self->{'insultPort'} is down!"); } } elsif ($message =~ /^\s*(?:please\s+)?(?:can\s+i\s+have\s+an\s+|(?:(?:can|could)\s+you\s+)?give\s+me\s+an\s+)?excuse(?:[?,.!1\s]+please)?\s*[!?,.1]*\s*$/osi) { my $line; eval { my $t = new Net::Telnet (Timeout => 3); $t->Net::Telnet::open(Host => $self->{'excuseHost'}, Port => $self->{'excusePort'}); # print "=== The BOFH-style Excuse Server --- Feel The Power!\n"; $t->Net::Telnet::getline(Timeout => 4); # print "=== By Jeff Ballard \n"; $t->Net::Telnet::getline(Timeout => 4); # print "=== See http://www.cs.wisc.edu/~ballard/bofh/ for more info.\n"; $t->Net::Telnet::getline(Timeout => 4); # print "Your excuse is: $excuses[$j]"; $line = $t->Net::Telnet::getline(Timeout => 4); }; if ($line) { # $line =~ s/^.*?Your excuse is: //gosi; # $self->say($event, "$event->{'from'}: '$line'"); $self->say($event, "$line"); } else { $self->say($event, "$event->{'from'}: Don't ask *me* for an excuse! Sheesh!"); $self->debug("yikes, $self->{'excuseHost'}:$self->{'excusePort'} is down!"); } } else { return $self->SUPER::Told(@_); } return 0; # we've dealt with it, no need to do anything else. }