Bot::BasicBot::Pluggable::Module::Whois - look up Internic/RIPE whois records for a host


Bot-BasicBot-Pluggable-Module-Network documentation Contained in the Bot-BasicBot-Pluggable-Module-Network distribution.

Index


Code Index:

NAME

Top

Bot::BasicBot::Pluggable::Module::Whois - look up Internic/RIPE whois records for a host

SYNOPSIS

Top

Queries RIPE or the Internic for the whois information about the supplied host, and formats it up nicely.

IRC USAGE

Top

    Internic|RIPE for <host>

AUTHOR

Top

Simon Wistow, <simon@thegestalt.org>

COPYRIGHT

Top

SEE ALSO

Top


Bot-BasicBot-Pluggable-Module-Network documentation Contained in the Bot-BasicBot-Pluggable-Module-Network distribution.

package Bot::BasicBot::Pluggable::Module::Whois;

use strict;
use Bot::BasicBot::Pluggable::Module; 
use base qw(Bot::BasicBot::Pluggable::Module);

use Net::Whois;

sub said { 
    my ($self, $mess, $pri) = @_;

    my $body = $mess->{body}; 
    my $who  = $mess->{who};

    return unless ($pri == 2);

    return unless $body =~ /^(whois|internic|ripe)(?: for)?\s+(\S+)$/i;

    my $where = $1;
    my $what  = $2;

    my $w = Net::Whois::Domain->new($what) || return "Can't connect to the WHOIS server";

    return "No match for $what" unless $w->ok;

    my $address = join "", map { "$_, " } $w->address;
    my $ns      = join "", map { my $name =  $$_[0]; my $ip = $$_[1] || " "; "$name ($ip), " } @{$w->servers};

    my $response = "";
    $response .= "Domain: ". $w->domain. " ";
    $response .= "Name: ". $w->name. " ";
    $response .= "Tag: ". $w->tag. " ";
    $response .= "Address: $address ";
    $response .= "Country: ". $w->country. " ";
    $response .= "Name Servers: $ns"; 

    return $response;



}

sub help {
    return "Commands: '(whois|internic|ripe) fo <host>'";
}

1;