add if you swear 3 or more times you are unceremoniously logged out
[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                         for (@{$self->{talklist}}) {
226                                 $self->send_talks($_, $cmdline);
227                         }
228                         $self->send($self->talk_prompt) if $self->{state} eq 'talk';
229                 } else {
230                         # for safety
231                         $self->state('prompt');
232                 }
233         } elsif (my $func = $self->{func}) {
234                 no strict 'refs';
235                 my @ans;
236                 if (ref $self->{edit}) {
237                         eval { @ans = $self->{edit}->$func($self, $cmdline)};
238                 } else {
239                         eval {  @ans = &{$self->{func}}($self, $cmdline) };
240                 }
241                 $self->send_ans("Syserr: on stored func $self->{func}", $@) if $@;
242                 $self->send_ans(@ans);
243         } else {
244                 $self->send_ans(run_cmd($self, $cmdline));
245         } 
246
247         # check for excessive swearing
248         if ($self->{badcount} && $self->{badcount} >= $maxbadcount) {
249                 Log('DXCommand', "$self->{call} logged out for excessive swearing");
250                 $self->disconnect;
251                 return;
252         }
253
254         # send a prompt only if we are in a prompt state
255         $self->prompt() if $self->{state} =~ /^prompt/o;
256 }
257
258 # send out the talk messages taking into account vias and connectivity
259 sub send_talks
260 {
261         my ($self, $ent, $line) = @_;
262         
263         my ($to, $via) = $ent =~ /(\S+)>(\S+)/;
264         $to = $ent unless $to;
265         my $call = $via ? $via : $to;
266         my $clref = Route::get($call);
267         my $dxchan = $clref->dxchan if $clref;
268         if ($dxchan) {
269                 $dxchan->talk($self->{call}, $to, $via, $line);
270         } else {
271                 $self->send($self->msg('disc2', $via ? $via : $to));
272                 my @l = grep { $_ ne $ent } @{$self->{talklist}};
273                 if (@l) {
274                         $self->{talklist} = \@l;
275                 } else {
276                         delete $self->{talklist};
277                         $self->state('prompt');
278                 }
279         }
280 }
281
282 sub talk_prompt
283 {
284         my $self = shift;
285         my @call;
286         for (@{$self->{talklist}}) {
287                 my ($to, $via) = /(\S+)>(\S+)/;
288                 $to = $_ unless $to;
289                 push @call, $to;
290         }
291         return $self->msg('talkprompt', join(',', @call));
292 }
293
294 #
295 # send a load of stuff to a command user with page prompting
296 # and stuff
297 #
298
299 sub send_ans
300 {
301         my $self = shift;
302         
303         if ($self->{pagelth} && @_ > $self->{pagelth}) {
304                 my $i;
305                 for ($i = $self->{pagelth}; $i-- > 0; ) {
306                         my $line = shift @_;
307                         $line =~ s/\s+$//o;     # why am having to do this? 
308                         $self->send($line);
309                 }
310                 $self->{pagedata} =  [ @_ ];
311                 $self->state('page');
312                 $self->send($self->msg('page', scalar @_));
313         } else {
314                 for (@_) {
315                         if (defined $_) {
316                                 $self->send($_);
317                         } else {
318                                 $self->send('');
319                         }
320                 }
321         } 
322 }
323
324 # this is the thing that runs the command, it is done like this for the 
325 # benefit of remote command execution
326 #
327
328 sub run_cmd
329 {
330         my $self = shift;
331         my $user = $self->{user};
332         my $call = $self->{call};
333         my $cmdline = shift;
334         my @ans;
335         
336
337         return () if length $cmdline == 0;
338                 
339         # strip out //
340         $cmdline =~ s|//|/|og;
341                 
342         # split the command line up into parts, the first part is the command
343         my ($cmd, $args) = split /\s+/, $cmdline, 2;
344         $args = "" unless defined $args;
345                 
346         if ($cmd) {
347                         
348                 my ($path, $fcmd);
349                         
350                 dbg("cmd: $cmd") if isdbg('command');
351                         
352                 # alias it if possible
353                 my $acmd = CmdAlias::get_cmd($cmd);
354                 if ($acmd) {
355                         ($cmd, $args) = split /\s+/, "$acmd $args", 2;
356                         $args = "" unless defined $args;
357                         dbg("aliased cmd: $cmd $args") if isdbg('command');
358                 }
359                         
360                 # first expand out the entry to a command
361                 ($path, $fcmd) = search($main::localcmd, $cmd, "pl");
362                 ($path, $fcmd) = search($main::cmd, $cmd, "pl") if !$path || !$fcmd;
363
364                 if ($path && $cmd) {
365                         dbg("path: $cmd cmd: $fcmd") if isdbg('command');
366                         
367                         my $package = find_cmd_name($path, $fcmd);
368                         return ($@) if $@;
369                                 
370                         if ($package) {
371                                 no strict 'refs';
372                                 dbg("package: $package") if isdbg('command');
373                                 eval { @ans = &$package($self, $args) };
374                                 return (DXDebug::shortmess($@)) if $@;
375                         }
376                 } else {
377                         dbg("cmd: $cmd not found") if isdbg('command');
378                         if (++$self->{errors} > $maxerrors) {
379                                 $self->send($self->msg('e26'));
380                                 $self->disconnect;
381                                 return ();
382                         } else {
383                                 return ($self->msg('e1'));
384                         }
385                 }
386         }
387         
388         my $ok = shift @ans;
389         if ($ok) {
390                 delete $self->{errors};
391         } else {
392                 if (++$self->{errors} > $maxerrors) {
393                         $self->send($self->msg('e26'));
394                         $self->disconnect;
395                         return ();
396                 }
397         }
398         return (@ans);
399 }
400
401 #
402 # This is called from inside the main cluster processing loop and is used
403 # for despatching commands that are doing some long processing job
404 #
405 sub process
406 {
407         my $t = time;
408         my @dxchan = DXChannel->get_all();
409         my $dxchan;
410         
411         foreach $dxchan (@dxchan) {
412                 next if $dxchan->sort ne 'U';  
413                 
414                 # send a prompt if no activity out on this channel
415                 if ($t >= $dxchan->t + $main::user_interval) {
416                         $dxchan->prompt() if $dxchan->{state} =~ /^prompt/o;
417                         $dxchan->t($t);
418                 }
419         }
420
421         while (my ($k, $v) = each %nothereslug) {
422                 if ($main::systime >= $v + 300) {
423                         delete $nothereslug{$k};
424                 }
425         }
426 }
427
428 #
429 # finish up a user context
430 #
431 sub disconnect
432 {
433         my $self = shift;
434         my $call = $self->call;
435
436         return if $self->{disconnecting}++;
437
438         delete $self->{senddbg};
439
440         my $uref = Route::User::get($call);
441         my @rout;
442         if ($uref) {
443                 @rout = $main::routeroot->del_user($uref);
444                 dbg("B/C PC17 on $main::mycall for: $call") if isdbg('route');
445         } else {
446                 confess "trying to disconnect a non existant user $call";
447         }
448
449         # issue a pc17 to everybody interested
450         DXProt::route_pc17($main::me, $main::routeroot, @rout) if @rout;
451
452         # I was the last node visited
453     $self->user->node($main::mycall);
454                 
455         # send info to all logged in thingies
456         $self->tell_login('logoutu');
457
458         Log('DXCommand', "$call disconnected");
459
460         $self->SUPER::disconnect;
461 }
462
463 #
464 # short cut to output a prompt
465 #
466
467 sub prompt
468 {
469         my $self = shift;
470         $self->send($self->msg($self->here ? 'pr' : 'pr2', $self->call, cldate($main::systime), ztime($main::systime)));
471 }
472
473 # broadcast a message to all users [except those mentioned after buffer]
474 sub broadcast
475 {
476         my $pkg = shift;                        # ignored
477         my $s = shift;                          # the line to be rebroadcast
478         
479     foreach my $dxchan (DXChannel->get_all()) {
480                 next unless $dxchan->{sort} eq 'U'; # only interested in user channels  
481                 next if grep $dxchan == $_, @_;
482                 $dxchan->send($s);                      # send it
483         }
484 }
485
486 # gimme all the users
487 sub get_all
488 {
489         return grep {$_->{sort} eq 'U'} DXChannel->get_all();
490 }
491
492 # run a script for this user
493 sub run_script
494 {
495         my $self = shift;
496         my $silent = shift || 0;
497         
498 }
499
500 #
501 # search for the command in the cache of short->long form commands
502 #
503
504 sub search
505 {
506         my ($path, $short_cmd, $suffix) = @_;
507         my ($apath, $acmd);
508         
509         # commands are lower case
510         $short_cmd = lc $short_cmd;
511         dbg("command: $path $short_cmd\n") if isdbg('command');
512
513         # do some checking for funny characters
514         return () if $short_cmd =~ /\/$/;
515
516         # return immediately if we have it
517         ($apath, $acmd) = split ',', $cmd_cache{$short_cmd} if $cmd_cache{$short_cmd};
518         if ($apath && $acmd) {
519                 dbg("cached $short_cmd = ($apath, $acmd)\n") if isdbg('command');
520                 return ($apath, $acmd);
521         }
522         
523         # if not guess
524         my @parts = split '/', $short_cmd;
525         my $dirfn;
526         my $curdir = $path;
527         my $p;
528         my $i;
529         my @lparts;
530         
531         for ($i = 0; $i < @parts; $i++) {
532                 my  $p = $parts[$i];
533                 opendir(D, $curdir) or confess "can't open $curdir $!";
534                 my @ls = readdir D;
535                 closedir D;
536                 my $l;
537                 foreach $l (sort @ls) {
538                         next if $l =~ /^\./;
539                         if ($i < $#parts) {             # we are dealing with directories
540                                 if ((-d "$curdir/$l") && $p eq substr($l, 0, length $p)) {
541                                         dbg("got dir: $curdir/$l\n") if isdbg('command');
542                                         $dirfn .= "$l/";
543                                         $curdir .= "/$l";
544                                         last;
545                                 }
546                         } else {                        # we are dealing with commands
547                                 @lparts = split /\./, $l;                  
548                                 next if $lparts[$#lparts] ne $suffix;        # only look for .$suffix files
549                                 if ($p eq substr($l, 0, length $p)) {
550                                         pop @lparts; #  remove the suffix
551                                         $l = join '.', @lparts;
552                                         #                 chop $dirfn;               # remove trailing /
553                                         $dirfn = "" unless $dirfn;
554                                         $cmd_cache{$short_cmd} = join(',', ($path, "$dirfn$l")); # cache it
555                                         dbg("got path: $path cmd: $dirfn$l\n") if isdbg('command');
556                                         return ($path, "$dirfn$l"); 
557                                 }
558                         }
559                 }
560         }
561         return ();  
562 }  
563
564 # clear the command name cache
565 sub clear_cmd_cache
566 {
567         no strict 'refs';
568         
569         for (keys %Cache) {
570                 undef *{$_};
571                 dbg("Undefining cmd $_") if isdbg('command');
572         }
573         %cmd_cache = ();
574         %Cache = ();
575 }
576
577 #
578 # the persistant execution of things from the command directories
579 #
580 #
581 # This allows perl programs to call functions dynamically
582
583 # This has been nicked directly from the perlembed pages
584 #
585
586 #require Devel::Symdump;  
587
588 sub valid_package_name {
589         my($string) = @_;
590         $string =~ s|([^A-Za-z0-9_/])|sprintf("_%2x",unpack("C",$1))|eg;
591         
592         $string =~ s|/|_|g;
593         return "cmd_$string";
594 }
595
596
597 # this bit of magic finds a command in the offered directory
598 sub find_cmd_name {
599         my $path = shift;
600         my $cmdname = shift;
601         my $package = valid_package_name($cmdname);
602         my $filename = "$path/$cmdname.pl";
603         my $mtime = -M $filename;
604         
605         # return if we can't find it
606         $errstr = undef;
607         unless (defined $mtime) {
608                 $errstr = DXM::msg('e1');
609                 return undef;
610         }
611         
612         if(defined $Cache{$package}->{mtime} &&$Cache{$package}->{mtime} <= $mtime) {
613                 #we have compiled this subroutine already,
614                 #it has not been updated on disk, nothing left to do
615                 #print STDERR "already compiled $package->handler\n";
616                 ;
617         } else {
618
619                 my $sub = readfilestr($filename);
620                 unless ($sub) {
621                         $errstr = "Syserr: can't open '$filename' $!";
622                         return undef;
623                 };
624                 
625                 #wrap the code into a subroutine inside our unique package
626                 my $eval = qq( sub $package { $sub } );
627                 
628                 if (isdbg('eval')) {
629                         my @list = split /\n/, $eval;
630                         my $line;
631                         for (@list) {
632                                 dbg($_ . "\n") if isdbg('eval');
633                         }
634                 }
635                 
636                 # get rid of any existing sub and try to compile the new one
637                 no strict 'refs';
638
639                 if (exists $Cache{$package}) {
640                         dbg("Redefining $package") if isdbg('command');
641                         undef *$package;
642                 } else {
643                         dbg("Defining $package") if isdbg('command');
644                 }
645                 eval $eval;
646                 
647                 $Cache{$package} = {mtime => $mtime };
648             
649         }
650
651         return $package;
652 }
653
654 sub local_send
655 {
656         my ($self, $let, $buf) = @_;
657         if ($self->{state} eq 'prompt' || $self->{state} eq 'talk') {
658                 if ($self->{enhanced}) {
659                         $self->send_later($let, $buf);
660                 } else {
661                         $self->send($buf);
662                 }
663         } else {
664                 $self->delay($buf);
665         }
666 }
667
668 # send a talk message here
669 sub talk
670 {
671         my ($self, $from, $to, $via, $line) = @_;
672         $line =~ s/\\5E/\^/g;
673         $self->local_send('T', "$to de $from: $line") if $self->{talk};
674         Log('talk', $to, $from, $main::mycall, $line);
675         # send a 'not here' message if required
676         unless ($self->{here} && $from ne $to) {
677                 my $key = "$to$from";
678                 unless (exists $nothereslug{$key}) {
679                         my ($ref, $dxchan);
680                         if (($ref = Route::get($from)) && ($dxchan = $ref->dxchan)) {
681                                 my $name = $self->user->name || $to;
682                                 my $s = $self->user->nothere || $dxchan->msg('nothere', $name);
683                                 $nothereslug{$key} = $main::systime;
684                                 $dxchan->talk($to, $from, undef, $s);
685                         }
686                 }
687         }
688 }
689
690 # send an announce
691 sub announce
692 {
693         my $self = shift;
694         my $line = shift;
695         my $isolate = shift;
696         my $to = shift;
697         my $target = shift;
698         my $text = shift;
699         my ($filter, $hops);
700
701         if (!$self->{ann_talk} && $to ne $self->{call}) {
702                 my $call = AnnTalk::is_talk_candidate($_[0], $text);
703                 return if $call;
704         }
705
706         if ($self->{annfilter}) {
707                 ($filter, $hops) = $self->{annfilter}->it(@_ );
708                 return unless $filter;
709         }
710
711         unless ($self->{ann}) {
712                 return if $_[0] ne $main::myalias && $_[0] ne $main::mycall;
713         }
714         return if $target eq 'SYSOP' && $self->{priv} < 5;
715         my $buf = "$to$target de $_[0]: $text";
716         $buf =~ s/\%5E/^/g;
717         $buf .= "\a\a" if $self->{beep};
718         $self->local_send($target eq 'WX' ? 'W' : 'N', $buf);
719 }
720
721 # send a dx spot
722 sub dx_spot
723 {
724         my $self = shift;
725         my $line = shift;
726         my $isolate = shift;
727         my ($filter, $hops);
728
729         return unless $self->{dx};
730         
731         if ($self->{spotsfilter}) {
732                 ($filter, $hops) = $self->{spotsfilter}->it(@_ );
733                 return unless $filter;
734         }
735
736         my $buf = Spot::formatb($self->{user}->wantgrid, $_[0], $_[1], $_[2], $_[3], $_[4]);
737         $buf .= "\a\a" if $self->{beep};
738         $buf =~ s/\%5E/^/g;
739         $self->local_send('X', $buf);
740 }
741
742 sub wwv
743 {
744         my $self = shift;
745         my $line = shift;
746         my $isolate = shift;
747         my ($filter, $hops);
748
749         return unless $self->{wwv};
750         
751         if ($self->{wwvfilter}) {
752                 ($filter, $hops) = $self->{wwvfilter}->it(@_ );
753                 return unless $filter;
754         }
755
756         my $buf = "WWV de $_[6] <$_[1]>:   SFI=$_[2], A=$_[3], K=$_[4], $_[5]";
757         $buf .= "\a\a" if $self->{beep};
758         $self->local_send('V', $buf);
759 }
760
761 sub wcy
762 {
763         my $self = shift;
764         my $line = shift;
765         my $isolate = shift;
766         my ($filter, $hops);
767
768         return unless $self->{wcy};
769         
770         if ($self->{wcyfilter}) {
771                 ($filter, $hops) = $self->{wcyfilter}->it(@_ );
772                 return unless $filter;
773         }
774
775         my $buf = "WCY de $_[10] <$_[1]> : K=$_[4] expK=$_[5] A=$_[3] R=$_[6] SFI=$_[2] SA=$_[7] GMF=$_[8] Au=$_[9]";
776         $buf .= "\a\a" if $self->{beep};
777         $self->local_send('Y', $buf);
778 }
779
780 # broadcast debug stuff to all interested parties
781 sub broadcast_debug
782 {
783         my $s = shift;                          # the line to be rebroadcast
784         
785         foreach my $dxchan (DXChannel->get_all) {
786                 next unless $dxchan->{enhanced} && $dxchan->{senddbg};
787                 $dxchan->send_later('L', $s);
788         }
789 }
790
791
792 1;
793 __END__