my $host = "$pnick.users.netgamers.org";
my ($username,$hostname,$p_nick) = $dbh->selectrow_array(q{
SELECT username, hostmask,pnick
-FROM users WHERE username ILIKE ? OR hostmask ILIKE ? OR pnick ILIKE ?
+FROM users WHERE username = $1 OR hostmask = $2 OR pnick = $3
},undef,$nick,$host,$pnick);
if (defined $username){
{
my ($self,$c,$msg) = @_;
- my ($nick, $flags) = $msg =~ /^(\S+) ((\+|-)?\w+)$/ or die 'ARGS';
+ my ($nick, $mode, $flags) = $msg =~ /^(\S+) (\+|-)?(\w+)$/ or die 'ARGS';
my $dbh = $c->model;
my $f = $dbh->prepare(q{SELECT uid,username FROM users WHERE username ILIKE ?});
my $user = $f->fetchrow_hashref;
if ($f->rows == 1){
my $update;
- if ($flags =~ /^(-)/){
+ if ($mode ~~ '-'){
$update = $dbh->prepare(q{
DELETE FROM groupmembers WHERE uid = $1 AND gid = ANY($2)
});
}
sub flag
- : Help(syntax: .flag flag | Lists all users with the given flag.)
+ : Help(syntax: .flag flag [-noflags] | Lists all users with the given flag. Can specify a second argument to remove members that has any of those flags. .flag M -C lists all members that doesn't have community flag)
: ACL(irc_flag)
{
my ($self,$c,$msg) = @_;
- my ($flag) = $msg =~ /^(\w)$/ or die 'ARGS';
+ my ($flag,$noflag) = $msg =~ /^(\w)(?: -(\w+))?$/ or die 'ARGS';
+ $noflag //= '';
my $f = $c->model->prepare(q{
SELECT array_to_string(array_agg(username),', '),count(username)
FROM (SELECT uid, username FROM users ORDER BY username) u
JOIN groupmembers gm USING (uid)
-WHERE gid = $1
+WHERE gid = $1 AND uid NOT IN (SELECT uid FROM groupmembers WHERE gid = ANY($2))
});
- my ($users,$count) = $c->model->selectrow_array($f,undef,$flag);
+ my @noflag = split //, $noflag;
+ my ($users,$count) = $c->model->selectrow_array($f,undef,$flag,\@noflag);
$c->reply("<b>$count</b> Users with flag <b>$flag</b>: $users");
}
if($@){
if ($@ =~ /duplicate key value violates unique constraint/){
my ($username, $hostname) = $dbh->selectrow_array(q{
-SELECT username,hostmask FROM users WHERE hostmask ILIKE $1
+SELECT username,hostmask FROM users WHERE hostmask = $1
},undef,$host);
$c->reply("<c04>Problem</c>, <b>$username</b> already uses host <b>$hostname</b>.");
}else{
if($@){
if ($@ =~ /duplicate key value violates unique constraint/){
my ($username, $hostname, $pnick) = $dbh->selectrow_array(q{
-SELECT username,hostmask,pnick FROM users WHERE hostmask ILIKE $1 OR pnick ILIKE $2
+SELECT username,hostmask,pnick FROM users WHERE hostmask = $1 OR pnick = $2
},undef,$hostname, $pnick);
$c->reply("<c04>Problem</c>, <b>$username</b> already uses host <b>$hostname</b> and pnick <b>$pnick</b>.");
}else{