Re: Net::IRC Auto-OP
by jZed (Prior) on Jun 03, 2007 at 18:06 UTC
|
You've told us more about what we shouldn't tell you then about what we should :-). For example, you didn't tell us what happens when you try what you've shown - is there an error message? nothing? somtehing unexpected? I assume you've tried printing out $comm->{channel} and $nick just before send $conn->privmsg() and they hold what you expect? | [reply] |
Re: Net::IRC Auto-OP
by betterworld (Curate) on Jun 03, 2007 at 19:27 UTC
|
...it sends a private message to Chanserv telling it to op the user
If you have chanserv available, there are easier methods to automatically op users. See chanserv's "level" or "levels" command.
| [reply] |
|
I don't want to use the levels command. After viewing the help page, I learned that it involves changing the level of the user I want to be auto oped. I don't want to do that. I want to leave their level as is, and just send a command to op them.
As for the output, there is none. No error in the terminal, no getting kicked out of irc, no crash, nothing. The user just doesn't get OPed.
| [reply] |
|
Does your bot handle incoming private messages? Chanserv may be replying to you with a useful error message.
| [reply] |
|
Re: Net::IRC Auto-OP
by kunwon1 (Sexton) on Jun 03, 2007 at 20:50 UTC
|
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. | [reply] |
|
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. | [reply] [d/l] |
|
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 ) {
...
}
| [reply] [d/l] [select] |
|
|
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?
| [reply] [d/l] |
|
|
|