5. Go back to the old way of caching commands (but without the silly warnings
because I know better what I am doing now). This allows symbolic debugging
of commands again without coredumps. Hurrah!
+6. Add badword handling for messages. Users will get rude messages back if
+they try to send naughty words in msgs. Incoming messages with badwords will
+be dropped on receipt and their contents logged.
30Sep01=======================================================================
1. made some small bug fixes in rspf checking and also messages.
23Sep01=======================================================================
# $Id$
#
my ($self, $line) = @_;
-return $BadWord::badwords->unset(8, $self->msg('e6'), $self, $line);
+return $BadWords::badword->unset(8, $self->msg('e6'), $self, $line);
eval { @ans = &{$self->{func}}($self, $cmdline) };
}
$self->send_ans("Syserr: on stored func $self->{func}", $@) if $@;
+ $self->send_ans(@ans);
} else {
$self->send_ans(run_cmd($self, $cmdline));
}
for (keys %Cache) {
undef *{$_};
+ dbg("Undefining cmd $_") if isdbg('command');
}
%cmd_cache = ();
%Cache = ();
# get rid of any existing sub and try to compile the new one
no strict 'refs';
- dbg("[Re]defining $package") if isdbg('command');
- undef *$package;
+ if (exists $Cache{$package}) {
+ dbg("Redefining $package") if isdbg('command');
+ undef *$package;
+ } else {
+ dbg("Defining $package") if isdbg('command');
+ }
eval $eval;
$Cache{$package} = {mtime => $mtime };
return;
}
+ # check the message for bad words
+ my @words;
+ for (@{$ref->{lines}}) {
+ push @words, BadWords::check($_);
+ }
+ push @words, BadWords::check($ref->{subject});
+ if (@words) {
+ dbg("message with badwords '@words' $ref->{from} -> $ref->{to} '$ref->{subject}' origin: $ref->{origin}") if isdbg('msg');
+ Log('msg',"message with badwords '@words' $ref->{from} -> $ref->{to} origin: $ref->{origin}");
+ Log('msg',"subject: $ref->{subject}");
+ for (@{$ref->{lines}}) {
+ Log('msg', "line: $_");
+ }
+ $ref->stop_msg($self->call);
+ return;
+ }
+
$ref->{msgno} = next_transno("Msgno");
push @{$ref->{gotit}}, $f[2]; # mark this up as being received
$ref->store($ref->{lines});
# $DB::single = 1;
confess "local var gone missing" if !ref $self->{loc};
my $loc = $self->{loc};
+ if (my @ans = BadWords::check($line)) {
+ Log('msg', $self->call . " used badwords: @ans to @{$loc->{to}} in msg");
+ return ($self->msg('e17', @ans), $self->msg('m1'));
+ }
$loc->{subject} = $line;
$loc->{lines} = [];
$self->state('sendbody');
$self->func(undef);
$self->state('prompt');
} else {
+ if (my @ans = BadWords::check($line)) {
+ Log('msg', $self->call . " used badwords: @ans to @{$loc->{to}} subject: '$loc->{subject}' in msg");
+ Log('msg', "line: $line");
+ return ($self->msg('e17', @ans));
+ }
# i.e. it ain't and end or abort, therefore store the line
push @{$loc->{lines}}, length($line) > 0 ? $line : " ";
}
}
- return (1, @out);
+ return @out;
}
# return the standard directory line for this ref
package Editable;
+use strict;
+
use vars qw($VERSION $BRANCH);
$VERSION = sprintf( "%d.%03d", q$Revision$ =~ /(\d+)\.(\d+)/ );
$BRANCH = sprintf( "%d.%03d", q$Revision$ =~ /\d+\.\d+\.(\d+)\.(\d+)/ ) || 0;
$main::build += $VERSION;
$main::branch += $BRANCH;
+use DXChannel;
+use DXDebug;
+use BadWords;
+
sub new
{
my $pkg = shift;
my $class = ref $pkg || $pkg;
- return {}, $class;
+ return {@_}, $class;
+}
+
+sub copy
+{
+ my $self = shift;
+ return $self->new(%$self);
+}
+
+sub addline
+{
+ my $self = shift;
+ my $dxchan = shift;
+ my $line = shift;
+
+ if (my @ans = BadWord::check($line)) {
+ return ($dxchan->msg('e17', @ans));
+ }
+ push @{$self->{lines}}, $line;
+ return ();
+}
+
+sub modline
+{
+ my $self = shift;
+ my $dxchan = shift;
+ my $no = shift;
+ my $line = shift;
+
+ if (my @ans = BadWord::check($line)) {
+ return ($dxchan->msg('e17', @ans));
+ }
+ ${$self->{lines}}[$no], $line;
+ return ();
+}
+
+sub lines
+{
+ my $self = shift;
+ return exists $self->{lines} ? (@{$self->{lines}}) : ();
+}
+
+sub nolines
+{
+ my $self = shift;
+ return exists $self->{lines} ? scalar @{$self->{lines}} : 0;
}
1;