X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=Commands%2FChannel.pm;fp=Commands%2FChannel.pm;h=c1a5f7b5f405a864f0acb1d961f5faae22d14590;hb=7091b004eee879d36792d6da3b8fd4fb1b5f71bf;hp=0000000000000000000000000000000000000000;hpb=21cb796be35d56fc6620af557355ab57b6c00e88;p=NDIRC.git diff --git a/Commands/Channel.pm b/Commands/Channel.pm new file mode 100644 index 0000000..c1a5f7b --- /dev/null +++ b/Commands/Channel.pm @@ -0,0 +1,64 @@ +#************************************************************************** +# Copyright (C) 2008 by Michael Andreen * +# * +# This program is free software; you can redistribute it and/or modify * +# it under the terms of the GNU General Public License as published by * +# the Free Software Foundation; either version 2 of the License, or * +# (at your option) any later version. * +# * +# This program is distributed in the hope that it will be useful, * +# but WITHOUT ANY WARRANTY; without even the implied warranty of * +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +# GNU General Public License for more details. * +# * +# You should have received a copy of the GNU General Public License * +# along with this program; if not, write to the * +# Free Software Foundation, Inc., * +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * +#**************************************************************************/ + +package NDIRC::Commands::Channel; + +use strict; +use warnings; +use feature ':5.10'; + +use Moose; +use MooseX::MethodAttributes; + +sub op + : Alias(qw/deop voice devoice/) + : Help(syntax: .op [nicks] | Gives op to the specified nicks, or yourself if no command is given) + : Type(channel) +{ + my ($self,$c,$msg) = @_; + + my ($access) = $self->name =~ /(op|voice)/; + + my $where = ""; + if ($msg =~ /^\s*$/){ + $msg = $c->nick; + $where = "OR f.name = 'auto_$access'"; + } + + my $mode = qq{ +SELECT DISTINCT c.name FROM users u + JOIN groupmembers g ON g.uid = u.uid + JOIN channel_group_flags gf ON g.gid = gf.group + JOIN channels c ON gf.channel = c.id + JOIN channel_flags f ON f.id = gf.flag +WHERE u.hostmask ILIKE ? AND c.name = ? AND (f.name = '$access' $where); + }; + if ($c->check_user_roles(qw/irc_masterop/)){ + $mode = 1; + }else{ + ($mode) = $c->model->selectrow_array($mode,undef,$c->host,$c->channel); + } + if ($mode){ + $c->server->command($self->name . " " . $c->channel . " $msg"); + }else{ + $c->reply("No access to " . $self->name . " in this channel"); + } +} + +1;