--- /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::Intel;
+
+use strict;
+use warnings;
+use feature ':5.10';
+
+use Moose;
+use MooseX::MethodAttributes;
+
+sub sethostile
+ : Help(Usage: .sethostile X:Y:Z)
+ : ACL(irc_sethostile)
+{
+ my ($self,$c,$msg) = @_;
+ my ($x,$y,$z) = $msg =~ /^(\d+)\D(\d+)\D(\d+)$/ or die 'ARGS';
+ my $dbh = $c->model;
+
+ my $findid = $dbh->prepare(q{SELECT planetid(?,?,?,tick())});
+ my ($id) = $dbh->selectrow_array($findid,undef,$x,$y,$z);
+ $dbh->begin_work;
+ my $rv = $dbh->do(q{UPDATE planets SET planet_status = 'Hostile' WHERE id = $1}
+ ,undef,$id);
+ if ($rv == 1){
+ $c->reply("$x:$y:$z is now marked s hostile");
+ $c->intel_log($id,"Set planet_status to: 'Hostile'");
+ }
+ $dbh->commit;
+}
+
+1;
$self->server->command("$command $msg");
}
+sub intel_log {
+ my ($c,$planet, $message) = @_;
+ my $log = $c->model->prepare_cached(q{
+INSERT INTO forum_posts (ftid,uid,message) VALUES(
+ (SELECT ftid FROM planets WHERE id = $3)
+ ,(SELECT uid FROM users WHERE hostmask ILIKE $1)
+ ,$2)
+ });
+ $log->execute($c->host,$message,$planet);
+}
+
sub _build_roles {
my ($self) = @_;
our @ISA = qw/Exporter/;
-our @EXPORT = qw/setHostile setNick setAlly setChannel/;
-
-sub setHostile {
- my ($msg, $command) = @_;
- my ($x,$y,$z);
- if(defined $msg && $msg =~ /^(\d+)\D(\d+)\D(\d+)$/){
- $x = $1;
- $y = $2;
- $z = $3;
- }else{
- $ND::server->command("notice $ND::nick Usage: .$command X:Y:Z");
- return;
- }
- if(my $user = dc()){
- my $findid = $ND::DBH->prepare_cached(q{SELECT planetid(?,?,?,tick())});
- my ($id) = $ND::DBH->selectrow_array($findid,undef,$x,$y,$z);
- my $rv = $ND::DBH->do(q{UPDATE planets SET planet_status = 'Hostile' WHERE id = $1},undef,$id);
- if ($rv == 1){
- $ND::server->command("msg $ND::target $x:$y:$z is now marked s hostile");
- intel_log $user->{uid},$id,"Set planet_status to: 'Hostile'";
- }
- }
-}
+our @EXPORT = qw/setNick setAlly setChannel/;
sub setNick {
my ($msg, $command) = @_;
INSERT INTO roles VALUES('irc_d');
INSERT INTO roles VALUES('irc_s');
INSERT INTO roles VALUES('irc_h');
+INSERT INTO roles VALUES('irc_sethostile');
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_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(1,'irc_sethostile');
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_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(3,'irc_sethostile');
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(5,'irc_sethostile');
INSERT INTO group_roles (gid,role) VALUES(6,'irc_p_intel');
INSERT INTO group_roles (gid,role) VALUES(6,'irc_points_others');
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(6,'irc_sethostile');
INSERT INTO group_roles (gid,role) VALUES(8,'irc_scanreqs');
INSERT INTO group_roles (gid,role) VALUES(8,'irc_anonscan');
my $disp = new NDIRC::Dispatcher;
-$disp->load('Basic','PA','Channel','Scans','Quotes','Members','Usermgm');
+$disp->load('Basic','PA','Channel','Scans','Quotes','Members','Usermgm','Intel');
$ND::scanchan = '#testarmer';
$disp->add_channel('#testarlite', ['pub','help','channel','def']);