fix console.pl max scroll depth
[spider.git] / cmd / wwv.pl
1 #
2 # WWV command
3 #
4 # This can only be used if the appropriate flag is enabled.
5 #
6 # I would STRONGLY recommend that you
7 # DO NOT ENABLE THIS COMMAND - YES THAT MEANS YOU!!!
8 #
9 # There are enough internet sources of WWV, you should really
10 # only enable a callsign for posting WWV spots if it is some
11 # RELIABLE automatic feed from somewhere.
12 #
13 # If you want to allow this command then you need to know that
14 # you must set/var @Geomag::allowed = qw(call call call) for EVERY
15 # callsign that issues wwv not just on your node but from outside 
16 # AS WELL. 
17 #
18 # I am making this deliberately hard because I believe that you are
19 # either a RELIABLE (probably machine generated) source of WWV or
20 # you shouldn't be doing it (and will have consequent problems).
21 #
22 # Copyright (c) 2001 Dirk Koopman G1TLH
23 #
24 #
25 #
26 my ($self, $line) = @_;
27 my $call = $self->call;
28 $call =~ s/-\d+$//;
29 return (1, $self->msg('e5')) unless grep $call eq $_, @Geomag::allowed;
30
31 my @out;
32
33 #$DB::single = 1;
34
35 # calc 18 minutes past the hour in time_t seconds
36 my $hour = (gmtime $main::systime)[2];
37 my $d = int ($main::systime / 3600) * 3600 + 18 * 60; 
38
39 $line = unpad($line);
40
41 my @l = split /\s*,\s*/, $line;
42 my $forecast = pop @l;
43
44 # make a hash out of the args
45 my %args = map {split /\s*=\s*/, lc $_} @l; 
46
47 # check the ranges of each one
48 push @out, $self->msg('wwv1', 'k') unless defined $args{k} && $args{k} >= 0 && $args{k} <= 9;
49 push @out, $self->msg('wwv1', 'a') unless defined $args{a} && $args{a} >= 0 && $args{a} <= 400;
50 push @out, $self->msg('wwv1', 'sf') unless defined $args{sf} && $args{sf} >= 65 && $args{sf} <= 300;
51 push @out, $self->msg('wwv1', 'forecast') unless $forecast;
52 push @out, $self->msg('wwv2') if Geomag::dup($d, $args{sf}, $args{k}, $args{a}, $forecast);
53
54 return (1, @out) if @out;
55
56 # now this is all subject to change, but it will do for now, I think. 
57 my $today = cldate($main::systime);
58
59
60 # PC23^14-Dec-2001^15^220^  4^ 1^R=212 SA:mo=>mo-hi GF:qu=>qu-un^KH2D^KH2D^H48^~
61 # Date        Hour   SFI   A   K Forecast                               Logger
62 # 14-Dec-2001   15   220   4   1 R=212 SA:mo=>mo-hi GF:qu=>qu-un       <KH2D>
63
64 my @field = ('PC23',$today,$hour,$args{sf},$args{a},$args{k},$forecast, $self->call ,$main::mycall, 'H99');
65
66 my $s = join('^', @field) . '^';
67 my ($r) = $forecast =~ /R=(\d+)/;
68 Geomag::update($d, @field[2..8], $r);
69 DXProt::send_wwv_spot($self, $s, $d, @field[2..8]);
70 #$self->wwv($s, 0, @field[1..8]);
71 return (1, @out);
72
73