in reply to Net::IRC Auto-OP

There are a lot of subtle security holes in what you're doing. You really should (re)consider using chanserv, it's almost always the best choice.

Are you using strict and using warnings? If not, that should be your first step. As suggested above, you should check the value of $conn->{channel} and $nick before proceeding, and at least add a generic handler for unhandled events, maybe to redirect them to stderr, if you don't already have one.

If you post more code this will be a lot easier to troubleshoot, at least the whole on_join subroutine.

Replies are listed 'Best First'.
Re^2: Net::IRC Auto-OP
by Cheater (Novice) on Jun 03, 2007 at 21:08 UTC
    I've checked for private messages from Chanserv. There aren't any.

    I've checked the value of $conn->{channel} and $nick using print statements. They are set to the correct values. Here is the on_join sub:
    sub on_join { my ($conn, $event) = @_; my $nick = $event->{nick}; if ($nick eq ("xxx" || "yyy")) { $conn->privmsg("Chanserv", "OP $conn->{channel} $nick"); print "Auto-Op $nick\n"; $conn->privmsg($nick, "You have been Auto-Oped by $mynick"); $conn->me($conn->{channel}, "Auto-Ops $nick"); } $conn->privmsg($conn->{channel}, "Welcome, $nick!") unless ($ni +ck eq $mynick); print "[$mynick] Welcome, $nick!\n" unless ($nick eq $mynick); }
    $mynick is equal to the bot's nick.
    xxx and yyy are the nicks of the users to be OPed.
      This:
      if ($nick eq ("xxx" || "yyy"))
      doesn't make sense. You're checking $nick for string-equality with the logical-ORed value of "xxx" and "yyy" which is just going to be "xxx". What you probably meant was
      if ( $nick eq "xxx" or $nick eq "yyy" )
      If you have a bigger list of nicks you can use a hash, which is a lot easier than constructing a gigantic conditional.
      my %ops = ( xxx => 1, yyy => 1, zzz => 1 ); if ( $ops{$nick} == 1 ) { ... }
        Even fixing the or statement (I'll swith to a hash when I get a bigger list), it still won't op the users.
      Does this
      print "Auto-Op $nick\n";
      print statement print? If not, you're not getting into the if block.

      And again, are you using strict and warnings pragmas?
        It prints. All the other commands in the if statement are also executed.