-# first lets see if we think we have a callsign as the first argument
-if ($f[0] =~ /[A-Za-z]/) {
- $spotter = uc $f[0];
- $freq = $f[1];
- $spotted = uc $f[2];
- $line =~ s/^$f[0]\s+$f[1]\s+$f[2]\s*//;
+my @bad;
+if (@bad = BadWords::check($line)) {
+ $self->badcount(($self->badcount||0) + @bad);
+ Log('DXCommand', "$self->{call} swore: $line");
+ $localonly++;
+}
+
+# do we have at least two args?
+return (1, $self->msg('dx2')) unless @f >= 2;
+
+# as a result of a suggestion by Steve K9AN, I am changing the syntax of
+# 'spotted by' things to "dx by g1tlh <freq> <call>" <freq> and <call>
+# can be in any order
+
+if ($f[0] =~ /^by$/i) {
+ $spotter = uc $f[1];
+ $line =~ s/^\s*\Q$f[0]\s+\Q$f[1]\s+//;
+ $line = $f[2];
+ @f = split /\s+/, $line;
+ return (1, $self->msg('dx2')) unless @f >= 2;
+}
+
+# get the freq and callsign either way round
+if (is_freq($f[1]) && $f[0] =~ m{^[\w\d]+(?:/[\w\d]+){0,2}$}) {
+ $spotted = uc $f[0];
+ $freq = $f[1];
+} elsif (is_freq($f[0]) && $f[1] =~ m{^[\w\d]+(?:/[\w\d]+){0,2}$}) {
+ $freq = $f[0];
+ $spotted = uc $f[1];