$f->finish;
}
+sub a
+ : Help(Usage: .a username [points] | % can be used for wildcards \%arro\% will match barrow, if the number of points isn't specified, then 1 will be assumed.)
+ : ACL(irc_a)
+{
+ my ($self,$c,$msg) = @_;
+ my ($nick,$points) = $msg =~ /^(\S+)(?: (-?(\d+)?(\.\d+)?))?$/ or die 'ARGS';
+ $points //= 1;
+
+ my ($fleets) = $c->model->selectrow_array(q{
+SELECT count(*) FROM raids r
+ JOIN raid_targets rt ON r.id = rt.raid
+ JOIN raid_claims rc ON rt.id = rc.target
+WHERE not launched AND tick + 24 > tick()
+ AND uid = (SELECT uid FROM users WHERE username ILIKE $1);
+ },undef,$nick);
+
+ if ($fleets > 0 && $points > 0){
+ $c->reply("$nick has $fleets claimed waves the last 24 ticks that aren't marked as launched, so no points.");
+ return;
+ }
+ addPoints($c, 'attack', $nick, $points);
+}
+
+sub d
+ : Help(Usage: .d username [points] | % can be used for wildcards \%arro\% will match barrow, if the number of points isn't specified, then 1 will be assumed.)
+ : ACL(irc_d)
+ : Type(def)
+{
+ my ($self,$c,$msg) = @_;
+ my ($nick,$points) = $msg =~ /^(\S+)(?: (-?(\d+)?(\.\d+)?))?$/ or die 'ARGS';
+
+ addPoints($c, 'defense', $nick, $points);
+}
+
+sub s
+ : Help(Usage: .s username [points] | % can be used for wildcards \%arro\% will match barrow, if the number of points isn't specified, then 1 will be assumed.)
+ : ACL(irc_s)
+{
+ my ($self,$c,$msg) = @_;
+ my ($nick,$points) = $msg =~ /^(\S+)(?: (-?(\d+)?(\.\d+)?))?$/ or die 'ARGS';
+
+ addPoints($c, 'scan', $nick, $points);
+}
+
+sub h
+ : Help(Usage: .h username [points] | % can be used for wildcards \%arro\% will match barrow, if the number of points isn't specified, then 1 will be assumed.)
+ : ACL(irc_h)
+{
+ my ($self,$c,$msg) = @_;
+ my ($nick,$points) = $msg =~ /^(\S+)(?: (-?(\d+)?(\.\d+)?))?$/ or die 'ARGS';
+
+ addPoints($c, 'humor', $nick, $points);
+}
+
+sub addPoints {
+ my ($c,$type, $nick, $points) = @_;
+ $points //= 1;
+
+ my $dbh = $c->model;
+
+ if ($points*$points > 400){
+ $c->reply("Values between -20 and 20 please");
+ return;
+ }
+
+ my $f = $dbh->prepare(q{SELECT uid,username FROM users WHERE username ILIKE ?});
+ $f->execute($nick);
+ my $user = $f->fetchrow_hashref;
+ if ($f->rows == 1){
+ $type .= "_points";
+ $dbh->do(qq{UPDATE users SET $type = $type + ? WHERE uid = ?}
+ ,undef,$points,$user->{uid});
+ $c->reply("$user->{username} has been given $points $type");
+ }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;
+++ /dev/null
-#**************************************************************************
-# Copyright (C) 2006 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::Usermgm;
-use strict;
-use warnings;
-use ND::DB;
-use NDIRC::Access;
-require Exporter;
-
-our @ISA = qw/Exporter/;
-
-our @EXPORT = qw/addPoints/;
-
-sub addPoints {
- my ($msg, $t) = @_;
-
- my ($nick, $points);
- if(defined $msg && $msg =~ /^(\S+)(?: (-?(\d+)?(\.\d+)?))?$/){
- $nick = $1;
- $points = $2;
- }else{
- $ND::server->command("notice $ND::nick syntax: .$t nick [points] | % can be used for wildcards \%arro\% will match barrow, if the number of points isn't specified, then 1 will be assumed.");
- return;
- }
- if ( ($t eq "d" && dc())
- || ($t eq "a" && bc())
- || ($t eq "h" && officer())
- || ($t eq "s" && scanner())){
- $points = 1 unless $points;
- if ($points*$points > 400){
- $ND::server->command("msg $ND::target Values between -20 and 20 please");
- return;
- }
- my $f = $ND::DBH->prepare("SELECT uid,username FROM users WHERE username ILIKE ?");
- $f->execute($nick);
- my @row = $f->fetchrow();
- if ($f->rows == 1){
- my $type = "defense";
- $type = "attack" if $t eq "a";
- $type = "humor" if $t eq "h";
- $type = "scan" if $t eq "s";
- my ($fleets) = $ND::DBH->selectrow_array('SELECT count(*) FROM raids r JOIN raid_targets rt ON r.id = rt.raid JOIN raid_claims rc ON rt.id = rc.target WHERE not launched AND uid = ? AND tick + 24 > tick();',undef,$row[0]);
- if ($t eq 'a' && $fleets > 0 && $points > 0){
- $ND::server->command("msg $ND::target $row[1] has $fleets claimed waves the last 24 ticks that aren't marked as launched, so no points.");
- return;
- }
- $type .= "_points";
- $ND::DBH->do("UPDATE users SET $type = $type + ? WHERE uid = ?",undef,$points,$row[0]);
- $ND::server->command("msg $ND::target $row[1] has been given $points $type");
- }elsif ($f->rows == 0){
- $ND::server->command("msg $ND::target No hit, maybe spelling mistake, or add % as wildcard");
- }else{
- $ND::server->command("msg $ND::target More than 1 user matched, please refine the search");
- }
- $f->finish;
-
- }else{
- $ND::server->command("msg $ND::target You don't have access for that");
- }
-}
-
-1;
INSERT INTO roles VALUES('irc_getfleet');
INSERT INTO roles VALUES('irc_sethost');
INSERT INTO roles VALUES('irc_setpnick');
+INSERT INTO roles VALUES('irc_a');
+INSERT INTO roles VALUES('irc_d');
+INSERT INTO roles VALUES('irc_s');
+INSERT INTO roles VALUES('irc_h');
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_getfleet');
INSERT INTO group_roles (gid,role) VALUES(1,'irc_sethost');
INSERT INTO group_roles (gid,role) VALUES(1,'irc_setpnick');
+INSERT INTO group_roles (gid,role) VALUES(1,'irc_a');
+INSERT INTO group_roles (gid,role) VALUES(1,'irc_d');
+INSERT INTO group_roles (gid,role) VALUES(1,'irc_s');
+INSERT INTO group_roles (gid,role) VALUES(1,'irc_h');
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_getfleet');
INSERT INTO group_roles (gid,role) VALUES(3,'irc_sethost');
INSERT INTO group_roles (gid,role) VALUES(3,'irc_setpnick');
+INSERT INTO group_roles (gid,role) VALUES(3,'irc_a');
+INSERT INTO group_roles (gid,role) VALUES(3,'irc_d');
+INSERT INTO group_roles (gid,role) VALUES(3,'irc_s');
+INSERT INTO group_roles (gid,role) VALUES(3,'irc_h');
INSERT INTO group_roles (gid,role) VALUES(4,'irc_points_others');
+INSERT INTO group_roles (gid,role) VALUES(4,'irc_a');
INSERT INTO group_roles (gid,role) VALUES(5,'irc_p_nick');
INSERT INTO group_roles (gid,role) VALUES(5,'irc_p_intel');
INSERT INTO group_roles (gid,role) VALUES(6,'irc_sms');
INSERT INTO group_roles (gid,role) VALUES(6,'irc_getships');
INSERT INTO group_roles (gid,role) VALUES(6,'irc_getfleet');
+INSERT INTO group_roles (gid,role) VALUES(6,'irc_d');
INSERT INTO group_roles (gid,role) VALUES(8,'irc_scanreqs');
INSERT INTO group_roles (gid,role) VALUES(8,'irc_anonscan');
INSERT INTO group_roles (gid,role) VALUES(18,'irc_lastseen');
INSERT INTO group_roles (gid,role) VALUES(19,'irc_p_intel');
+INSERT INTO group_roles (gid,role) VALUES(19,'irc_h');
$disp->load('Basic','PA','Channel','Scans','Quotes','Members','Usermgm');
$ND::scanchan = '#testarmer';
-$disp->add_channel('#testarlite', ['pub','help','channel']);
+$disp->add_channel('#testarlite', ['pub','help','channel','def']);
$disp->add_channel($ND::scanchan, ['pub','help','channel','scan','member']);
$disp->add_channel('pm', ['pub','help','pm']);