add user level ping as link check command
[spider.git] / cmd / ping.pl
1 #
2 # ping command
3 #
4 # Copyright (c) 1998 Dirk Koopman G1TLH
5 #
6 #
7 #
8
9 my $counter;
10
11 sub init
12 {
13         $counter = 0;
14 }
15
16 sub handle
17 {
18         my $self = shift;
19         my $line = uc shift;            # only one callsign allowed 
20         my ($call) = $line =~ /^\s*(\S+)/;
21
22 #       $DB::single = 1;
23
24         if ($self->{priv} < 1) {
25                 if ($call) {
26                         return (1, "PONG $call");
27                 }
28                 ++$counter, return (1, "PONG $counter") 
29         }
30
31         # is there a call?
32         return (1, $self->msg('e6')) if !$call;
33
34         # is it me?
35         return (1, $self->msg('pinge1')) if $call eq $main::mycall;
36
37         # can we see it? Is it a node?
38         my $noderef = Route::Node::get($call);
39
40         return (1, $self->msg('e7', $call)) unless $noderef;
41
42         # ping it
43         DXXml::Ping::add($self, $call);
44
45         return (1, $self->msg('pingo', $call));
46 }
47
48