X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=Commands%2FChannel.pm;h=3907a89547fe73b8307d723410f8e002233ffe24;hb=84f84122d6e27123f026630ad1fa78e0f00520ac;hp=d309ce00ae1ac4e533f08f66f90101db2fe28159;hpb=1ccb344994c1b517c662da9f236cf1c640780177;p=NDIRC.git diff --git a/Commands/Channel.pm b/Commands/Channel.pm index d309ce0..3907a89 100644 --- a/Commands/Channel.pm +++ b/Commands/Channel.pm @@ -33,8 +33,9 @@ sub op { my ($self,$c,$msg) = @_; - $self->name =~ /(op|voice)/; - my @access = ($1); + $self->name =~ /(de)?(op|voice)/; + my @access = ($2); + my $mod = $1 ? '-' : ''; if ($msg =~ /^\s*$/){ $msg = $c->nick; @@ -42,19 +43,19 @@ sub op } my $mode = q{ -SELECT DISTINCT channel FROM users u +SELECT DISTINCT LOWER(flag) FROM users u JOIN groupmembers g USING (uid) JOIN channel_group_flags gf USING (gid) JOIN channel_flags f USING (flag) -WHERE u.hostmask ILIKE $1 AND channel = $2 AND f.name = ANY($3); +WHERE uid = $1 AND channel = $2 AND f.name = ANY($3); }; if ($c->check_user_roles(qw/irc_masterop/)){ - $mode = 1; + $mode = substr $access[0], 0,1; }else{ - ($mode) = $c->model->selectrow_array($mode,undef,$c->host,$c->channel,\@access); + ($mode) = $c->model->selectrow_array($mode,undef,$c->uid,$c->channel,\@access); } if ($mode){ - $c->server->command($self->name . " " . $c->channel . " $msg"); + $c->command(mode => $c->channel, "$mod$mode", $msg); }else{ $c->reply("No access to " . $self->name . " in this channel"); } @@ -72,23 +73,22 @@ sub invite if ($channel && $c->check_user_roles('irc_masterinvite')){ push @channels,$channel; }else{ - my @access = ('auto_invite'); - push @access, 'invite' if $channel; + my @access = ('i'); + push @access, 'I' if $channel; my $channels = $c->model->prepare(q{ SELECT DISTINCT channel FROM users u JOIN groupmembers g USING (uid) JOIN channel_group_flags gf USING (gid) - JOIN channel_flags f USING (flag) -WHERE u.hostmask ILIKE $1 AND COALESCE(channel = $2,TRUE) - AND (f.name = ANY($3) ) +WHERE uid = $1 AND COALESCE(channel = $2,TRUE) + AND (flag = ANY($3) ) }); - $channels->execute($c->host,$channel,\@access); + $channels->execute($c->uid,$channel,\@access); while (my ($channel) = $channels->fetchrow()){ push @channels,$channel; } } for (@channels){ - $c->server->command("invite ". $c->nick ." $_"); + $c->command(invite => $c->nick, $_); } } @@ -130,8 +130,8 @@ sub getpass my $password = generate_random_string 10; my $update = $dbh->do(q{ UPDATE users SET password = MD5( ? ) -WHERE hostmask ILIKE ? AND password ='' - },undef,$password,$c->host); +WHERE uid = ? AND password ='' + },undef,$password,$c->uid); if ($update > 0){ $c->reply("Password set to: $password (you can change it on webbie)"); }else{