| 1 | package Bot::BasicBot::Pluggable::Module::DNS; | ||
| 2 | $Bot::BasicBot::Pluggable::Module::DNS::VERSION = '1.11'; | ||
| 3 | use base qw(Bot::BasicBot::Pluggable::Module); | ||
| 4 | use warnings; | ||
| 5 | use strict; | ||
| 6 | |||
| 7 | use Socket; | ||
| 8 | |||
| 9 | sub help { | ||
| 10 | return | ||
| 11 | "DNS lookups for hosts or IPs. Usage: 'dns <ip address>' for the hostname, 'nslookup <hostname>' for the IP address."; | ||
| 12 | } | ||
| 13 | |||
| 14 | sub told { | ||
| 15 | my ( $self, $mess ) = @_; | ||
| 16 | my $body = $mess->{body}; | ||
| 17 | |||
| 18 | my ( $command, $param ) = split( /\s+/, $body, 2 ); | ||
| 19 | $command = lc($command); | ||
| 20 | |||
| 21 | if ( $command eq "dns" ) { | ||
| 22 | my $addr = inet_aton($param); | ||
| 23 | my @addr = gethostbyaddr( $addr, AF_INET ); | ||
| 24 | return "$param is $addr[0]."; | ||
| 25 | } | ||
| 26 | elsif ( $command eq "nslookup" ) { | ||
| 27 | my @addr = gethostbyname($param); | ||
| 28 | my $straddr = inet_ntoa( $addr[4] ); | ||
| 29 | return "$param is $straddr."; | ||
| 30 | } | ||
| 31 | } | ||
| 32 | |||
| 33 | 1; | ||
| 34 | |||
| 35 | __END__ | ||
| 36 | |||
| 37 | =head1 NAME | ||
| 38 | |||
| 39 | Bot::BasicBot::Pluggable::Module::DNS - DNS lookups for hostnames or IP addresses | ||
| 40 | |||
| 41 | =head1 VERSION | ||
| 42 | |||
| 43 | version 1.11 | ||
| 44 | |||
| 45 | =head1 IRC USAGE | ||
| 46 | |||
| 47 | =over 4 | ||
| 48 | |||
| 49 | =item dns <ip address> | ||
| 50 | |||
| 51 | Returns the hostname of that IP address | ||
| 52 | |||
| 53 | =item nslookup <hostname> | ||
| 54 | |||
| 55 | Returns the IP address of the hostname. | ||
| 56 | |||
| 57 | =back | ||
| 58 | |||
| 59 | =head1 AUTHOR | ||
| 60 | |||
| 61 | Mario Domgoergen <mdom@cpan.org> | ||
| 62 | |||
| 63 | This program is free software; you can redistribute it | ||
| 64 | and/or modify it under the same terms as Perl itself. |