in reply to Re^2: A Quick OO Module for parsing lines from an IRC connection
in thread A Quick OO Module for parsing lines from an IRC connection

Something like this?

my $sock = IO::Socket::INET->new('localhost:6669'); print "pass this_is_the_passwd\n"; print $sock "pass this_is_the_pw\r"; print "nick whateverhack\n"; print $sock "nick whateverhack\r";

later on I always to stuff like this to parse messages people send (here p.e. all messages from hitty:

LOOP: while (<$sock>) { $line = $_; if ( $line =~ / 366 / ) { print "$line\r"; } if ( $line =~ /PRIVMSG/ ) { $line =~ /^:(.*)!(.*) PRIVMSG (.*) :(.*?)--(.*).$/; $from = $1; $room = $3; $cam = $4; if ($cam eq "") { next LOOP; } $comment = $5; if ( $cam =~ /hitty/ ) { print "<$from\@$cam> $comment\n"; } } }

Replies are listed 'Best First'.
Re^4: A Quick OO Module for parsing lines from an IRC connection
by SoupNazi (Acolyte) on Aug 26, 2005 at 20:40 UTC

    ...thats interesting yes, something exactly like that. On the server I frequent, NickServe likes for you to auth a certain way and it is peculiar, if you were in an irc client, you'd type:

    /msg nickserv@services.crazylogic.org AUTH yourpassword

    Getting the bot to send that message (as a raw irc message) at the proper time, man ... I'll tell you, it was frustrating.

    Your parser interests me, too. I especially like the:

    $line =~ /^:(.*)!(.*) PRIVMSG (.*) :(.*?)--(.*).$/;

    Because occasionally NOTICES and other such things get sent out, and the parser I wrote will do it's thing on those as best it can but I still get "Uninitialized value ... " warnings when it happens sometimes. I could use that, and build it into the parse_line() method, to check whether it is a PRIVMSG type line, or a NOTICE or something else and then have the method parse the line accordingly.

    ...if that makes any sense (I've been at work all day & I'm tired :))

    Thank you, I think I'll work on that this weekend.

    Regards
    SoupNazi

    Visit us at irc.crazylogic.org #apartment411
    D A R K E M P I R E s u b n e t w o r k