--- /dev/null
+#**************************************************************************
+# 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;
our @ISA = qw/Exporter/;
-our @EXPORT = qw/addUser whois flags flag laston addPoints chattrG setHost setPNick deactivateUser getShips getFleet/;
+our @EXPORT = qw/whois flags flag laston addPoints chattrG setHost setPNick deactivateUser getShips getFleet/;
-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");
- }
-}
sub whois {
my ($msg, $command) = @_;
INSERT INTO roles VALUES('irc_delquote');
INSERT INTO roles VALUES('irc_points_others');
INSERT INTO roles VALUES('irc_sms');
+INSERT INTO roles VALUES('irc_adduser');
INSERT INTO group_roles (gid,role) VALUES(1,'irc_p_nick');
INSERT INTO group_roles (gid,role) VALUES(1,'irc_p_intel');
INSERT INTO group_roles (gid,role) VALUES(1,'irc_delquote');
INSERT INTO group_roles (gid,role) VALUES(1,'irc_points_others');
INSERT INTO group_roles (gid,role) VALUES(1,'irc_sms');
+INSERT INTO group_roles (gid,role) VALUES(1,'irc_adduser');
INSERT INTO group_roles (gid,role) VALUES(2,'irc_gs');
INSERT INTO group_roles (gid,role) VALUES(2,'irc_scan');
INSERT INTO group_roles (gid,role) VALUES(3,'irc_delquote');
INSERT INTO group_roles (gid,role) VALUES(3,'irc_points_others');
INSERT INTO group_roles (gid,role) VALUES(3,'irc_sms');
+INSERT INTO group_roles (gid,role) VALUES(3,'irc_adduser');
INSERT INTO group_roles (gid,role) VALUES(4,'irc_points_others');
my $disp = new NDIRC::Dispatcher;
-$disp->load('Basic','PA','Channel','Scans','Quotes','Members');
+$disp->load('Basic','PA','Channel','Scans','Quotes','Members','Usermgm');
$ND::scanchan = '#testarmer';
$disp->add_channel('#testarlite', ['pub','help','channel']);