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

Sorry for asking yet another question but this is pretty much the same as before as the additions aren't working.

I have an Perl IRC but using Net::IRC. It runs via the command line and it hits an infinite loop when it reaches $irc->start;. I know this from the docs but the thing I need to do is get the script to prompt for commands continuously while it's LIVE. I tried using a do_once_loop but with no documentation examples on it, I have no idea what to do. And by using this loop, my bot never logged back in. So can someone show me the proper way to have the script loop and ask for commands through the command-line while the bot is live?

The second one is being able to read user-actions when they type /me does something. No documentation examples on this either so can someone show a snippet on how I would detect a user-action AND have the bot be able do do actions itself? prvmsg does NOT work with commands, it prints as text.

I've been on this for days now and I can't for the life of me get any sample code of what I need. I would appreciate ANYTHING you have to offer.

Replies are listed 'Best First'.
Re: more problems with an IRC bot
by strat (Canon) on May 05, 2005 at 09:43 UTC

    Btw: if you download Net::IRC from CPAN, the tar.gz contains a script called irctest. This script contains a lot of information about Net::IRC

    Best regards,
    perl -e "s>>*F>e=>y)\*martinF)stronat)=>print,print v8.8.8.32.11.32"

Re: more problems with an IRC bot
by eibwen (Friar) on May 05, 2005 at 05:55 UTC

    I've never used Net::IRC, but from the POD and your description it sounds like it invokes an event handler. It would appear that you'd have to create an on_event sub to suit your purposes. Alternatively, you can implement your bot in IO::Socket::INET, which makes this problem trivial.

    User actions have \001 prefixed and appended to the action-text.

    UPDATE: Net::IRC includes the addfh() method, which if you can use to add the new() socket, you can also register your own callback sub. Alternatively, you can use the add_handler() or add_global_handler() methods -- the documentation is particularly sparse, but it appears that it only responds to IRC server responses as defined by the RFCs.

Re: more problems with an IRC bot
by gellyfish (Monsignor) on May 05, 2005 at 08:21 UTC

    Might I suggest that instead of Net::IRC you might consider Bot::BasicBot or POE::Component::IRC ? Catching CTCP "actions" in the former is simply a matter of over-riding the default emoted subroutine in a sub-class and in the latter providing a handler for the irc_ctcp_action event.

    /J\