Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Net::IRC Auto-OP

by kunwon1 (Sexton)
on Jun 03, 2007 at 20:50 UTC ( [id://618998]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://618998]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2024-04-25 20:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found