3 /***************************************************************************
4 * Copyright (C) 2006 by Michael Andreen <harvATruinDOTnu> *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the *
18 * Free Software Foundation, Inc., *
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
20 ***************************************************************************/
27 use DBD::Pg qw(:pg_types);
28 use CGI qw/:standard/;
32 use MIME::QuotedPrint;
35 use lib "$FindBin::Bin/../lib";
38 my $dbh = ND::DB::DB();
41 my $text = join '',@text;
43 $text =~ /ndreport\+(.+?)\@ruin\.nu/;
47 my $email = Email::Simple->new($text);
49 my $body = decode('ISO-8859-1', $email->body);
51 my $c = $dbh->prepare(q{
52 SELECT coords(x,y,z) FROM current_planet_stats WHERE pid = (SELECT pid FROM users WHERE username = $1
53 AND uid IN (SELECT uid FROM groupmembers WHERE gid = 'M'))
56 my $a = $dbh->prepare(q{
57 SELECT race, $1 - tick() FROM current_planet_stats WHERE x = $2 AND y = $3 AND z = $4
60 my $report = $dbh->prepare(q{INSERT INTO irc_requests (channel,uid,message) VALUES('def',$1,$2)});
62 while($body =~ /jumpgate from (.+?), located at (\d+):(\d+):(\d+).+?our system in tick (\d+) and appears to have (\d+)/sg){
63 my ($fleet, $x,$y,$z,$tick, $amount) = ($1,$2,$3,$4,$5,$6);
65 my ($coords) = $dbh->selectrow_array($c, undef, $user);
67 $coords //= '(no coords entered)';
69 my ($race,$eta) = $dbh->selectrow_array($a,undef, $tick,$x,$y,$z);
71 $report->execute(-5,"$user has incs: $coords $x:$y:$z $fleet $race $amount $eta");
76 system 'killall','-USR1', 'ndbot.pl';