-sub gs
- : Help(syntax: gs type X:Y:Z message | type is the first character in the scan name, like p for planet scan, message is a message to scanners, like plz or thanks like plz or thanks)
- : ACL(irc_gs)
- : Type(pm)
-{
- my ($self,$c,$args) = @_;
-
- my ($typeid, $x, $y, $z, $msg) = $args =~ /^([pdunja]) (\d+)\D+(\d+)\D+(\d+) (\S.*)/
- or die 'ARGS';
- $typeid = $scanid{$typeid};
- my $type = $scantypes[$typeid-1];
-
- my $planet = $c->model->selectrow_array(q{SELECT planetid($1,$2,$3,tick())}
- ,undef,$x,$y,$z);
-
- my $query = $c->model->prepare(q{SELECT scan_id
- FROM scans
- WHERE planet = $1 AND type = $2 AND tick >= tick()});
- $query->execute($planet,$type);
-
- if (my $scan = $query->fetchrow_hashref){
- $c->reply("scan already exist: "
- . "http://game.planetarion.com/showscan.pl?scan_id=$scan->{scan_id}");
- }else{
- my $req = $c->model->prepare(q{
+command gs => {
+ help => q(syntax: gs type X:Y:Z message | type is the first character in the scan name, like p for planet scan, message is a message to scanners, like plz or thanks like plz or thanks),
+ acl => q(irc_gs),
+ type => q(pm),
+}, class extends NDIRC::Command {
+ method execute($c,$args) {
+ my ($typeid, $x, $y, $z, $msg) = $args =~ /^([pdunja]) (\d+)\D+(\d+)\D+(\d+) (\S.*)/
+ or die 'ARGS';
+ $typeid = $scanid{$typeid};
+ my $type = $scantypes[$typeid-1];
+
+ my ($planet,$dists,$tick) = $c->model->selectrow_array(q{
+SELECT pid,distorters,tick
+FROM current_planet_stats LEFT JOIN current_development_scans USING (pid)
+WHERE x = $1 AND y = $2 AND z = $3
+ },undef,$x,$y,$z);
+ unless ($planet){
+ $c->reply("There is no planet with coords $x:$y:$z, try again after the tick.");
+ return;
+ }
+
+ my $query = $c->model->prepare(q{
+SELECT scan_id FROM scans
+WHERE pid = $1 AND type = $2 AND tick >= tick()
+ });
+ $query->execute($planet,$type);
+
+ if (my $scan = $query->fetchrow_hashref){
+ $c->reply("scan already exist: "
+ . "http://game.planetarion.com/showscan.pl?scan_id=$scan->{scan_id}");
+ }else{
+ my $req = $c->model->prepare(q{