fix sh/log users as well
authorDirk Koopman <djk@tobit.co.uk>
Mon, 20 Apr 2020 13:39:39 +0000 (14:39 +0100)
committerDirk Koopman <djk@tobit.co.uk>
Mon, 20 Apr 2020 13:39:39 +0000 (14:39 +0100)
cmd/show/announce.pl
cmd/show/chat.pl
cmd/show/groups.pl
cmd/show/rcmd.pl
cmd/show/talk.pl

index 77811449638fd01210511bb03119d8b33dd17ef3..2820c6c7f665c0638be3cbefb9fd10b79996ceca 100644 (file)
@@ -28,13 +28,13 @@ while ($f = shift @f) {                 # next field
                next if $to;
        }
        next if $who;
-       ($who) = $f =~ /^(\w+)/o;
+       #($who) = $f =~ /^(\w+)/o;
 }
 
 $to = 20 unless $to;
 $from = 0 unless $from;
 
-@out = $self->spawn_cmd("show/announce $cmdline", \&DXLog::print, args => [$from, $to, $main::systime, 'ann', $who]);
+return (1, DXLog::print($from, $to, $main::systime, 'ann', $who)) if $self->{_nospawn};;
+return (1, $self->spawn_cmd("show/announce $cmdline", \&DXLog::print, args => [$from, $to, $main::systime, 'ann', $who]));
        
-#@out = DXLog::print($from, $to, $main::systime, 'ann', $who);
 return (1, @out);
index 9f543df58717b50aa4fbe707e7e9f62f20d5df57..cc251c10727f1e0e71f407e9142b977e285d2e4a 100644 (file)
@@ -28,7 +28,7 @@ while ($f = shift @f) {                 # next field
                next if $to;
        }
        next if $who;
-       ($who) = $f =~ /^(\w+)/o;
+#      ($who) = $f =~ /^(\w+)/o;
 }
 
 $to = 20 unless $to;
index 8cbf54e6c2940b10faf20593b03aad0a0c84410a..85e3fe2b0057dc6853e1297e4127c141c60774e6 100644 (file)
 
 use Time::Local;
 
+my $to;
+
 sub handle
 {
        my $self = shift;
-       my $to = shift;
+       $to = shift;
 
        if ($to =~ /\D/) {
                return (1, "try sh/chatgroups xxx where xxx is the number of chat messages to search.");
        }
-
-       my @out;
        $to = 500 unless $to;
 
-       @out = $self->spawn_cmd("show/groups $to", \&DXLog::print, 
-                                                       args => [0, $to, $main::systime, 'chat', undef], 
-                                                       cb => sub {
-                                                               my $self = shift;
-                                                               my @chatlog = @_;
+       if ($self->{_nospawn}) {
+               return (1, doit($self, DXLog::print(undef, $to, $main::systime, 'chat', undef)));
+       }
+       return (1, $self->spawn_cmd("show/groups $to", \&DXLog::print, args => [0, $to, $main::systime, 'chat', undef], cb => \&doit));
+}
+
+sub doit {
+       my $self = shift;
+       
+               my @chatlog = @_;
+
+               my $g= {};
+               my @out;
+               my $row;
+               my ($time, $call, $group);
+               my $found;
+               my %month = (
+                                        Jan => 0,
+                                        Feb => 1,
+                                        Mar => 2,
+                                        Apr => 3,
+                                        May => 4,
+                                        Jun => 5,
+                                        Jul => 6,
+                                        Aug => 7,
+                                        Sep => 8,
+                                        Oct => 9,
+                                        Nov => 10,
+                                        Dec => 11,
+                                       );
+
+               @chatlog = reverse @chatlog;
+               foreach $row(@chatlog) {
+                       ($time, $call, $group) = ($row =~ m/^(\S+) (\S+) -> (\S+) /o);
+                       if (!exists $g->{$group}) {
+                               $time =~ m/^(\d\d)(\w{3})(\d{4})\@(\d\d):(\d\d):(\d\d)/o;
+                               $g->{$group}->{sec} = timegm($6, $5, $4, $1, $month{$2}, $3-1900);
+                               $time =~ s/\@/ at /;
+                               $g->{$group}->{last} = $time;
+                               push @{ $g->{$group}->{calls} }, $call;
+                       }
+                       else {
+                               $found = 0;
+                               foreach (@{ $g->{$group}->{calls} }) {
+                                       if (/$call/) {
+                                               $found = 1;
+                                               last;
+                                       }
+                               }
+                               push @{ $g->{$group}->{calls} }, $call unless $found;
+                       }
+                       $g->{$group}->{msgcount}++;
+               }
 
-                                                               my $g= {};
-                                                               my @out;
-                                                               my $row;
-                                                               my ($time, $call, $group);
-                                                               my $found;
-                                                               my %month = (
-                                                                                        Jan => 0,
-                                                                                        Feb => 1,
-                                                                                        Mar => 2,
-                                                                                        Apr => 3,
-                                                                                        May => 4,
-                                                                                        Jun => 5,
-                                                                                        Jul => 6,
-                                                                                        Aug => 7,
-                                                                                        Sep => 8,
-                                                                                        Oct => 9,
-                                                                                        Nov => 10,
-                                                                                        Dec => 11,
-                                                                                       );
+               push (@out, "Chat groups recently used:");
+               push (@out, "($to messages searched)");
+               push (@out, "--------------------------");
+               my @calls;
+               my @l;
+               my $max = 6;
+               my $mtext;
+               foreach $group (sort { $g->{$b}->{sec}  <=> $g->{$a}->{sec} } keys %$g) {
+                       @calls = sort( @{ $g->{$group}->{calls} } );
+                       $mtext = "  " . $g->{$group}->{msgcount} . " messages by:";
+                       push (@out, "$group: Last active " . $g->{$group}->{last});
+                       if (@calls <= $max) {
+                               push (@out, "$mtext @calls");
+                       }
+                       else {
+                               foreach $call(@calls) {
+                                       push @l, $call;
+                                       if (@l >= $max) {
+                                               if ($max == 6) {
+                                                       push (@out, "$mtext @l");
+                                               }
+                                               else {
+                                                       push (@out, "  @l");
+                                               }
+                                               @l = ();
+                                               $max = 8;
+                                       }
+                               }
+                               push (@out, "  @l") if (@l);
+                               $max = 6;
+                               @l = ();
+                       }
+                       push (@out, "-");
+               }
+               return @out;
+       }
 
-                                                               @chatlog = reverse @chatlog;
-                                                               foreach $row(@chatlog) {
-                                                                       ($time, $call, $group) = ($row =~ m/^(\S+) (\S+) -> (\S+) /o);
-                                                                       if (!exists $g->{$group}) {
-                                                                               $time =~ m/^(\d\d)(\w{3})(\d{4})\@(\d\d):(\d\d):(\d\d)/o;
-                                                                               $g->{$group}->{sec} = timegm($6, $5, $4, $1, $month{$2}, $3-1900);
-                                                                               $time =~ s/\@/ at /;
-                                                                               $g->{$group}->{last} = $time;
-                                                                               push @{ $g->{$group}->{calls} }, $call;
-                                                                       }
-                                                                       else {
-                                                                               $found = 0;
-                                                                               foreach (@{ $g->{$group}->{calls} }) {
-                                                                                       if (/$call/) {
-                                                                                               $found = 1;
-                                                                                               last;
-                                                                                       }
-                                                                               }
-                                                                               push @{ $g->{$group}->{calls} }, $call unless $found;
-                                                                       }
-                                                                       $g->{$group}->{msgcount}++;
-                                                               }
 
-                                                               push (@out, "Chat groups recently used:");
-                                                               push (@out, "($to messages searched)");
-                                                               push (@out, "--------------------------");
-                                                               my @calls;
-                                                               my @l;
-                                                               my $max = 6;
-                                                               my $mtext;
-                                                               foreach $group (sort { $g->{$b}->{sec}  <=> $g->{$a}->{sec} } keys %$g) {
-                                                                       @calls = sort( @{ $g->{$group}->{calls} } );
-                                                                       $mtext = "  " . $g->{$group}->{msgcount} . " messages by:";
-                                                                       push (@out, "$group: Last active " . $g->{$group}->{last});
-                                                                       if (@calls <= $max) {
-                                                                               push (@out, "$mtext @calls");
-                                                                       }
-                                                                       else {
-                                                                               foreach $call(@calls) {
-                                                                                       push @l, $call;
-                                                                                       if (@l >= $max) {
-                                                                                               if ($max == 6) {
-                                                                                                       push (@out, "$mtext @l");
-                                                                                               }
-                                                                                               else {
-                                                                                                       push (@out, "  @l");
-                                                                                               }
-                                                                                               @l = ();
-                                                                                               $max = 8;
-                                                                                       }
-                                                                               }
-                                                                               push (@out, "  @l") if (@l);
-                                                                               $max = 6;
-                                                                               @l = ();
-                                                                       }
-                                                                       push (@out, "-");
-                                                               }
-                                                               return @out;
-                                                       });
-       
-       #       my @chatlog = DXLog::print(undef, $to, $main::systime, 'chat', undef);
-       return (1, @out);
-}
index d7cbd332a5529a9cd7099e6962f4afdb4a6eb9bf..7cd02d5de7022f8738145037e649b1571af6a385 100644 (file)
@@ -27,7 +27,7 @@ while ($f = shift @f) {                 # next field
                next if $to;
        }
        next if $who;
-       ($who) = $f =~ /^(\w+)/o;
+       #($who) = $f =~ /^(\w+)/o;
 }
 
 $to = 20 unless $to;
index 942dac72dbeb015ceef56ab0b8e704a50413cf94..811719d7802399d6e8f9a667ddcb71abffed4bd3 100644 (file)
@@ -25,7 +25,7 @@ while ($f = shift @f) {                 # next field
                next if $to;
        }
        next if $who;
-       ($who) = $f =~ /^(\w+)/o;
+#      ($who) = $f =~ /^(\w+)/o;
 }
 
 $to = 20 unless $to;
@@ -35,7 +35,5 @@ if ($self->priv < 6) {
        return (1, $self->msg('e5')) if $who ne $self->call;
 }
 
-@out = $self->spawn_cmd("show/talk $cmdline", \&DXLog::print, args => [$from, $to, $main::systime, 'talk', $who]);
-       
-#@out = DXLog::print($from, $to, $main::systime, 'talk', $who);
-return (1, @out);
+return (1, DXLog::print($from, $to, $main::systime, 'talk', $who)) if $self->{_nospawn};
+return (1, $self->spawn_cmd("show/talk $cmdline", \&DXLog::print, args => [$from, $to, $main::systime, 'talk', $who]));