From 1172d7b2620ef52ab89a683f4a73696616e680a5 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Fri, 3 Nov 2017 12:28:41 -0700 Subject: [PATCH] Ensure admins actually have rights in $channel to use $command --- PBot/ChanOpCommands.pm | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/PBot/ChanOpCommands.pm b/PBot/ChanOpCommands.pm index 64b08209..aa1569c5 100644 --- a/PBot/ChanOpCommands.pm +++ b/PBot/ChanOpCommands.pm @@ -82,6 +82,10 @@ sub ban_user { my $botnick = $self->{pbot}->{registry}->get_value('irc', 'botnick'); return "I don't think so." if $target =~ /^\Q$botnick\E!/i; + if (not $self->{pbot}->{admins}->loggedin($channel, "$nick!$user\@$host")) { + return "/msg $nick You are not an admin for $channel."; + } + $self->{pbot}->{chanops}->ban_user_timed($target, $channel, $length); if ($length > 0) { @@ -112,6 +116,10 @@ sub unban_user { return "/msg $nick Usage for /msg: unban " if $channel !~ /^#/; + if (not $self->{pbot}->{admins}->loggedin($channel, "$nick!$user\@$host")) { + return "/msg $nick You are not an admin for $channel."; + } + $self->{pbot}->{chanops}->unban_user($target, $channel, 1); return "/msg $nick $target has been unbanned from $channel."; } @@ -157,6 +165,10 @@ sub mute_user { my $botnick = $self->{pbot}->{registry}->get_value('irc', 'botnick'); return "I don't think so." if $target =~ /^\Q$botnick\E!/i; + if (not $self->{pbot}->{admins}->loggedin($channel, "$nick!$user\@$host")) { + return "/msg $nick You are not an admin for $channel."; + } + $self->{pbot}->{chanops}->mute_user_timed($target, $channel, $length); if ($length > 0) { @@ -187,6 +199,10 @@ sub unmute_user { return "/msg $nick Usage for /msg: unmute " if $channel !~ /^#/; + if (not $self->{pbot}->{admins}->loggedin($channel, "$nick!$user\@$host")) { + return "/msg $nick You are not an admin for $channel."; + } + $self->{pbot}->{chanops}->unmute_user($target, $channel, 1); return "/msg $nick $target has been unmuted in $channel."; } @@ -230,6 +246,10 @@ sub kick_user { } } + if (not $self->{pbot}->{admins}->loggedin($channel, "$nick!$user\@$host")) { + return "/msg $nick You are not an admin for $channel."; + } + $self->{pbot}->{chanops}->add_op_command($channel, "kick $channel $victim $reason"); $self->{pbot}->{chanops}->gain_ops($channel); return "";