X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=Commands%2FScans.pm;fp=Commands%2FScans.pm;h=1f5f347272b405baf7e579747b1888de081adab2;hb=c8e65de85f3c2724a5290e0ee612b83e7f63aea0;hp=11f3337308eeaef821ff59383f43764ccb918001;hpb=f4fda6de68d23833ffe61c81f29177cc210b3825;p=NDIRC.git diff --git a/Commands/Scans.pm b/Commands/Scans.pm index 11f3337..1f5f347 100644 --- a/Commands/Scans.pm +++ b/Commands/Scans.pm @@ -144,4 +144,46 @@ ORDER BY id $c->reply($text || 'No unhandled requests.'); } +sub scan + : Help(syntax: scan type X:Y:Z [tick] | type is the first character in the scan name, like p for planet scan. Specify a tick if you want scans older than the specified tick.) + : ACL(irc_scan) + : Type(pm) +{ + my ($self, $c,$msg) = @_; + + my ($t, $x, $y, $z, $tick) + = $msg =~ /^([pdunja]) (\d+)\D+(\d+)\D+(\d+)(?: (\d+))?/ or die 'ARGS'; + my $type =$scantypes[$scanid{$t}-1]; + + my $scan = $c->model->selectrow_hashref(q{ +SELECT id, scan_id, tick FROM scans +WHERE type = $1 AND planet = planetid($2,$3,$4,0) AND COALESCE(tick < $5,TRUE) +ORDER BY tick DESC LIMIT 1 + },undef,$type,$x,$y,$z,$tick); + unless ($scan->{id}){ + $c->reply("No $type scan for $x:$y:$z. Planet might not exist."); + return; + } + my $text = ''; + given ($t){ + when(/[ua]/){ + my $fid = $c->model->selectrow_array(q{ +SELECT fid FROM fleet_scans WHERE id = $1 + },undef,$scan->{id}); + my $ships = $c->model->prepare(q{ +SELECT ship,amount FROM fleet_ships WHERE fid = $1 ORDER BY num + }); + $ships->execute($fid); + while (my $ship = $ships->fetchrow_hashref){ + $text .= " $ship->{ship} $ship->{amount} |" + } + } + default { + $text = "http://game.planetarion.com/showscan.pl?scan_id=$scan->{scan_id}"; + } + } + $c->reply("$type scan of $x:$y:$z " + . "($scan->{scan_id} pt: $scan->{tick}): $text"); +} + 1;