-sub addUser {
- my ($msg, $command) = @_;
-
- my ($nick,$pnick);
- if(defined $msg && $msg =~ /^(\w+)(?: ([^.\s]+))?$/){
- $nick = $1;
- $pnick = $2;
- }else{
- $ND::server->command("notice $ND::nick syntax: .$command nick [pnick] | nick must be alphanum characters, if no pnick is given then it will be set to nick");
- return;
- }
- if (hc()){
- $pnick = $nick unless $pnick;
- my $host = "$pnick.users.netgamers.org";
- my ($username,$hostname,$p_nick) = $ND::DBH->selectrow_array(q{SELECT username, hostmask,pnick
- FROM users WHERE username ILIKE ? OR hostmask ILIKE ? OR pnick ILIKE ?}
- ,undef,$nick,$host,$pnick);
- if ((not defined $username) && $ND::DBH->do("INSERT INTO users (username,hostmask,pnick,password) VALUES(?,?,?,'')"
- ,undef,$nick,$host,$pnick)){
- $ND::server->command("msg $ND::target Added $ND::B$nick(/$pnick)$ND::B with host: $ND::B$host$ND::B");
- }elsif(defined $username){
- $ND::server->command("msg $ND::target $ND::B$username ($p_nick)$ND::B already exists with host: $ND::B$hostname$ND::B.");
-
- }else{
- $ND::server->command("msg $ND::target Something went wrong when trying to add $ND::B$nick ($pnick)$ND::B with host: $ND::B$host$ND::B, ".$ND::DBH->errstr);
- }
- }else{
- $ND::server->command("msg $ND::target Only HCs are allowed to add users");
- }
-}