fixed Aliases so that shutdown works again.
[spider.git] / perl / DXCommandmode.pm
1 #!/usr/bin/perl
2 #
3 # This module impliments the user facing command mode for a dx cluster
4 #
5 # Copyright (c) 1998 Dirk Koopman G1TLH
6 #
7 # $Id$
8
9
10 package DXCommandmode;
11
12 use POSIX;
13
14 @ISA = qw(DXChannel);
15
16 use DXUtil;
17 use DXChannel;
18 use DXUser;
19 use DXVars;
20 use DXDebug;
21 use DXM;
22 use DXLog;
23 use DXLogPrint;
24 use DXBearing;
25 use CmdAlias;
26 use Filter;
27 use Minimuf;
28 use DXDb;
29 use AnnTalk;
30 use WCY;
31 use Sun;
32 use Internet;
33 use Script;
34
35
36 use strict;
37 use vars qw(%Cache %cmd_cache $errstr %aliases $scriptbase $maxerrors %nothereslug $maxbadcount);
38
39 %Cache = ();                                    # cache of dynamically loaded routine's mod times
40 %cmd_cache = ();                                # cache of short names
41 $errstr = ();                                   # error string from eval
42 %aliases = ();                                  # aliases for (parts of) commands
43 $scriptbase = "$main::root/scripts"; # the place where all users start scripts go
44 $maxerrors = 20;                                # the maximum number of concurrent errors allowed before disconnection
45 $maxbadcount = 3;                               # no of bad words allowed before disconnection
46
47
48 use vars qw($VERSION $BRANCH);
49 $VERSION = sprintf( "%d.%03d", q$Revision$ =~ /(\d+)\.(\d+)/ );
50 $BRANCH = sprintf( "%d.%03d", q$Revision$ =~ /\d+\.\d+\.(\d+)\.(\d+)/ ) || 0;
51 $main::build += $VERSION;
52 $main::branch += $BRANCH;
53
54 #
55 # obtain a new connection this is derived from dxchannel
56 #
57
58 sub new 
59 {
60         my $self = DXChannel::alloc(@_);
61
62         # routing, this must go out here to prevent race condx
63         my $pkg = shift;
64         my $call = shift;
65         my @rout = $main::routeroot->add_user($call, Route::here(1));
66         DXProt::route_pc16($main::me, $main::routeroot, @rout) if @rout;
67
68         return $self;
69 }
70
71 # this is how a a connection starts, you get a hello message and the motd with
72 # possibly some other messages asking you to set various things up if you are
73 # new (or nearly new and slacking) user.
74
75 sub start
76
77         my ($self, $line, $sort) = @_;
78         my $user = $self->{user};
79         my $call = $self->{call};
80         my $name = $user->{name};
81         
82         # log it
83         my $host = $self->{conn}->{peerhost} || "unknown";
84         Log('DXCommand', "$call connected from $host");
85
86         $self->{name} = $name ? $name : $call;
87         $self->send($self->msg('l2',$self->{name}));
88         $self->send_file($main::motd) if (-e $main::motd);
89         $self->state('prompt');         # a bit of room for further expansion, passwords etc
90         $self->{priv} = $user->priv || 0;
91         $self->{lang} = $user->lang || $main::lang || 'en';
92         $self->{pagelth} = $user->pagelth || 20;
93         $self->{priv} = 0 if $line =~ /^(ax|te)/; # set the connection priv to 0 - can be upgraded later
94         ($self->{width}) = $line =~ /width=(\d+)/;
95         $self->{width} = 80 unless $self->{width} && $self->{width} > 80;
96         $self->{consort} = $line;       # save the connection type
97         
98         # set some necessary flags on the user if they are connecting
99         $self->{beep} = $user->wantbeep;
100         $self->{ann} = $user->wantann;
101         $self->{wwv} = $user->wantwwv;
102         $self->{wcy} = $user->wantwcy;
103         $self->{talk} = $user->wanttalk;
104         $self->{wx} = $user->wantwx;
105         $self->{dx} = $user->wantdx;
106         $self->{logininfo} = $user->wantlogininfo;
107         $self->{ann_talk} = $user->wantann_talk;
108         $self->{here} = 1;
109
110         # get the filters
111         $self->{spotsfilter} = Filter::read_in('spots', $call, 0) || Filter::read_in('spots', 'user_default', 0);
112         $self->{wwvfilter} = Filter::read_in('wwv', $call, 0) || Filter::read_in('wwv', 'user_default', 0);
113         $self->{wcyfilter} = Filter::read_in('wcy', $call, 0) || Filter::read_in('wcy', 'user_default', 0);
114         $self->{annfilter} = Filter::read_in('ann', $call, 0) || Filter::read_in('ann', 'user_default', 0) ;
115
116         # clean up qra locators
117         my $qra = $user->qra;
118         $qra = undef if ($qra && !DXBearing::is_qra($qra));
119         unless ($qra) {
120                 my $lat = $user->lat;
121                 my $long = $user->long;
122                 $user->qra(DXBearing::lltoqra($lat, $long)) if (defined $lat && defined $long);  
123         }
124
125         # decide on echo
126         if (!$user->wantecho) {
127                 $self->send_now('E', "0");
128                 $self->send($self->msg('echow'));
129         }
130         
131         $self->tell_login('loginu');
132         
133         # do we need to send a forward/opernam?
134         my $lastoper = $user->lastoper || 0;
135         my $homenode = $user->homenode || ""; 
136         if ($homenode eq $main::mycall && $lastoper + $DXUser::lastoperinterval < $main::systime) {
137                 run_cmd($main::me, "forward/opernam $call");
138                 $user->lastoper($main::systime);
139         }
140
141         # run a script send the output to the punter
142         my $script = new Script(lc $call) || new Script('user_default');
143         $script->run($self) if $script;
144
145         # send cluster info
146         my $info = Route::cluster();
147         $self->send("Cluster:$info");
148
149         # send prompts and things
150         $self->send($self->msg('namee1')) if !$user->name;
151         $self->send($self->msg('qthe1')) if !$user->qth;
152         $self->send($self->msg('qll')) if !$user->qra || (!$user->lat && !$user->long);
153         $self->send($self->msg('hnodee1')) if !$user->qth;
154         $self->send($self->msg('m9')) if DXMsg::for_me($call);
155         $self->prompt;
156 }
157
158 #
159 # This is the normal command prompt driver
160 #
161
162 sub normal
163 {
164         my $self = shift;
165         my $cmdline = shift;
166         my @ans;
167         
168         # remove leading and trailing spaces
169         $cmdline =~ s/^\s*(.*)\s*$/$1/;
170         
171         if ($self->{state} eq 'page') {
172                 my $i = $self->{pagelth};
173                 my $ref = $self->{pagedata};
174                 my $tot = @$ref;
175                 
176                 # abort if we get a line starting in with a
177                 if ($cmdline =~ /^a/io) {
178                         undef $ref;
179                         $i = 0;
180                 }
181         
182                 # send a tranche of data
183                 while ($i-- > 0 && @$ref) {
184                         my $line = shift @$ref;
185                         $line =~ s/\s+$//o;     # why am having to do this? 
186                         $self->send($line);
187                 }
188                 
189                 # reset state if none or else chuck out an intermediate prompt
190                 if ($ref && @$ref) {
191                         $tot -= $self->{pagelth};
192                         $self->send($self->msg('page', $tot));
193                 } else {
194                         $self->state('prompt');
195                 }
196         } elsif ($self->{state} eq 'sysop') {
197                 my $passwd = $self->{user}->passwd;
198                 my @pw = split / */, $passwd;
199                 if ($passwd) {
200                         my @l = @{$self->{passwd}};
201                         my $str = "$pw[$l[0]].*$pw[$l[1]].*$pw[$l[2]].*$pw[$l[3]].*$pw[$l[4]]";
202                         if ($cmdline =~ /$str/) {
203                                 $self->{priv} = $self->{user}->priv;
204                         } else {
205                                 $self->send($self->msg('sorry'));
206                         }
207                 } else {
208                         $self->send($self->msg('sorry'));
209                 }
210                 delete $self->{passwd};
211                 $self->state('prompt');
212         } elsif ($self->{state} eq 'talk') {
213                 if ($cmdline =~ m{^(?:/EX|/ABORT)}i) {
214                         for (@{$self->{talklist}}) {
215                                 $self->send_talks($_,  $self->msg('talkend'));
216                         }
217                         $self->state('prompt');
218                         delete $self->{talklist};
219                 } elsif ($cmdline =~ m(^/\w+)) {
220                         $cmdline =~ s(^/)();
221                         $self->send_ans(run_cmd($self, $cmdline));
222                         $self->send($self->talk_prompt);
223                 } elsif ($self->{talklist} && @{$self->{talklist}}) {
224                         # send what has been said to whoever is in this person's talk list
225                         my @bad;
226                         if (@bad = BadWords::check($cmdline)) {
227                                 $self->badcount(($self->badcount||0) + @bad);
228                                 Log('DXCommand', "$self->{call} swore: $cmdline");
229                         } else {
230                                 for (@{$self->{talklist}}) {
231                                         $self->send_talks($_, $cmdline);
232                                 }
233                         }
234                         $self->send($self->talk_prompt) if $self->{state} eq 'talk';
235                 } else {
236                         # for safety
237                         $self->state('prompt');
238                 }
239         } elsif (my $func = $self->{func}) {
240                 no strict 'refs';
241                 my @ans;
242                 if (ref $self->{edit}) {
243                         eval { @ans = $self->{edit}->$func($self, $cmdline)};
244                 } else {
245                         eval {  @ans = &{$self->{func}}($self, $cmdline) };
246                 }
247                 $self->send_ans("Syserr: on stored func $self->{func}", $@) if $@;
248                 $self->send_ans(@ans);
249         } else {
250                 $self->send_ans(run_cmd($self, $cmdline));
251         } 
252
253         # check for excessive swearing
254         if ($self->{badcount} && $self->{badcount} >= $maxbadcount) {
255                 Log('DXCommand', "$self->{call} logged out for excessive swearing");
256                 $self->disconnect;
257                 return;
258         }
259
260         # send a prompt only if we are in a prompt state
261         $self->prompt() if $self->{state} =~ /^prompt/o;
262 }
263
264 # send out the talk messages taking into account vias and connectivity
265 sub send_talks
266 {
267         my ($self, $ent, $line) = @_;
268         
269         my ($to, $via) = $ent =~ /(\S+)>(\S+)/;
270         $to = $ent unless $to;
271         my $call = $via ? $via : $to;
272         my $clref = Route::get($call);
273         my $dxchan = $clref->dxchan if $clref;
274         if ($dxchan) {
275                 $dxchan->talk($self->{call}, $to, $via, $line);
276         } else {
277                 $self->send($self->msg('disc2', $via ? $via : $to));
278                 my @l = grep { $_ ne $ent } @{$self->{talklist}};
279                 if (@l) {
280                         $self->{talklist} = \@l;
281                 } else {
282                         delete $self->{talklist};
283                         $self->state('prompt');
284                 }
285         }
286 }
287
288 sub talk_prompt
289 {
290         my $self = shift;
291         my @call;
292         for (@{$self->{talklist}}) {
293                 my ($to, $via) = /(\S+)>(\S+)/;
294                 $to = $_ unless $to;
295                 push @call, $to;
296         }
297         return $self->msg('talkprompt', join(',', @call));
298 }
299
300 #
301 # send a load of stuff to a command user with page prompting
302 # and stuff
303 #
304
305 sub send_ans
306 {
307         my $self = shift;
308         
309         if ($self->{pagelth} && @_ > $self->{pagelth}) {
310                 my $i;
311                 for ($i = $self->{pagelth}; $i-- > 0; ) {
312                         my $line = shift @_;
313                         $line =~ s/\s+$//o;     # why am having to do this? 
314                         $self->send($line);
315                 }
316                 $self->{pagedata} =  [ @_ ];
317                 $self->state('page');
318                 $self->send($self->msg('page', scalar @_));
319         } else {
320                 for (@_) {
321                         if (defined $_) {
322                                 $self->send($_);
323                         } else {
324                                 $self->send('');
325                         }
326                 }
327         } 
328 }
329
330 # this is the thing that runs the command, it is done like this for the 
331 # benefit of remote command execution
332 #
333
334 sub run_cmd
335 {
336         my $self = shift;
337         my $user = $self->{user};
338         my $call = $self->{call};
339         my $cmdline = shift;
340         my @ans;
341         
342
343         return () if length $cmdline == 0;
344                 
345         # strip out //
346         $cmdline =~ s|//|/|og;
347                 
348         # split the command line up into parts, the first part is the command
349         my ($cmd, $args) = split /\s+/, $cmdline, 2;
350         $args = "" unless defined $args;
351                 
352         if ($cmd) {
353                         
354                 my ($path, $fcmd);
355                         
356                 dbg("cmd: $cmd") if isdbg('command');
357                         
358                 # alias it if possible
359                 my $acmd = CmdAlias::get_cmd($cmd);
360                 if ($acmd) {
361                         ($cmd, $args) = split /\s+/, "$acmd $args", 2;
362                         $args = "" unless defined $args;
363                         dbg("aliased cmd: $cmd $args") if isdbg('command');
364                 }
365                         
366                 # first expand out the entry to a command
367                 ($path, $fcmd) = search($main::localcmd, $cmd, "pl");
368                 ($path, $fcmd) = search($main::cmd, $cmd, "pl") if !$path || !$fcmd;
369
370                 if ($path && $cmd) {
371                         dbg("path: $cmd cmd: $fcmd") if isdbg('command');
372                         
373                         my $package = find_cmd_name($path, $fcmd);
374                         return ($@) if $@;
375                                 
376                         if ($package) {
377                                 no strict 'refs';
378                                 dbg("package: $package") if isdbg('command');
379                                 eval { @ans = &$package($self, $args) };
380                                 return (DXDebug::shortmess($@)) if $@;
381                         }
382                 } else {
383                         dbg("cmd: $cmd not found") if isdbg('command');
384                         if (++$self->{errors} > $maxerrors) {
385                                 $self->send($self->msg('e26'));
386                                 $self->disconnect;
387                                 return ();
388                         } else {
389                                 return ($self->msg('e1'));
390                         }
391                 }
392         }
393         
394         my $ok = shift @ans;
395         if ($ok) {
396                 delete $self->{errors};
397         } else {
398                 if (++$self->{errors} > $maxerrors) {
399                         $self->send($self->msg('e26'));
400                         $self->disconnect;
401                         return ();
402                 }
403         }
404         return (@ans);
405 }
406
407 #
408 # This is called from inside the main cluster processing loop and is used
409 # for despatching commands that are doing some long processing job
410 #
411 sub process
412 {
413         my $t = time;
414         my @dxchan = DXChannel->get_all();
415         my $dxchan;
416         
417         foreach $dxchan (@dxchan) {
418                 next if $dxchan->sort ne 'U';  
419                 
420                 # send a prompt if no activity out on this channel
421                 if ($t >= $dxchan->t + $main::user_interval) {
422                         $dxchan->prompt() if $dxchan->{state} =~ /^prompt/o;
423                         $dxchan->t($t);
424                 }
425         }
426
427         while (my ($k, $v) = each %nothereslug) {
428                 if ($main::systime >= $v + 300) {
429                         delete $nothereslug{$k};
430                 }
431         }
432 }
433
434 #
435 # finish up a user context
436 #
437 sub disconnect
438 {
439         my $self = shift;
440         my $call = $self->call;
441
442         return if $self->{disconnecting}++;
443
444         delete $self->{senddbg};
445
446         my $uref = Route::User::get($call);
447         my @rout;
448         if ($uref) {
449                 @rout = $main::routeroot->del_user($uref);
450                 dbg("B/C PC17 on $main::mycall for: $call") if isdbg('route');
451         } else {
452                 confess "trying to disconnect a non existant user $call";
453         }
454
455         # issue a pc17 to everybody interested
456         DXProt::route_pc17($main::me, $main::routeroot, @rout) if @rout;
457
458         # I was the last node visited
459     $self->user->node($main::mycall);
460                 
461         # send info to all logged in thingies
462         $self->tell_login('logoutu');
463
464         Log('DXCommand', "$call disconnected");
465
466         $self->SUPER::disconnect;
467 }
468
469 #
470 # short cut to output a prompt
471 #
472
473 sub prompt
474 {
475         my $self = shift;
476         $self->send($self->msg($self->here ? 'pr' : 'pr2', $self->call, cldate($main::systime), ztime($main::systime)));
477 }
478
479 # broadcast a message to all users [except those mentioned after buffer]
480 sub broadcast
481 {
482         my $pkg = shift;                        # ignored
483         my $s = shift;                          # the line to be rebroadcast
484         
485     foreach my $dxchan (DXChannel->get_all()) {
486                 next unless $dxchan->{sort} eq 'U'; # only interested in user channels  
487                 next if grep $dxchan == $_, @_;
488                 $dxchan->send($s);                      # send it
489         }
490 }
491
492 # gimme all the users
493 sub get_all
494 {
495         return grep {$_->{sort} eq 'U'} DXChannel->get_all();
496 }
497
498 # run a script for this user
499 sub run_script
500 {
501         my $self = shift;
502         my $silent = shift || 0;
503         
504 }
505
506 #
507 # search for the command in the cache of short->long form commands
508 #
509
510 sub search
511 {
512         my ($path, $short_cmd, $suffix) = @_;
513         my ($apath, $acmd);
514         
515         # commands are lower case
516         $short_cmd = lc $short_cmd;
517         dbg("command: $path $short_cmd\n") if isdbg('command');
518
519         # do some checking for funny characters
520         return () if $short_cmd =~ /\/$/;
521
522         # return immediately if we have it
523         ($apath, $acmd) = split ',', $cmd_cache{$short_cmd} if $cmd_cache{$short_cmd};
524         if ($apath && $acmd) {
525                 dbg("cached $short_cmd = ($apath, $acmd)\n") if isdbg('command');
526                 return ($apath, $acmd);
527         }
528         
529         # if not guess
530         my @parts = split '/', $short_cmd;
531         my $dirfn;
532         my $curdir = $path;
533         my $p;
534         my $i;
535         my @lparts;
536         
537         for ($i = 0; $i < @parts; $i++) {
538                 my  $p = $parts[$i];
539                 opendir(D, $curdir) or confess "can't open $curdir $!";
540                 my @ls = readdir D;
541                 closedir D;
542                 my $l;
543                 foreach $l (sort @ls) {
544                         next if $l =~ /^\./;
545                         if ($i < $#parts) {             # we are dealing with directories
546                                 if ((-d "$curdir/$l") && $p eq substr($l, 0, length $p)) {
547                                         dbg("got dir: $curdir/$l\n") if isdbg('command');
548                                         $dirfn .= "$l/";
549                                         $curdir .= "/$l";
550                                         last;
551                                 }
552                         } else {                        # we are dealing with commands
553                                 @lparts = split /\./, $l;                  
554                                 next if $lparts[$#lparts] ne $suffix;        # only look for .$suffix files
555                                 if ($p eq substr($l, 0, length $p)) {
556                                         pop @lparts; #  remove the suffix
557                                         $l = join '.', @lparts;
558                                         #                 chop $dirfn;               # remove trailing /
559                                         $dirfn = "" unless $dirfn;
560                                         $cmd_cache{$short_cmd} = join(',', ($path, "$dirfn$l")); # cache it
561                                         dbg("got path: $path cmd: $dirfn$l\n") if isdbg('command');
562                                         return ($path, "$dirfn$l"); 
563                                 }
564                         }
565                 }
566         }
567         return ();  
568 }  
569
570 # clear the command name cache
571 sub clear_cmd_cache
572 {
573         no strict 'refs';
574         
575         for (keys %Cache) {
576                 undef *{$_};
577                 dbg("Undefining cmd $_") if isdbg('command');
578         }
579         %cmd_cache = ();
580         %Cache = ();
581 }
582
583 #
584 # the persistant execution of things from the command directories
585 #
586 #
587 # This allows perl programs to call functions dynamically
588
589 # This has been nicked directly from the perlembed pages
590 #
591
592 #require Devel::Symdump;  
593
594 sub valid_package_name {
595         my($string) = @_;
596         $string =~ s|([^A-Za-z0-9_/])|sprintf("_%2x",unpack("C",$1))|eg;
597         
598         $string =~ s|/|_|g;
599         return "cmd_$string";
600 }
601
602
603 # this bit of magic finds a command in the offered directory
604 sub find_cmd_name {
605         my $path = shift;
606         my $cmdname = shift;
607         my $package = valid_package_name($cmdname);
608         my $filename = "$path/$cmdname.pl";
609         my $mtime = -M $filename;
610         
611         # return if we can't find it
612         $errstr = undef;
613         unless (defined $mtime) {
614                 $errstr = DXM::msg('e1');
615                 return undef;
616         }
617         
618         if(defined $Cache{$package}->{mtime} &&$Cache{$package}->{mtime} <= $mtime) {
619                 #we have compiled this subroutine already,
620                 #it has not been updated on disk, nothing left to do
621                 #print STDERR "already compiled $package->handler\n";
622                 ;
623         } else {
624
625                 my $sub = readfilestr($filename);
626                 unless ($sub) {
627                         $errstr = "Syserr: can't open '$filename' $!";
628                         return undef;
629                 };
630                 
631                 #wrap the code into a subroutine inside our unique package
632                 my $eval = qq( sub $package { $sub } );
633                 
634                 if (isdbg('eval')) {
635                         my @list = split /\n/, $eval;
636                         my $line;
637                         for (@list) {
638                                 dbg($_ . "\n") if isdbg('eval');
639                         }
640                 }
641                 
642                 # get rid of any existing sub and try to compile the new one
643                 no strict 'refs';
644
645                 if (exists $Cache{$package}) {
646                         dbg("Redefining $package") if isdbg('command');
647                         undef *$package;
648                 } else {
649                         dbg("Defining $package") if isdbg('command');
650                 }
651                 eval $eval;
652                 
653                 $Cache{$package} = {mtime => $mtime };
654             
655         }
656
657         return $package;
658 }
659
660 sub local_send
661 {
662         my ($self, $let, $buf) = @_;
663         if ($self->{state} eq 'prompt' || $self->{state} eq 'talk') {
664                 if ($self->{enhanced}) {
665                         $self->send_later($let, $buf);
666                 } else {
667                         $self->send($buf);
668                 }
669         } else {
670                 $self->delay($buf);
671         }
672 }
673
674 # send a talk message here
675 sub talk
676 {
677         my ($self, $from, $to, $via, $line) = @_;
678         $line =~ s/\\5E/\^/g;
679         $self->local_send('T', "$to de $from: $line") if $self->{talk};
680         Log('talk', $to, $from, $main::mycall, $line);
681         # send a 'not here' message if required
682         unless ($self->{here} && $from ne $to) {
683                 my $key = "$to$from";
684                 unless (exists $nothereslug{$key}) {
685                         my ($ref, $dxchan);
686                         if (($ref = Route::get($from)) && ($dxchan = $ref->dxchan)) {
687                                 my $name = $self->user->name || $to;
688                                 my $s = $self->user->nothere || $dxchan->msg('nothere', $name);
689                                 $nothereslug{$key} = $main::systime;
690                                 $dxchan->talk($to, $from, undef, $s);
691                         }
692                 }
693         }
694 }
695
696 # send an announce
697 sub announce
698 {
699         my $self = shift;
700         my $line = shift;
701         my $isolate = shift;
702         my $to = shift;
703         my $target = shift;
704         my $text = shift;
705         my ($filter, $hops);
706
707         if (!$self->{ann_talk} && $to ne $self->{call}) {
708                 my $call = AnnTalk::is_talk_candidate($_[0], $text);
709                 return if $call;
710         }
711
712         if ($self->{annfilter}) {
713                 ($filter, $hops) = $self->{annfilter}->it(@_ );
714                 return unless $filter;
715         }
716
717         unless ($self->{ann}) {
718                 return if $_[0] ne $main::myalias && $_[0] ne $main::mycall;
719         }
720         return if $target eq 'SYSOP' && $self->{priv} < 5;
721         my $buf = "$to$target de $_[0]: $text";
722         $buf =~ s/\%5E/^/g;
723         $buf .= "\a\a" if $self->{beep};
724         $self->local_send($target eq 'WX' ? 'W' : 'N', $buf);
725 }
726
727 # send a dx spot
728 sub dx_spot
729 {
730         my $self = shift;
731         my $line = shift;
732         my $isolate = shift;
733         my ($filter, $hops);
734
735         return unless $self->{dx};
736         
737         if ($self->{spotsfilter}) {
738                 ($filter, $hops) = $self->{spotsfilter}->it(@_ );
739                 return unless $filter;
740         }
741
742         my $buf = Spot::formatb($self->{user}->wantgrid, $_[0], $_[1], $_[2], $_[3], $_[4]);
743         $buf .= "\a\a" if $self->{beep};
744         $buf =~ s/\%5E/^/g;
745         $self->local_send('X', $buf);
746 }
747
748 sub wwv
749 {
750         my $self = shift;
751         my $line = shift;
752         my $isolate = shift;
753         my ($filter, $hops);
754
755         return unless $self->{wwv};
756         
757         if ($self->{wwvfilter}) {
758                 ($filter, $hops) = $self->{wwvfilter}->it(@_ );
759                 return unless $filter;
760         }
761
762         my $buf = "WWV de $_[6] <$_[1]>:   SFI=$_[2], A=$_[3], K=$_[4], $_[5]";
763         $buf .= "\a\a" if $self->{beep};
764         $self->local_send('V', $buf);
765 }
766
767 sub wcy
768 {
769         my $self = shift;
770         my $line = shift;
771         my $isolate = shift;
772         my ($filter, $hops);
773
774         return unless $self->{wcy};
775         
776         if ($self->{wcyfilter}) {
777                 ($filter, $hops) = $self->{wcyfilter}->it(@_ );
778                 return unless $filter;
779         }
780
781         my $buf = "WCY de $_[10] <$_[1]> : K=$_[4] expK=$_[5] A=$_[3] R=$_[6] SFI=$_[2] SA=$_[7] GMF=$_[8] Au=$_[9]";
782         $buf .= "\a\a" if $self->{beep};
783         $self->local_send('Y', $buf);
784 }
785
786 # broadcast debug stuff to all interested parties
787 sub broadcast_debug
788 {
789         my $s = shift;                          # the line to be rebroadcast
790         
791         foreach my $dxchan (DXChannel->get_all) {
792                 next unless $dxchan->{enhanced} && $dxchan->{senddbg};
793                 $dxchan->send_later('L', $s);
794         }
795 }
796
797
798 1;
799 __END__