-# 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*//;
+if ($f[0] =~ /^by$/i) {
+ return (1, $self->msg('e5')) unless $main::allowdxby || $self->priv > 1;
+ $spotter = uc $f[1];
+ $line =~ s/^\s*$f[0]\s+$f[1]\s+//;
+ @f = split /\s+/, $line, 3;
+ return (1, $self->msg('dx2')) unless @f >= 2;
+}
+
+my $ipaddr;
+@f = split /\s+/, $line, 3;
+if ($f[0] eq 'ip') {
+ return (1, $self->msg('e5')) unless $spotter && $self->priv > 1;
+ if (is_ipaddr($f[1])) {
+ $ipaddr = $f[1];
+ } else {
+ return (1, $self->msg('dx4', $f[1]));
+ }
+ $line =~ s/^\s*$f[0]\s+$f[1]\s+//;
+ @f = split /\s+/, $line, 3;
+}
+
+
+# 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];