added spoofing
[spider.git] / cmd / spoof.pl
1 #!/usr/bin/perl
2 #
3 # pretend that you are another user, useful for reseting
4 # those silly things that people insist on getting wrong
5 # like set/homenode et al
6 #
7 # Copyright (c) 1999 Dirk Koopman G1TLH
8 #
9 my ($self, $line) = @_;
10
11 my $mycall = $self->call;
12 my $myuser = $self->user;
13
14 my ($call, $newline) = split /\s+/, $line, 2;
15 return (1, $self->msg('nodee1', $call)) if DXChannel->get($call);
16
17 if ($self->remotecmd) {
18         Log('DXCommand', "$mycall is trying to spoof $call remotely");
19         return (1, $self->msg('e5'));
20 }
21 if ($self->priv < 9) {
22         Log('DXCommand', "$mycall is trying to spoof $call locally");
23         return (1, $self->msg('e5'));
24 }
25
26 my @out;
27 $call = uc $call;
28 my $user = DXUser->get($call);
29 unless ($user) {
30         $user = DXUser->new($call);
31         push @out, $self->msg('spf1', $call);
32 }
33
34 # set up basic environment
35 $self->call($call);
36 $self->user($user);
37 Log('DXCommand', "spoof '$newline' as $call by $mycall");
38 my @in = $self->run_cmd($newline);
39 push @out, map {"spoof $call: $_"} @in;
40 $self->call($mycall);
41 $self->user($myuser);
42
43 return (1, @out);