Morten Brix Pedersen 24 лет назад
Родитель
Сommit
fce4a2018f
5 измененных файлов с 97 добавлено и 18 удалено
  1. 12 8
      docs/Changelog
  2. 38 0
      docs/pisg-doc.sgml
  3. 1 0
      modules/Pisg.pm
  4. 42 7
      modules/Pisg/HTMLGenerator.pm
  5. 4 3
      modules/Pisg/Parser/Logfile.pm

+ 12 - 8
docs/Changelog

@@ -1,9 +1,4 @@
 pisg (x.xx)
-   * SortByWords option added (thanks, Matthew Cheetah Gabeler-Lee
-     <msg2@po.cwru.edu>)
-   * Foul-words matching is now more strict. It no longer matches inside a
-     word, but only in the end or at the start of a word (thanks, Matthew
-     Cheetah Gabeler-Lee <msg2@po.cwru.edu>)
    * ShowFoulLine option added (thanks, Adam Spiers <adam@spiers.net>).
    * The "foul-words" counting is now done word-wise instead of line-wise
      (thanks, Adam Spiers <adam@spiers.net>)
@@ -20,9 +15,18 @@ pisg (x.xx)
      Hanno Hecker <hanno-pisg@bee.de>)
    * A problem with multiple mode changes (+vv, +oo) in Trillian format has
      been fixed.
-   * --cchannels commandline option added, when a channel is specified here,
-     it will be the only channel to run stats for in pisg.cfg. (thanks,
-     "Matthew \"Cheetah\" Gabeler-Lee" <msg2@po.cwru.edu>)
+   * Changes thanks to Matthew "Cheetah" Gabeler-Lee (<msg2@po.cwru.edu>):
+    * A ShowWordTime option now exists that works the same as ShowLineTime,
+      but uses word stats
+    * SortByWords option added
+    * Foul-words matching is now more strict. It no longer matches inside a
+      word, but only in the end or at the start of a word
+    * --cchannels commandline option added, when a channel is specified here,
+      it will be the only channel to run stats for in pisg.cfg.
+    * A bug previously that could cause pisg to error out in channels with
+      untalkative users in the active list when sorting by words is fixed.
+    * Random quotes wrap in the output html now
+
 
 pisg (0.38) - Thu Apr, 25th 2002
    * Grammar fixes in documentation (thanks, Azhrarn <diablo2@krock.com>)

+ 38 - 0
docs/pisg-doc.sgml

@@ -1160,6 +1160,44 @@
     </refsect1>
     </refentry>
 
+    <!-- *** SHOWWORDTIME *** -->
+    <refentry id="ShowWordTime">
+
+    <refmeta> <refentrytitle>ShowWordTime</refentrytitle> </refmeta>
+
+    <refnamediv>
+    <refname>ShowWordTime</refname>
+    <refpurpose>ShowLineTime like behavior of words column</refpurpose>
+    </refnamediv>
+
+    <refsynopsisdiv><programlisting>
+      <![CDATA[
+        <channel="#channel">
+         Logfile = "channel.log"
+         Format = "bobot"
+         ShowWordTime = "0"
+        </channel>
+
+        <set ShowWordTime="1">
+      ]]>
+    </programlisting></refsynopsisdiv>
+
+    <refsect1>
+    <title>Description</title>
+    <para>
+    The default behaviour is to add a column to the "Most Active Nicks"
+    section displaying a fancy linetimebar to show when a user was active. 
+    With this option it can be done similarly to mIRCStats does it and like
+    the ShowLineTime option, but using words instead of lines; that is, by
+    putting that timebar next to the number of words, in the same column.
+    </para>
+    </refsect1>
+    <refsect1>
+    <title>Default</title>
+    <para> 0 (disabled) </para>
+    </refsect1>
+    </refentry>
+
     <!-- *** SHOWRANDQUOTE *** -->
     <refentry id="ShowRandQuote">
 

+ 1 - 0
modules/Pisg.pm

@@ -132,6 +132,7 @@ sub get_default_config_settings
         showbignumbers => 1,
         showtopics => 1,
         showlinetime => 0,
+        showwordtime => 0,
         showtime => 1,
         showwords => 0,
         showwpl => 0,

+ 42 - 7
modules/Pisg/HTMLGenerator.pm

@@ -43,6 +43,12 @@ sub create_html
     if ($self->{cfg}->{showtime}) {
         $self->{cfg}->{tablewidth} += 40;
     }
+    if ($self->{cfg}->{showlinetime}) {
+        $self->{cfg}->{tablewidth} += 100;
+    }
+    if ($self->{cfg}->{showwordtime}) {
+        $self->{cfg}->{tablewidth} += 100;
+    }
     if ($self->{cfg}->{showwords}) {
         $self->{cfg}->{tablewidth} += 40;
     }
@@ -278,6 +284,7 @@ sub _pageheader
     while (<PAGEHEAD>) {
         _html($_);
     }
+    close(PAGEHEAD);
 }
 
 sub _pagefooter
@@ -287,6 +294,7 @@ sub _pagefooter
     while (<PAGEFOOT>) {
         _html($_);
     }
+    close(PAGEFOOT);
 }
 
 sub _activetimes
@@ -379,12 +387,14 @@ sub _activenicks
     );
 
     my @active;
+    my $nicks;
     if ($self->{cfg}->{sortbywords}) {
         @active = sort { $self->{stats}->{words}{$b} <=> $self->{stats}->{words}{$a} } keys %{ $self->{stats}->{words} };
+        $nicks = scalar keys %{ $self->{stats}->{words} };
     } else {
         @active = sort { $self->{stats}->{lines}{$b} <=> $self->{stats}->{lines}{$a} } keys %{ $self->{stats}->{lines} };
+        $nicks = scalar keys %{ $self->{stats}->{lines} };
     }
-    my $nicks = scalar keys %{ $self->{stats}->{lines} };
 
     if ($self->{cfg}->{activenicks} > $nicks) { $self->{cfg}->{activenicks} = $nicks; }
 
@@ -445,13 +455,15 @@ sub _activenicks
         my $ch   = $self->{stats}->{lengths}{$nick};
         _html("<td style=\"background-color: $color\">$visiblenick</td>"
         . ($self->{cfg}->{showlinetime} ?
-        "<td style=\"background-color: $color\">".$self->_user_linetimes($nick,$active[0])."</td>"
+        "<td style=\"background-color: $color\" nowrap=\"nowrap\">".$self->_user_linetimes($nick,$active[0])."</td>"
         : "<td style=\"background-color: $color\">$line</td>")
         . ($self->{cfg}->{showtime} ?
         "<td style=\"background-color: $color\">".$self->_user_times($nick)."</td>"
         : "")
         . ($self->{cfg}->{showwords} ?
-        "<td style=\"background-color: $color\">$w</td>"
+           ($self->{cfg}->{showwordtime} ?
+           "<td style=\"background-color: $color\" nowrap=\"nowrap\">".$self->_user_wordtimes($nick,$active[0])."</td>"
+           : "<td style=\"background-color: $color\">$w</td>")
         : "")
         . ($self->{cfg}->{showwpl} ?
         "<td style=\"background-color: $color\">".sprintf("%.1f",$w/$line)."</td>"
@@ -463,7 +475,7 @@ sub _activenicks
         "<td style=\"background-color: $color\">$lastseen</td>"
         : "")
         . ($self->{cfg}->{showrandquote} ?
-        "<td style=\"background-color: $color\" nowrap=\"nowrap\">\"$randomline\"</td>"
+        "<td style=\"background-color: $color\">\"$randomline\"</td>"
         : "")
         );
 
@@ -1619,16 +1631,39 @@ sub _user_linetimes
     return "$bar&nbsp;$self->{stats}->{lines}{$nick}";
 }
 
+sub _user_wordtimes
+{
+    my $self = shift;
+    my $nick  = shift;
+    my $top   = shift;
+
+    my $bar      = "";
+    my $len      = ($self->{stats}->{words}{$nick} / $self->{stats}->{words}{$top}) * 100;
+
+    for (my $i = 0; $i <= 3; $i++) {
+        next if not defined $self->{stats}->{word_times}{$nick}[$i];
+        my $w = int(($self->{stats}->{word_times}{$nick}[$i] / $self->{stats}->{words}{$nick}) * $len);
+        if ($w) {
+            my $pic = 'pic_h_'.(6*$i);
+            $bar .= "<img src=\"$self->{cfg}->{piclocation}/$self->{cfg}->{$pic}\" border=\"0\" width=\"$w\" height=\"15\" align=\"middle\" alt=\"\" />";
+        }
+    }
+    return "$bar&nbsp;$self->{stats}->{words}{$nick}";
+}
+
 sub _user_times
 {
     my $self = shift;
     my ($nick) = @_;
 
     my $bar = "";
-
+    
+    my $itemstat = ($self->{cfg}->{sortbywords} ? 'words' : 'lines');
+    my $timestat = ($self->{cfg}->{sortbywords} ? 'word_times' : 'line_times');
+    
     for (my $i = 0; $i <= 3; $i++) {
-        next if not defined $self->{stats}->{line_times}{$nick}[$i];
-        my $w = int(($self->{stats}->{line_times}{$nick}[$i] / $self->{stats}->{lines}{$nick}) * 40);
+        next if not defined $self->{stats}->{$timestat}{$nick}[$i];
+        my $w = int(($self->{stats}->{$timestat}{$nick}[$i] / $self->{stats}->{$itemstat}{$nick}) * 40);
         if ($w) {
             my $pic = 'pic_h_'.(6*$i);
             $bar .= "<img src=\"$self->{cfg}->{piclocation}/$self->{cfg}->{$pic}\" border=\"0\" width=\"$w\" height=\"15\" alt=\"\" />";

+ 4 - 3
modules/Pisg/Parser/Logfile.pm

@@ -297,7 +297,7 @@ sub _parse_file
                         }
                     }
 
-                    _parse_words($stats, $saying, $nick, $self->{cfg}->{ignoreword});
+                    _parse_words($stats, $saying, $nick, $self->{cfg}->{ignoreword}, $hour);
                 }
             }
             $lastnormal = $line;
@@ -342,7 +342,7 @@ sub _parse_file
                 my $len = length($saying);
                 $stats->{lengths}{$nick} += $len;
 
-                _parse_words($stats, $saying, $nick, $self->{cfg}->{ignoreword});
+                _parse_words($stats, $saying, $nick, $self->{cfg}->{ignoreword}, $hour);
             }
         }
 
@@ -449,10 +449,11 @@ sub _modechanges
 
 sub _parse_words
 {
-    my ($stats, $saying, $nick, $ignoreword) = @_;
+    my ($stats, $saying, $nick, $ignoreword, $hour) = @_;
 
     foreach my $word (split(/[\s,!?.:;)(\"]+/, $saying)) {
         $stats->{words}{$nick}++;
+        $stats->{word_times}{$nick}[int($hour/6)]++;
         # remove uninteresting words
         next if ($ignoreword->{$word});