]> ruin.nu Git - NDIRC.git/commitdiff
Converted .sethostile
authorMichael Andreen <harv@ruin.nu>
Sat, 16 May 2009 21:31:14 +0000 (23:31 +0200)
committerMichael Andreen <harv@ruin.nu>
Sat, 16 May 2009 21:31:14 +0000 (23:31 +0200)
Commands/Intel.pm [new file with mode: 0644]
Context.pm
Intel.pm
database/roles.sql
ndawn.pl

diff --git a/Commands/Intel.pm b/Commands/Intel.pm
new file mode 100644 (file)
index 0000000..5e79c96
--- /dev/null
@@ -0,0 +1,49 @@
+#**************************************************************************
+#   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;
index 9d37655729453ed454caeede43a69fff538621ce..6831bdef9c0ddae934e21413d4467a4284088aa3 100644 (file)
@@ -109,6 +109,17 @@ sub message {
        $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) = @_;
 
index 18ea15f16fc2218cf8ca2225c3a9da28e58bf37c..7594c09ac75bb9282d71add33718c6aaba96ae4e 100644 (file)
--- a/Intel.pm
+++ b/Intel.pm
@@ -27,29 +27,7 @@ require Exporter;
 
 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) = @_;
index d98dce654d471ed9cceb3ac48f97a210c8511b5a..b84e53d8d604854dd4aa36fde909e9467dbe6065 100644 (file)
@@ -24,6 +24,7 @@ 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 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');
@@ -49,6 +50,7 @@ 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(1,'irc_sethostile');
 
 INSERT INTO group_roles (gid,role) VALUES(2,'irc_gs');
 INSERT INTO group_roles (gid,role) VALUES(2,'irc_scan');
@@ -76,12 +78,14 @@ 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(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');
@@ -89,6 +93,7 @@ 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(6,'irc_sethostile');
 
 INSERT INTO group_roles (gid,role) VALUES(8,'irc_scanreqs');
 INSERT INTO group_roles (gid,role) VALUES(8,'irc_anonscan');
index 594477e2b3b8673066a7c2a7e463c0a77972dbcf..49a7a079c92cf8ffce28050bdd3dae5ca5dde417 100644 (file)
--- a/ndawn.pl
+++ b/ndawn.pl
@@ -55,7 +55,7 @@ my $TICK = $DBH->selectrow_array('SELECT tick()');
 
 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']);