Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

using Net::IRC for actions

by Anonymous Monk
on May 03, 2005 at 00:25 UTC ( #453451=perlquestion: print w/replies, xml ) Need Help??

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

Anyone out there familiar with Net::IRC and familiar know your away around IRC/MIRC? My question is, I want my bot to do a specific action when the bot is slapped (ie: /me slaps Wizard). I'm sure my regex is fine but I think the reason it's not reading in the action is because it's not being read as "on_public" text..

Everything else in the on_public is working, just not the actions.

sub on_public { my ($conn, $event) = @_; my $nick = $event->{nick}; . . . elsif ($text =~ m/slaps Wizard/i) { $conn->privmsg($conn->{channel}, "Hey, don't slap me!"); } . . . }
I tried looking on Google but it doesn't say anything about reading user actions. Any ideas?

Replies are listed 'Best First'.
Re: using Net::IRC for actions
by friedo (Prior) on May 03, 2005 at 01:12 UTC
    Actions are actually not part of the IRC protocol, but are CTCP events. Thus they aren't handled by your on_public handler. Instead, set a handler for the caction event. For more, see the docs for Net::IRC::Event.
Re: using Net::IRC for actions
by eibwen (Friar) on May 03, 2005 at 00:28 UTC
      Sorry, do you mean elsif ($text =~ m/\001slaps\001/i)? I tried that as the regex and it didn't change anything.

        No, that's wrong. According to the CTCP Specification, correct is:

        $text =~ m/^\001ACTION slaps Wizard\001$/

        --Ingo

Re: using Net::IRC for actions
by Steve_p (Priest) on May 03, 2005 at 13:28 UTC

    For a simple bot like this, I'd suggest looking into Bot::BasicBot.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://453451]
Approved by sulfericacid
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2020-07-09 19:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?