X-Git-Url: http://dxcluster.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FDXCommandmode.pm;h=a8418bd4daf0af368947b188f8c30a534279f26d;hb=ace0278fbe041182bec5fc536ade55647145994b;hp=f00163297e43d367abf0d8ef249d25a3e8278129;hpb=2b58ccdf81685a1167a43c38705a0d84b9d8d661;p=spider.git diff --git a/perl/DXCommandmode.pm b/perl/DXCommandmode.pm index f0016329..a8418bd4 100644 --- a/perl/DXCommandmode.pm +++ b/perl/DXCommandmode.pm @@ -30,6 +30,8 @@ use AnnTalk; use WCY; use Sun; use Internet; +use Script; + use strict; use vars qw(%Cache %cmd_cache $errstr %aliases $scriptbase $maxerrors %nothereslug); @@ -59,7 +61,7 @@ sub new my $pkg = shift; my $call = shift; my @rout = $main::routeroot->add_user($call, Route::here(1)); - DXProt::route_pc16($DXProt::me, $main::routeroot, @rout) if @rout; + DXProt::route_pc16($main::me, $main::routeroot, @rout) if @rout; return $self; } @@ -75,6 +77,10 @@ sub start my $call = $self->{call}; my $name = $user->{name}; + # log it + my $host = $self->{conn}->{peerhost} || "unknown"; + Log('DXCommand', "$call connected from $host"); + $self->{name} = $name ? $name : $call; $self->send($self->msg('l2',$self->{name})); $self->send_file($main::motd) if (-e $main::motd); @@ -83,6 +89,8 @@ sub start $self->{lang} = $user->lang || $main::lang || 'en'; $self->{pagelth} = $user->pagelth || 20; $self->{priv} = 0 if $line =~ /^(ax|te)/; # set the connection priv to 0 - can be upgraded later + ($self->{width}) = $line =~ /width=(\d+)/; + $self->{width} = 80 unless $self->{width} && $self->{width} > 80; $self->{consort} = $line; # save the connection type # set some necessary flags on the user if they are connecting @@ -94,6 +102,7 @@ sub start $self->{wx} = $user->wantwx; $self->{dx} = $user->wantdx; $self->{logininfo} = $user->wantlogininfo; + $self->{ann_talk} = $user->wantann_talk; $self->{here} = 1; # get the filters @@ -111,18 +120,6 @@ sub start $user->qra(DXBearing::lltoqra($lat, $long)) if (defined $lat && defined $long); } - Log('DXCommand', "$call connected"); - - # send prompts and things - my $info = Route::cluster(); - $self->send("Cluster:$info"); - $self->send($self->msg('namee1')) if !$user->name; - $self->send($self->msg('qthe1')) if !$user->qth; - $self->send($self->msg('qll')) if !$user->qra || (!$user->lat && !$user->long); - $self->send($self->msg('hnodee1')) if !$user->qth; - $self->send($self->msg('m9')) if DXMsg::for_me($call); - $self->prompt; - # decide on echo if (!$user->wantecho) { $self->send_now('E', "0"); @@ -135,9 +132,25 @@ sub start my $lastoper = $user->lastoper || 0; my $homenode = $user->homenode || ""; if ($homenode eq $main::mycall && $lastoper + $DXUser::lastoperinterval < $main::systime) { - run_cmd($DXProt::me, "forward/opernam $call"); + run_cmd($main::me, "forward/opernam $call"); $user->lastoper($main::systime); } + + # run a script send the output to the punter + my $script = new Script(lc $call) || new Script('user_default'); + $script->run($self) if $script; + + # send cluster info + my $info = Route::cluster(); + $self->send("Cluster:$info"); + + # send prompts and things + $self->send($self->msg('namee1')) if !$user->name; + $self->send($self->msg('qthe1')) if !$user->qth; + $self->send($self->msg('qll')) if !$user->qra || (!$user->lat && !$user->long); + $self->send($self->msg('hnodee1')) if !$user->qth; + $self->send($self->msg('m9')) if DXMsg::for_me($call); + $self->prompt; } # @@ -423,13 +436,22 @@ sub disconnect { my $self = shift; my $call = $self->call; + + return if $self->{disconnecting}++; + delete $self->{senddbg}; - my @rout = $main::routeroot->del_user($call); - dbg("B/C PC17 on $main::mycall for: $call") if isdbg('route'); + my $uref = Route::User::get($call); + my @rout; + if ($uref) { + @rout = $main::routeroot->del_user($uref); + dbg("B/C PC17 on $main::mycall for: $call") if isdbg('route'); + } else { + confess "trying to disconnect a non existant user $call"; + } # issue a pc17 to everybody interested - DXProt::route_pc17($DXProt::me, $main::routeroot, @rout) if @rout; + DXProt::route_pc17($main::me, $main::routeroot, @rout) if @rout; # I was the last node visited $self->user->node($main::mycall); @@ -690,6 +712,11 @@ sub announce my $text = shift; my ($filter, $hops); + if (!$self->{ann_talk} && $to ne $self->{call}) { + my $call = AnnTalk::is_talk_candidate($_[0], $text); + return if $call; + } + if ($self->{annfilter}) { ($filter, $hops) = $self->{annfilter}->it(@_ ); return unless $filter;