}
}
+sub deactivateuser
+ : Help(syntax: .-user nick | nick must be alphanum characters, if no pnick is given then it will be set to nick)
+ : Alias(-user)
+ : ACL(irc_deactivateuser)
+{
+ my ($self,$c,$msg) = @_;
+
+ my ($nick) = $msg =~ /^(\S+)$/ or die 'ARGS';
+
+ my $dbh = $c->model;
+ my $f = $dbh->prepare(q{SELECT uid,username FROM users WHERE username ILIKE ?});
+ $f->execute($nick);
+ my ($uid,$username) = $f->fetchrow();
+
+ if ($f->rows == 1){
+ my $updated = $dbh->do(q{
+UPDATE users SET hostmask = ?, password = '' WHERE uid = ?
+ },undef,$username,$uid);
+ if ($updated > 0){
+ my $groups = $dbh->do(q{DELETE FROM groupmembers WHERE uid = ?},undef,$uid);
+ $groups += 0;
+ $c->reply("<b>$username</b> has been deactivated. Removed from $groups groups.");
+ }else{
+ $c->reply("Something went wrong when trying to modify <b>$username</b>");
+ }
+ }elsif ($f->rows == 0){
+ $c->reply("No hit, maybe spelling mistake, or add % as wildcard");
+ }else{
+ $c->reply("More than 1 user matched, please refine the search");
+ }
+ $f->finish;
+}
+
1;