From: Michael Andreen Date: Thu, 27 Aug 2009 17:55:22 +0000 (+0200) Subject: Make it possible to remove members of specified groups from .flag listing X-Git-Url: https://ruin.nu/git/?p=NDIRC.git;a=commitdiff_plain;h=10707d9620d6beadaaa0faf0fe3c2ad28013175d;hp=37431c7bcaf19447eb076dd5fc840b94df20263c Make it possible to remove members of specified groups from .flag listing --- diff --git a/Commands/Usermgm.pm b/Commands/Usermgm.pm index 74bb7eb..cf5b853 100644 --- a/Commands/Usermgm.pm +++ b/Commands/Usermgm.pm @@ -164,19 +164,21 @@ GROUP BY username,pnick,hostmask LIMIT 5 } 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("$count Users with flag $flag: $users"); }