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

I'm writing an IRC bot (a useful one not an annoying one) using the Net::IRC module (version 0.75). I've been through the docs and the source code and I can't seem to get the module to notify me of changes in the client's mode (whether from myself or someone else). Here's the code I have right now:
sub on_umode { my ($self, $event) = @_; print "got umode\n"; # print "umode args = " . $event->args . "\n"; } ... $conn->add_handler('umode', \&on_umode);
This handler never gets called. This is the only handler I'm having trouble with. I tried having the client change it's own mode and having my normal IRC user change its mode, and I get absolutely nothing. That function is never called. Does anyone know what I'm doing wrong?

Replies are listed 'Best First'.
Re: getting client mode with Net::IRC
by Mr. Muskrat (Canon) on Dec 31, 2004 at 16:44 UTC

    User mode changes will only be made by the client. Some valid user modes are invisible (i), receive server messages (s) and recieve wallops (w). How have you been testing it?

      Since I haven't written a command for mode changes, I put in the following at the top of my handler for channel text.
      $conn->mode($mynick, "+i"); $conn->mode($mynick, "-i");
      I also tried:
      $conn->mode($channel, "+i", $mynick); $conn->mode($channel, "-i", $mynick);
      My on_umode handler never gets called. The docs aren't too clear on how to do user mode changes instead of channel mode changes. If user mode changes can only be made by the client, how do I know when someone else changes my mode (+o, for example)?

        +o is not a user mode change but it is a mode change that triggers the mode handler if you have one.

Re: getting client mode with Net::IRC
by halley (Prior) on Jan 04, 2005 at 20:25 UTC
    I think you got your answer, but in terms of clarification, there are two sets of modes: user UMODE and channel MODE flags.

    A client submits UMODE commands (or the server may assert UMODE changes) to adjust your client's relationship to the server or the network as a whole. These are typically not seen or manipulated by other clients at all, though server operators and ircd services like nickserv may have special abilities. User UMODE changes include things like invisibility from general queries, powers over service administration, flagging valid registered nicknames, etc.

    Any client submits MODE commands only relative to a specific channel. The *other* participants in those channels will get a chance to witness the MODE adjustment; some servers assume that your client is smart enough to monitor the mode changes you submit on your own.

    These MODE changes (like +o for chanops) are really referring to the state of the channel itself, not a part of your connection, and they just contain a reference to your nick or mask.

    --
    [ e d @ h a l l e y . c c ]

      Thanks, that does clarify things a bit. The Net::IRC docs don't make this distinction clear, although they may just expect you to already know this.