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 ***************************************************************************/
26 use DBD::Pg qw(:pg_types);
27 use CGI qw/:standard/;
30 use Encode::Encoder qw(encoder);
31 use MIME::QuotedPrint;
34 use lib "$FindBin::Bin/../lib";
37 my $dbh = ND::DB::DB();
40 my $text = join '',@text;
42 $text =~ /ndreport\+(.+?)\@ruin\.nu/;
46 my $email = Email::Simple->new($text);
48 my $body = encoder($email->body,'ISO-8859-15')->utf8;
50 my $c = $dbh->prepare(q{
51 SELECT coords(x,y,z) FROM current_planet_stats WHERE pid = (SELECT pid FROM users WHERE username = $1)
54 my $a = $dbh->prepare(q{
55 SELECT race, $1 - tick() FROM current_planet_stats WHERE x = $2 AND y = $3 AND z = $4
58 my $report = $dbh->prepare(q{INSERT INTO irc_requests (channel,uid,message) VALUES('def',$1,$2)});
60 while($body =~ /jumpgate from (.+?), located at (\d+):(\d+):(\d+).+?our system in tick (\d+) and appears to have (\d+)/sg){
61 my ($fleet, $x,$y,$z,$tick, $amount) = ($1,$2,$3,$4,$5,$6);
63 my ($coords) = $dbh->selectrow_array($c, undef, $user);
65 $coords //= '(no coords entered)';
67 my ($race,$eta) = $dbh->selectrow_array($a,undef, $tick,$x,$y,$z);
69 $report->execute(-5,"$user has incs: $coords $x:$y:$z $fleet $race $amount $eta");
74 system 'killall','-USR1', 'ndbot.pl';