]> ruin.nu Git - NDIRC.git/commitdiff
Converted the .scanreqs command
authorMichael Andreen <harv@ruin.nu>
Sat, 9 May 2009 22:25:01 +0000 (00:25 +0200)
committerMichael Andreen <harv@ruin.nu>
Sat, 9 May 2009 22:25:01 +0000 (00:25 +0200)
Commands/Scans.pm
Scans.pm
database/roles.sql

index 2cb0c3c12c3db8ab85e55020501cbc1bb5ccaaf5..134629bb49fbdf69592df7824451bcd21e75e799 100644 (file)
@@ -91,4 +91,48 @@ VALUES((SELECT uid FROM users WHERE hostmask ILIKE $1),$2,$3,$4) RETURNING (id)
        }
 }
 
+my %scantypes;
+{
+       my $i = 1;
+       %scantypes = map {$_ => $i++} @scantypes;
+}
+
+sub scanreqs
+       : Help(syntax: .scanreqs [-pdunja] | Lists scan requests that haven't been handled. The argument can be used to omit types you don't have, like .scanreqs -ja to list all requests except jumpgates and advanced unit scans.)
+       : ACL(irc_scanreqs)
+{
+       my ($self, $c, $msg) = @_;
+
+       my @notype;
+       if ($msg =~ /^-([pdunja]+)$/){
+               for (split //, $1){
+                       push @notype, $scantypes[$scanid{$_}-1];
+               }
+       }elsif($msg){
+               die 'ARGS';
+       }
+
+       my $reqs = $c->model->prepare(q{
+SELECT min(sr.id) AS id, x,y,z,type
+FROM scan_requests sr
+       JOIN current_planet_stats p ON p.id = sr.planet
+WHERE sr.time > NOW() - '30 min'::INTERVAL
+       AND NOT EXISTS (SELECT scan_id FROM scans
+               WHERE planet = sr.planet
+                       AND type = sr.type
+                       AND tick >= sr.tick
+       )
+       AND type <> ALL($1)
+GROUP BY x,y,z,type
+ORDER BY id
+               });
+       $reqs->execute(\@notype);
+       my $text = '';
+       while (my $req = $reqs->fetchrow_hashref){
+               $text .= "<b>$req->{id}</b> http://game.planetarion.com/waves.pl?id=$scantypes{$req->{type}}&x=$req->{x}&y=$req->{y}&z=$req->{z} "
+       }
+
+       $c->reply($text || 'No unhandled requests.');
+}
+
 1;
index b2621e8d332da3b3332fe9abf8e04ead03357dff..2b33361c65413da1665e70fe11e78f6a8e6fe3a4 100644 (file)
--- a/Scans.pm
+++ b/Scans.pm
@@ -84,49 +84,6 @@ sub sendScan {
        }
 }
 
-
-our %scantypes;
-{
-       my $i = 1;
-       %scantypes = map {$_ => $i++} @scantypes;
-}
-
-sub scanReqs {
-       my ($msg, $command) = @_;
-
-       if (scanner()){
-
-               my @notype;
-               if ($msg && $msg =~ /-([pdunja]+)/){
-                       for (split //, $1){
-                               push @notype, $scantypes[$scanid{$_}-1];
-                       }
-               }
-
-               my $reqs = $ND::DBH->prepare(q{SELECT min(sr.id) AS id, x,y,z,type
-                       FROM scan_requests sr
-                               JOIN current_planet_stats p ON p.id = sr.planet
-                       WHERE sr.time > NOW() - '30 min'::INTERVAL
-                               AND NOT EXISTS (SELECT scan_id FROM scans
-                                       WHERE planet = sr.planet
-                                               AND type = sr.type
-                                               AND tick >= sr.tick
-                               )
-                               AND type <> ALL($1)
-                       GROUP BY x,y,z,type
-                       ORDER BY id
-                       });
-               $reqs->execute(\@notype);
-               my $text = '';
-               while (my $req = $reqs->fetchrow_hashref){
-                       $text .= "$ND::B$req->{id}$ND::O http://game.planetarion.com/waves.pl?id=$scantypes{$req->{type}}&x=$req->{x}&y=$req->{y}&z=$req->{z} "
-               }
-
-               $text = 'No unhandled requests.' unless $text;
-               $ND::server->command("notice $ND::nick $text");
-       }
-}
-
 sub getScan {
        my ($msg, $command) = @_;
 
index 2a2e1e0ac446cdfebfce2f4f7573d1ace17bd45d..6d21757c6c464e6c927af90ba6d971ef30503f21 100644 (file)
@@ -3,23 +3,28 @@ INSERT INTO roles VALUES('irc_p_intel');
 INSERT INTO roles VALUES('irc_masterop');
 INSERT INTO roles VALUES('irc_masterinvite');
 INSERT INTO roles VALUES('irc_gs');
+INSERT INTO roles VALUES('irc_scanreqs');
 
 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_masterop');
 INSERT INTO group_roles (gid,role) VALUES(1,'irc_masterinvite');
+INSERT INTO group_roles (gid,role) VALUES(1,'irc_scanreqs');
 
 INSERT INTO group_roles (gid,role) VALUES(2,'irc_gs');
 
 INSERT INTO group_roles (gid,role) VALUES(3,'irc_p_nick');
 INSERT INTO group_roles (gid,role) VALUES(3,'irc_masterop');
 INSERT INTO group_roles (gid,role) VALUES(3,'irc_masterinvite');
+INSERT INTO group_roles (gid,role) VALUES(3,'irc_scanreqs');
 
 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_p_intel');
 
+INSERT INTO group_roles (gid,role) VALUES(8,'irc_scanreqs');
+
 INSERT INTO group_roles (gid,role) VALUES(18,'irc_p_nick');
 INSERT INTO group_roles (gid,role) VALUES(18,'irc_p_intel');