Просмотр исходного кода

Add "show_mostnicks" feature, thanks to "ST8" <st8@barrysworld.com>

Morten Brix Pedersen 24 лет назад
Родитель
Сommit
86c8b1f07d
5 измененных файлов с 74 добавлено и 0 удалено
  1. 12 0
      docs/Changelog
  2. 1 0
      lang.txt
  3. 1 0
      modules/Pisg.pm
  4. 41 0
      modules/Pisg/HTMLGenerator.pm
  5. 19 0
      modules/Pisg/Parser/Logfile.pm

+ 12 - 0
docs/Changelog

@@ -2,6 +2,18 @@ pisg (0.35)
    * Translate mouse-over items (eg. "Open in new window: URL")
    * Translate mouse-over items (eg. "Open in new window: URL")
    * Support for oer bot logfiles (thanks to EQU <equ@equnet.org>)
    * Support for oer bot logfiles (thanks to EQU <equ@equnet.org>)
    * Support for perlbot logfiles (thanks to Travis Roy <travis@scootz.net>)
    * Support for perlbot logfiles (thanks to Travis Roy <travis@scootz.net>)
+   * Add -v / --version commandline option
+   * Fix a rare bug where a user with only one line, and no words were causing
+     unitialized values error.
+   * Many fixes to axur logfile format (thanks, Andrew <andy@lewman.com>)
+   * Fix to irssi logfile handling, where a user was recognized as a mode
+     (thanks, David Leadbeater <dgl@dgl.cx>)
+   * Support new xchat logfile format (from 1.8.6 and up)
+   * Add "show_mostnicks" feature (thanks to "ST8" <st8@barrysworld.com>),
+     this adds a box on the stats page showing how many different nick uses
+     people had
+   * Fix bug in documentation, which said nicktracking was enabled by default,
+     but it really isn't.
 
 
 pisg (0.34) - Tue, Jan 8th 2002
 pisg (0.34) - Tue, Jan 8th 2002
    * New option 'show_topics', to enable/disable 'last topics'
    * New option 'show_topics', to enable/disable 'last topics'

+ 1 - 0
lang.txt

@@ -119,6 +119,7 @@ mostwordstopic = "Most used words"
 referencetopic = "Most referenced nick"
 referencetopic = "Most referenced nick"
 urlstopic = "Most referenced URLs"
 urlstopic = "Most referenced URLs"
 notopic = "A topic was never set on this channel."
 notopic = "A topic was never set on this channel."
+mostnickstopic = "Users with most nicknames"
 bylinetopic = "by [:nick] on [:time]"
 bylinetopic = "by [:nick] on [:time]"
 
 
 ## Other text
 ## Other text

+ 1 - 0
modules/Pisg.pm

@@ -158,6 +158,7 @@ sub get_default_config_settings
         show_mrn => 1,
         show_mrn => 1,
         show_mru => 1,
         show_mru => 1,
         show_voices => 0,
         show_voices => 0,
+        show_mostnicks => 0,
 
 
         # Less important things
         # Less important things
 
 

+ 41 - 0
modules/Pisg/HTMLGenerator.pm

@@ -77,6 +77,10 @@ sub create_html
         _html("</table>"); # Needed for sections
         _html("</table>"); # Needed for sections
     }
     }
 
 
+    if ($self->{cfg}->{show_mostnicks}) {
+        $self->_mostnicks();
+    }
+
     if ($self->{cfg}->{show_muw}) {
     if ($self->{cfg}->{show_muw}) {
         $self->_mostusedword();
         $self->_mostusedword();
     }
     }
@@ -1640,6 +1644,43 @@ sub _user_times
     return $bar;
     return $bar;
 }
 }
 
 
+sub _mostnicks
+{
+    # List showing the user with most used nicks
+    my $self = shift;
+
+    my @sortnicks = sort { @{ $self->{stats}->{nicks}->{$b} } <=> @{ $self->{stats}->{nicks}->{$a} } } 
+                                keys %{ $self->{stats}->{nicks} };
+
+    if (@{ $self->{stats}->{nicks}->{$sortnicks[0]} } > 1) {
+
+        $self->_headline($self->_template_text('mostnickstopic'));
+
+        _html("<table border=\"0\" width=\"$self->{cfg}->{tablewidth}\"><tr>");
+        _html("<td>&nbsp;</td><td class=\"tdtop\"><b>Nick</b></td>");
+        _html("<td class=\"tdtop\"><b>Names Used</b></td></tr>");
+
+        for(my $i = 0; $i < 5; $i++) {
+            last unless $i < @sortnicks;
+            my $nickcount = scalar(@{ $self->{stats}->{nicks}->{$sortnicks[$i]} });
+            my $nickused = join(", ", @{ $self->{stats}->{nicks}->{$sortnicks[$i]} });
+
+            next unless ($nickcount > 1);
+            
+            my $a = $i + 1;
+            my $class = $a == 1 ? 'hirankc' : 'rankc';
+            my $n = $nickcount > 1 ? "names" : "name";
+
+            _html("<tr><td class=\"$class\">$a</td>");
+            _html("<td class=\"hicell\">$sortnicks[$i]<br><font size='1'>($nickcount $n)</font></td>");
+            _html("<td class=\"hicell\" valign='top'><font size='1'>$nickused</font></td>");
+            _html("</tr>");
+        }
+        _html("</table>");
+    }
+}
+
+
 1;
 1;
 
 
 __END__
 __END__

+ 19 - 0
modules/Pisg/Parser/Logfile.pm

@@ -213,6 +213,7 @@ sub _parse_file
 
 
                 $hour   = $hashref->{hour};
                 $hour   = $hashref->{hour};
                 $nick   = find_alias($hashref->{nick});
                 $nick   = find_alias($hashref->{nick});
+                checkname($hashref->{nick}, $nick, $stats) if ($self->{cfg}->{show_mostnicks});
                 $saying = $hashref->{saying};
                 $saying = $hashref->{saying};
 
 
                 if ($hour < $state->{oldtime}) { $stats->{days}++ }
                 if ($hour < $state->{oldtime}) { $stats->{days}++ }
@@ -304,6 +305,7 @@ sub _parse_file
 
 
             $hour   = $hashref->{hour};
             $hour   = $hashref->{hour};
             $nick   = find_alias($hashref->{nick});
             $nick   = find_alias($hashref->{nick});
+            checkname($hashref->{nick}, $nick, $stats) if ($self->{cfg}->{show_mostnicks});
             $saying = $hashref->{saying};
             $saying = $hashref->{saying};
 
 
             if ($hour < $state->{oldtime}) { $stats->{days}++ }
             if ($hour < $state->{oldtime}) { $stats->{days}++ }
@@ -347,6 +349,7 @@ sub _parse_file
             $hour     = $hashref->{hour};
             $hour     = $hashref->{hour};
             $min      = $hashref->{min};
             $min      = $hashref->{min};
             $nick     = find_alias($hashref->{nick});
             $nick     = find_alias($hashref->{nick});
+            checkname($hashref->{nick}, $nick, $stats) if ($self->{cfg}->{show_mostnicks});
             $kicker   = find_alias($hashref->{kicker})
             $kicker   = find_alias($hashref->{kicker})
                 if ($hashref->{kicker});
                 if ($hashref->{kicker});
             $newtopic = $hashref->{newtopic};
             $newtopic = $hashref->{newtopic};
@@ -381,6 +384,7 @@ sub _parse_file
 
 
                 } elsif (defined($newnick) and ($self->{cfg}->{nicktracking} == 1)) {
                 } elsif (defined($newnick) and ($self->{cfg}->{nicktracking} == 1)) {
                     add_alias($nick, $newnick);
                     add_alias($nick, $newnick);
+                    checkname($nick, $newnick, $stats) if ($self->{cfg}->{show_mostnicks});
                 }
                 }
             }
             }
         }
         }
@@ -501,6 +505,21 @@ sub _strip_mirccodes
     return $line;
     return $line;
 }
 }
 
 
+sub checkname {
+    # This function tracks nickchanges and puts them all in a hash->array,
+    # so we can show all nicks that I user had later (only works properly
+    # when nicktracking is enabled)
+    my ($nick, $newnick, $stats) = @_;
+
+    foreach (@{ $stats->{nicks}{$newnick}}) {
+        if ($_ eq $nick) {
+            return;
+        } 
+    }
+
+    push (@{ $stats->{nicks}{$newnick} }, $nick);
+}
+
 1;
 1;
 
 
 __END__
 __END__