]> ruin.nu Git - NDIRC.git/commitdiff
Converted .setchannel
authorMichael Andreen <harv@ruin.nu>
Sat, 16 May 2009 23:08:39 +0000 (01:08 +0200)
committerMichael Andreen <harv@ruin.nu>
Sat, 16 May 2009 23:08:39 +0000 (01:08 +0200)
Commands/Intel.pm
Intel.pm [deleted file]
database/roles.sql

index dd8eb2eca672f189b4943c2c743b5a17700d844b..9643333461973995da6bb958cc78b31d1978bfc9 100644 (file)
@@ -120,4 +120,33 @@ SELECT id,alliance,alliance_id FROM current_planet_stats WHERE x = ? AND y = ? a
        }
 }
 
+sub setchannel
+       : Help(Usage: .setchannel X:Y:Z channel | Set channel or bot for a planet)
+       : ACL(irc_setchannel)
+{
+       my ($self,$c,$msg) = @_;
+       my ($x,$y,$z,$channel) = $msg =~ /^(\d+)\D(\d+)\D(\d+) (\S+)$/ or die 'ARGS';
+       my $dbh = $c->model;
+
+       my $findid = $dbh->prepare_cached(q{SELECT id,channel FROM current_planet_stats
+               WHERE x = ? AND y = ? and z = ?});
+       my ($id,$oc) = $dbh->selectrow_array($findid,undef,$x,$y,$z);
+       if ($channel ~~ $oc){
+               $c->reply("$x:$y:$z already got $oc as channel");
+       }elsif($id){
+               $dbh->begin_work;
+               $dbh->do(q{UPDATE planets SET channel = $1 WHERE id = $2}
+                       ,undef,$channel,$id);
+               $c->intel_log($id,"Set channel to: $channel");
+               $dbh->commit;
+               if ($oc){
+                       $c->reply("Changed $x:$y:$z from <b>$oc</b> to <b>$channel</b>");
+               }else{
+                       $c->reply("Setting $x:$y:$z as <b>$channel</b>");
+               }
+       }else{
+               $c->reply("Couldn't find a planet at $x:$y:$z");
+       }
+}
+
 1;
diff --git a/Intel.pm b/Intel.pm
deleted file mode 100644 (file)
index 83dd833..0000000
--- a/Intel.pm
+++ /dev/null
@@ -1,63 +0,0 @@
-#**************************************************************************
-#   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::Intel;
-use strict;
-use warnings;
-use ND::DB;
-use NDIRC::Access;
-use NDIRC::Misc;
-use ND::Include;
-require Exporter;
-
-our @ISA = qw/Exporter/;
-
-our @EXPORT = qw/setChannel/;
-
-sub setChannel {
-       my ($msg, $command) = @_;
-       my ($x,$y,$z,$channel);
-       if(defined $msg && $msg =~ /^(\d+)\D(\d+)\D(\d+) (\S+)$/){
-               $x = $1;
-               $y = $2;
-               $z = $3;
-               $channel = $4;
-       }else{
-               $ND::server->command("notice $ND::nick Usage: .$command X:Y:Z channel");
-               return;
-       }
-       if (my $user = intel){
-               my $findid = $ND::DBH->prepare_cached(q{SELECT id,channel FROM current_planet_stats 
-                               WHERE x = ? AND y = ? and z = ?});
-               my ($id,$c) = $ND::DBH->selectrow_array($findid,undef,$x,$y,$z);
-               if ($ND::DBH->do('UPDATE planets SET channel = $1 WHERE id = $2'
-                               ,undef,$channel,$id)){
-
-                       if (defined $c){
-                               $ND::server->command("msg $ND::target Changed $x:$y:$z from $ND::B$c$ND::B to $ND::B$channel");
-                       }else{
-                               $ND::server->command("msg $ND::target Setting $x:$y:$z as $ND::B$channel");
-                       }
-                       intel_log $user->{uid},$id,"Set channel to: $channel";
-               }else{
-                       $ND::server->command("msg $ND::target Couldn't find a planet at $x:$y:$z");
-               }
-       }
-}
-
-1;
index 315fe47a0cb1085429aca4fc064d85863be630bb..fb3f64d59afc487ffe694edc434bf0ff7cd64744 100644 (file)
@@ -27,6 +27,7 @@ INSERT INTO roles VALUES('irc_h');
 INSERT INTO roles VALUES('irc_sethostile');
 INSERT INTO roles VALUES('irc_setnick');
 INSERT INTO roles VALUES('irc_setally');
+INSERT INTO roles VALUES('irc_setchannel');
 
 INSERT INTO group_roles (gid,role) VALUES(1,'irc_p_nick');
 INSERT INTO group_roles (gid,role) VALUES(1,'irc_p_intel');
@@ -55,6 +56,7 @@ 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(1,'irc_setnick');
 INSERT INTO group_roles (gid,role) VALUES(1,'irc_setally');
+INSERT INTO group_roles (gid,role) VALUES(1,'irc_setchannel');
 
 INSERT INTO group_roles (gid,role) VALUES(2,'irc_gs');
 INSERT INTO group_roles (gid,role) VALUES(2,'irc_scan');
@@ -85,6 +87,7 @@ 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(3,'irc_setnick');
 INSERT INTO group_roles (gid,role) VALUES(3,'irc_setally');
+INSERT INTO group_roles (gid,role) VALUES(3,'irc_setchannel');
 
 INSERT INTO group_roles (gid,role) VALUES(4,'irc_points_others');
 INSERT INTO group_roles (gid,role) VALUES(4,'irc_a');
@@ -94,6 +97,7 @@ 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(5,'irc_setnick');
 INSERT INTO group_roles (gid,role) VALUES(5,'irc_setally');
+INSERT INTO group_roles (gid,role) VALUES(5,'irc_setchannel');
 
 INSERT INTO group_roles (gid,role) VALUES(6,'irc_p_intel');
 INSERT INTO group_roles (gid,role) VALUES(6,'irc_points_others');