]> ruin.nu Git - NDIRC.git/blobdiff - Delling.pm
Log notices, need POE::Component::IRC 6.16
[NDIRC.git] / Delling.pm
index 224a6572650bfccd2109e34016d87a8d96ece066..39c7cf9f65494371a17733531bbe950251fcd44b 100644 (file)
@@ -36,7 +36,7 @@ has hal => (
        lazy_build => 1,
 );
 
-sub irc_public {
+after irc_public => sub {
        my ($self,$sender, $who, $where, $msg) = @_[OBJECT,SENDER, ARG0 .. ARG2];
        my ($nick,$username,$address) = ( split /[!@]/, $who );
        my $channel = $where->[0];
@@ -63,9 +63,9 @@ sub irc_public {
        if ($self->parseCommand($msg,$irc,$nick,$address,$channel,$dbh)){
                #Command parsed and run successfully
        }
-}
+};
 
-sub irc_msg {
+after irc_msg => sub {
        my ($self,$sender, $who, $where, $msg) = @_[OBJECT,SENDER, ARG0 .. ARG2];
        my ($nick,$username,$address) = ( split /[!@]/, $who );
        my $irc = $sender->get_heap();
@@ -79,7 +79,7 @@ sub irc_msg {
        }else{
                $irc->yield(notice => $nick, "unknown command");
        }
-}
+};
 
 sub irc_join {
        my ($self,$sender, $who, $channel) = @_[OBJECT,SENDER, ARG0 .. ARG1];
@@ -117,20 +117,23 @@ sub refresh {
 
        my $dbh = DB();
        my $scans = $dbh->prepare(q{SELECT s.scan_id
+                       ,coords(x,y,z),type
                        ,array_agg(sr.nick) AS nick
                        ,array_agg(sr.id) AS id
                FROM scan_requests sr
                        JOIN scans s USING (pid,type)
+                       JOIN current_planet_stats USING (pid)
                WHERE sr.time > NOW() - '30 min'::INTERVAL
                        AND s.tick >= sr.tick AND NOT sr.sent
-               GROUP BY scan_id
+               GROUP BY scan_id,x,y,z,type
                });
        my $sentscan = $dbh->prepare(q{UPDATE scan_requests
                SET sent = TRUE WHERE id = ANY($1)
                });
        $scans->execute;
        while (my $scan = $scans->fetchrow_hashref){
-               $heap->{irc}->yield(notice => $scan->{nick}, "http://game.planetarion.com/showscan.pl?scan_id=$scan->{scan_id}");
+               $heap->{irc}->yield(notice => $scan->{nick}, "($scan->{coords} $scan->{type})"
+                       ." http://game.planetarion.com/showscan.pl?scan_id=$scan->{scan_id}");
                $sentscan->execute($scan->{id});
        }
        return;