View Single Post
Old Jun 5th, 2006, 9:32 AM   #2
Pizentios
Programming Guru
 
Pizentios's Avatar
 
Join Date: May 2004
Location: Brandon, Manitoba, Canada
Posts: 2,023
Rep Power: 7 Pizentios is on a distinguished road
Send a message via ICQ to Pizentios Send a message via MSN to Pizentios
if you were to use Net::IRC, you can add event handlers. All you'd need to do is create a handler to handle public events (the events that happen in the room window). Something like this:

#!/usr/bin/env perl
use Net::IRC;

my $irc = new Net::IRC; 
my $conn = $irc->newconn(Server	=> 'irc.freenode.org', Port => '6667', Nick => 'Chuck-Norris', Ircname => 'Yo-Momma!');

sub on_public {
	my ($conn, $event)= @_;
       	my $text = $event->{args}[0]; #what the person said.
        my $nick = $event->{nick}; #the person's nick name.
        if ($text =~ m/\!server/)
        {
                 #then you would grab the text you wanted from $text here and save it.
        }
}

$conn->add_handler('public', \&on_public);

$irc->start;

Ofcourse the code above will connect to irc.freenode.org, but it will not join a room, for that you need to setup a on_connect handler, then send a join command.

You could grab the text you wanted a few different ways. you could use the function substr if you know the total length of the string you are working with (which can be obtained from the function length()). Also i am sure there is a way to get the text you need form the string using a regular expression. It's all really up to you and what your comfortable with.
__________________
Profanity is the one language that all programmers understand.

Check out my Blog <---updated Nov 30 2007!
Pizentios is offline   Reply With Quote