Unix and Linux Discussions Tagged with irc |
|
Thread / Thread Starter |
Last Post |
Replies |
Views |
Forum |
|
|
|
2 |
3,208 |
UNIX for Beginners Questions & Answers |
|
|
|
12 |
2,779 |
UNIX for Advanced & Expert Users |
|
|
|
2 |
3,502 |
UNIX for Dummies Questions & Answers |
|
|
|
1 |
1,874 |
Solaris |
|
|
|
0 |
9,759 |
News, Links, Events and Announcements |
|
|
|
2 |
2,871 |
Web Development |
|
|
|
0 |
4,494 |
UNIX for Dummies Questions & Answers |
|
|
|
0 |
614 |
Software Releases - RSS News |
|
|
|
0 |
800 |
Software Releases - RSS News |
|
|
|
0 |
848 |
Software Releases - RSS News |
|
|
|
0 |
709 |
Software Releases - RSS News |
|
|
|
0 |
880 |
Software Releases - RSS News |
|
|
|
0 |
939 |
Software Releases - RSS News |
|
|
|
10 |
10,302 |
Shell Programming and Scripting |
|
|
|
0 |
882 |
Software Releases - RSS News |
|
|
|
1 |
5,577 |
UNIX for Advanced & Expert Users |
|
|
|
1 |
2,712 |
UNIX for Dummies Questions & Answers |
|
|
|
2 |
4,501 |
UNIX for Dummies Questions & Answers |
POE::Component::IRC::Cookbook::Resolver(3pm) User Contributed Perl Documentation POE::Component::IRC::Cookbook::Resolver(3pm)
NAME
POE::Component::IRC::Cookbook::Resolver - A bot that can resolve DNS records
SYNOPSIS
This bot uses POE::Component::Client::DNS to DNS records for channel members.
DESCRIPTION
#!/usr/bin/env perl
use strict;
use warnings;
use IRC::Utils qw(parse_user);
use POE;
use POE::Component::Client::DNS;
use POE::Component::IRC::State;
use POE::Component::IRC::Plugin::AutoJoin;
use POE::Component::IRC::Plugin::BotCommand;
POE::Session->create(
package_states => [
main => [ qw(_start irc_botcmd_resolve dns_response) ]
],
);
$poe_kernel->run();
sub _start {
my $heap = $_[HEAP];
my $irc = POE::Component::IRC::State->spawn(
Nick => 'resolver_bot',
Server => 'irc.freenode.net',
);
$heap->{irc} = $irc;
$irc->plugin_add('AutoJoin', POE::Component::IRC::Plugin::AutoJoin->new(
Channels => [ '#test_channel1', '#test_channel2' ]
));
$irc->plugin_add('BotCommand', POE::Component::IRC::Plugin::BotCommand->new(
Commands => {
resolve => 'Usage: resolve <host>'
}
));
$heap->{dns} = POE::Component::Client::DNS->spawn();
$irc->yield(register => 'botcmd_resolve');
$irc->yield('connect');
return;
}
sub irc_botcmd_resolve {
my $dns = $_[HEAP]->{dns};
my $nick = parse_user( $_[ARG0] );
my ($channel, $host) = @_[ARG1, ARG2];
my $res = $dns->resolve(
event => 'dns_response',
host => $host,
context => {
channel => $channel,
nick => $nick,
},
);
$poe_kernel->yield(dns_response => $res) if $res;
return;
}
sub dns_response {
my $irc = $_[HEAP]->{irc};
my $res = $_[ARG0];
my @answers = $res->{response}
? map { $_->rdatastr } $res->{response}->answer()
: ();
$irc->yield(
'privmsg',
$res->{context}->{channel},
$res->{context}->{nick} . (@answers
? ": @answers"
: ': no answers for "' . $res->{host} . '"')
);
return;
}
AUTHOR
Hinrik Oern Sigur`sson, hinrik.sig@gmail.com
perl v5.14.2 2011-12-07 POE::Component::IRC::Cookbook::Resolver(3pm)