POE::C...esolver(3pm)

πŸ“¦
version 6.95 Β· 4 versions
, in ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

POE::Component::IRC::Cookbook::Resolver β€” it's a bot that can resolve DNS records πŸ’…

(also hi, this is a 3pm manual page out of the User Contributed Perl Documentation, so you know it's giving cookbook realness πŸ“)


✨ SYNOPSIS ✨

Bestie, the whole point: this bot uses POE::Component::Client::DNS to look up DNS records for the members of a channel. That's the vibe. No cap. πŸ¦‹


πŸŽ€ DESCRIPTION πŸŽ€

Okay so here's the entire bot, top to bottom, not one line skipped, not one line summarised. Copy-paste her and she works πŸ‘‘

#!/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 { $_->rdstring } $res->{response}->answer()
        : ();

    $irc->yield(
        'privmsg',
        $res->{context}->{channel},
        $res->{context}->{nick} . (@answers
            ? ": @answers"
            : ': no answers for "' . $res->{host} . '"')
    );

    return;
}

That's her 🫢 literally the entire thing. it's giving main character energy and we're obsessed.


🌸 AUTHOR 🌸

Hinrik Γ–rn SigurΓ°sson, hinrik.sig@gmail.com β€” oh he ate that πŸ’œ


and that's a wrap babe ✨ this page walked so you could run β€” it was served up as perl v5.40.1, dated 2025-08-21, and it lives under the POE::C...esolver(3pm) name in the User Contributed Perl Documentation πŸ’– bye bestie, go look up some records 🌈

πŸ“¦ where this page comes from