]> ruin.nu Git - NDIRC.git/blobdiff - Commands/Intel.pm
Converted .sethostile
[NDIRC.git] / Commands / Intel.pm
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;