$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("<b>$type</b> scan of $x:$y:$z "
+ . "($scan->{scan_id} pt: <b>$scan->{tick}</b>): $text");
+}
+
1;