+#**************************************************************************
+# Copyright (C) 2009 by Michael Andreen <harvATruinDOTnu> *
+# *
+# 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::Usermgm;
+
+use strict;
+use warnings;
+use feature ':5.10';
+
+use Moose;
+use MooseX::MethodAttributes;
+
+sub adduser
+ : Help(syntax: .+user username [pnick] | username must be alphanum characters, if no pnick is given then it will be set to the same as username)
+ : Alias(+user)
+ : ACL(irc_adduser)
+{
+ my ($self,$c,$msg) = @_;
+ my ($nick,$pnick) = $msg =~ /^(\w+)(?: ([^.\s]+))?$/ or die 'ARGS';
+ $pnick //= $nick;
+
+ my $dbh = $c->model;
+
+ 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 ?
+ },undef,$nick,$host,$pnick);
+
+ if (defined $username){
+ $c->reply("<b>$username ($p_nick)</b> already exists with host: <b>$hostname</b>");
+ }else{
+ $dbh->do(q{
+INSERT INTO users (username,hostmask,pnick,password) VALUES(?,?,?,'')
+ },undef,$nick,$host,$pnick);
+ $c->reply("Added <b>$nick(/$pnick)</b> with host: <b>$host</b>");
+ }
+}
+
+1;