spider/cmd/chat.pl
Dirk Koopman 4b207544da mega-merge of major parts of mojo
The point of this is to make it easier to maintain both branches.

DXProt (DXProtHandle has already been copied) route/* DXChannel
DXCommandmode and console.pl have been either copied wholesale,
where necessary, modified to use the old Msg based networking stack.
2022-01-07 23:47:56 +00:00

58 lines
1.3 KiB
Perl

#
# do a chat message
#
# this is my version of conferencing....
#
# Copyright (c) 2003 Dirk Koopman G1TLH
#
#
my ($self, $line) = @_;
#$DB::single = 1;
my @f = split /\s+/, $line, 2;
return (1, $self->msg('e5')) if $self->remotecmd || $self->inscript;
return (1, $self->msg('e34')) unless @f >= 1;
return (1, $self->msg('e28')) unless $self->isregistered;
my $target = uc $f[0];
return (1, $self->msg('e35', $target)) unless grep uc $_ eq $target, @{$self->user->group};
$f[1] ||= '';
my $from = $self->call;
my $text = $f[1] ;
my $t = ztime(time);
my $toflag = '*';
my @out;
# change ^ into : for transmission
$line =~ s/\^/:/og;
if ($text) {
my @bad;
if (@bad = BadWords::check($line)) {
$self->badcount(($self->badcount||0) + @bad);
LogDbg('DXCommand', "$self->{call} swore: $line (with words:" . join(',', @bad) . ")");
Log('chat', $target, $from, "[to $from only] $line");
return (1, "$target de $from <$t>: $line");
}
$self->send_chats($target, $text);
} else {
my $ref = $self->talklist;
if ($ref) {
push @out, $self->msg('chattoomany', $target, $self->talklist->[0]);
} else {
$self->talklist([ $target ]);
push @out, $self->msg('chatinst', $target);
$self->state('chat');
}
Log('chat', $target, $from, "Started chat mode on $target");
push @out, $self->chat_prompt;
}
return (1, @out);