iea has asked for the wisdom of the Perl Monks concerning the following question:

Hi, i am trying to use the irc:net modul. But i just dont know how to get the answer from my handle ?
use Net::IRC; $irc = new Net::IRC; $conn = $irc->newconn( Nick => 'BotRobotnnic', Server => 'irc.quakenet.org', Port => 6667, Ircname => 'Bot Robotnic'); $conn->add_global_handler('376', \&on_connect); $conn->add_handler('msg', \&on_msg); $irc->start; sub on_connect { my $self = shift; $self->join("#test"); $self->privmsg("#test", "Im boti"); } sub on_msg { my $self = shift; $self->privmsg("#test", "$WHAT DID HE WRITE"); }
I added the handler msg to react if someone writes an private msg. But i would like to know what he wrote ?
$conn->add_handler('msg', \&on_msg);
It doesnt return anything. Thank

Replies are listed 'Best First'.
Re: NET IRC
by moritz (Cardinal) on May 13, 2008 at 22:24 UTC
    sub on_msg { my ($self, $event) = @_; # $event contains all the interesting information, # for example $event->nick and $event->args $self->privmsg($event->nick, "You said " $event->args); }

    But you should note that Net::IRC doesn't seem to be actively maintained anymore (last version about 5 years old), nowadays most monks recommend POE::Component::IRC instead. If you want to write a simple bot, Bot::BasicBot really helps, it's much simpler to use.

      Thank ... great iŽll give it a try.