- @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}++;
+ }