Преглед на файлове

New patch from Hanno which enables new fancy bars at the most active nicks.
Enabled this by default for now... we also need some nicer images.

Morten Brix Pedersen преди 25 години
родител
ревизия
75f79e69af
променени са 3 файла, в които са добавени 80 реда и са изтрити 11 реда
  1. 2 0
      Changelog
  2. 4 0
      lang.txt
  3. 74 11
      pisg.pl

+ 2 - 0
Changelog

@@ -8,6 +8,8 @@ pisg (0.20)
    * Add new options 'show_wpl' and 'show_cpl', this enables user to view the
    * Add new options 'show_wpl' and 'show_cpl', this enables user to view the
      'chars per line' and 'words per line' in the 'most active nicks',
      'chars per line' and 'words per line' in the 'most active nicks',
      disabled by default.
      disabled by default.
+   * New option 'show_time', this will display a small bar in the 'most active
+     nicks' of when the respective people actually speak. [enabled]
    * Remember to distribute the 'FORMATS' file (was missed in the last two
    * Remember to distribute the 'FORMATS' file (was missed in the last two
      releases)
      releases)
    * Swedish translation (thanks to Andreas Henriksson)
    * Swedish translation (thanks to Andreas Henriksson)

+ 4 - 0
lang.txt

@@ -111,6 +111,8 @@ userpic = "Userpic"
 nottop = "These didn't make it to the top:"
 nottop = "These didn't make it to the top:"
 word = "Word"
 word = "Word"
 numberuses = "Number of Uses"
 numberuses = "Number of Uses"
+show_words = "Number of Words"
+show_time = "When?"
 show_wpl = "Words per line"
 show_wpl = "Words per line"
 show_cpl = "Chars per line"
 show_cpl = "Chars per line"
 lastused = "Last Used by"
 lastused = "Last Used by"
@@ -207,6 +209,8 @@ randquote = "Zufalls quote"
 userpic = "Userbild"
 userpic = "Userbild"
 nottop = "Sie haben es nicht an die Spitze geschafft:"
 nottop = "Sie haben es nicht an die Spitze geschafft:"
 word = "Wort"
 word = "Wort"
+show_words = "Anzahl der Worte"
+show_time = "Wann?"
 show_wpl = "Worte pro Zeile"
 show_wpl = "Worte pro Zeile"
 show_cpl = "Zeichen pro Zeile"
 show_cpl = "Zeichen pro Zeile"
 numberuses = "Wie oft benutzt"
 numberuses = "Wie oft benutzt"

+ 74 - 11
pisg.pl

@@ -62,6 +62,15 @@ my $conf = {
     pic1 => "pipe-blue.png",
     pic1 => "pipe-blue.png",
     pic2 => "pipe-purple.png",
     pic2 => "pipe-purple.png",
 
 
+    pic_v_0 => "pipe-v-blue.png",
+    pic_v_6 => "pipe-v-green.png",
+    pic_v_12 => "pipe-v-yellow.png",
+    pic_v_18 => "pipe-v-red.png",
+    pic_h_0 => "pipe-h-blue.png",
+    pic_h_6 => "pipe-h-green.png",
+    pic_h_12 => "pipe-h-yellow.png",
+    pic_h_18 => "pipe-h-red.png",
+
     # Less important things
     # Less important things
 
 
     minquote => "25",
     minquote => "25",
@@ -74,7 +83,10 @@ my $conf = {
     timeoffset => "+0",
     timeoffset => "+0",
 
 
     # Stats settings
     # Stats settings
-    
+
+    show_linetime => 0,
+    show_time => 1,
+    show_words => 0,
     show_wpl => 0,
     show_wpl => 0,
     show_cpl => 0,
     show_cpl => 0,
 
 
@@ -97,7 +109,8 @@ $thirdline, @ignore, $processtime, @topics, %monologue, %kicked, %gotkick,
 %line, %length, %sadface, %smile, $nicks, %longlines, %mono, %times, %question,
 %line, %length, %sadface, %smile, $nicks, %longlines, %mono, %times, %question,
 %loud, $totallength, %gaveop, %tookop, %joins, %actions, %sayings, %wordcount,
 %loud, $totallength, %gaveop, %tookop, %joins, %actions, %sayings, %wordcount,
 %lastused, %gotban, %setban, %foul, $days, $oldtime, $lastline, $actions,
 %lastused, %gotban, %setban, %foul, $days, $oldtime, $lastline, $actions,
-$normals, %T, $repeated, $lastnormal, %shout, %slap, %slapped, %words);
+$normals, %T, $repeated, $lastnormal, %shout, %slap, %slapped, %words,
+%line_time);
 
 
 
 
 sub main
 sub main
@@ -198,6 +211,7 @@ sub init_pisg
     undef %slap; 
     undef %slap; 
     undef %slapped; 
     undef %slapped; 
     undef %words; 
     undef %words; 
+    undef %line_time; 
 
 
 
 
     $timestamp = time;
     $timestamp = time;
@@ -434,7 +448,7 @@ sub parse_file
                 unless (grep /^\Q$nick\E$/i, @ignore) {
                 unless (grep /^\Q$nick\E$/i, @ignore) {
                     $normals++;
                     $normals++;
                     $line{$nick}++;
                     $line{$nick}++;
-
+                    $line_time{$nick}[int($hour/6)]++;
                     # Count up monologues
                     # Count up monologues
 
 
                     if ($lastline eq $nick) {
                     if ($lastline eq $nick) {
@@ -517,6 +531,7 @@ sub parse_file
             unless (grep /^\Q$nick\E$/i, @ignore) {
             unless (grep /^\Q$nick\E$/i, @ignore) {
                 $actions++;
                 $actions++;
                 $line{$nick}++;
                 $line{$nick}++;
+                $line_time{$nick}[int($hour/6)]++;
 
 
                 if($saying =~ /^slaps (\S+)/) {
                 if($saying =~ /^slaps (\S+)/) {
                     $slap{$nick}++;
                     $slap{$nick}++;
@@ -1008,6 +1023,12 @@ sub create_html
 
 
     open (OUTPUT, "> $conf->{outputfile}") or die("$0: Unable to open outputfile($conf->{outputfile}): $!\n");
     open (OUTPUT, "> $conf->{outputfile}") or die("$0: Unable to open outputfile($conf->{outputfile}): $!\n");
 
 
+    if ($conf->{show_time}) {
+        $conf->{tablewidth} += 40;
+    }
+    if ($conf->{show_words}) {
+        $conf->{tablewidth} += 40;
+    }
     if ($conf->{show_wpl}) {
     if ($conf->{show_wpl}) {
         $conf->{tablewidth} += 40;
         $conf->{tablewidth} += 40;
     }
     }
@@ -1081,11 +1102,9 @@ sub activetimes
 
 
     for my $hour (sort keys %times) {
     for my $hour (sort keys %times) {
         debug("Time: $hour => ". $times{$hour});
         debug("Time: $hour => ". $times{$hour});
-        if ($toptime[0] == $hour) {
-            $image = $conf->{pic2};
-        } else {
-            $image = $conf->{pic1};
-        }
+	$image = "pic_v_".(int($hour/6)*6);
+	$image = $conf->{$image};
+	debug("Image: $image");
 
 
         my $size = ($times{$hour} / $highest_value) * 100;
         my $size = ($times{$hour} / $highest_value) * 100;
         my $percent = ($times{$hour} / $lines) * 100;
         my $percent = ($times{$hour} / $lines) * 100;
@@ -1147,6 +1166,8 @@ sub activenicks
         . template_text('nick') . "</b></td><td bgcolor=\"$conf->{tdtop}\"><b>"
         . template_text('nick') . "</b></td><td bgcolor=\"$conf->{tdtop}\"><b>"
 	. template_text('numberlines') 
 	. template_text('numberlines') 
         . "</b></td><td bgcolor=\"$conf->{tdtop}\"><b>"
         . "</b></td><td bgcolor=\"$conf->{tdtop}\"><b>"
+	. ($conf->{show_time} ? template_text('show_time')."</b></td><td bgcolor=\"$conf->{tdtop}\"><b>" : "") 
+	. ($conf->{show_words} ? template_text('show_words')."</b></td><td bgcolor=\"$conf->{tdtop}\"><b>" : "") 
 	. ($conf->{show_wpl} ? template_text('show_wpl')."</b></td><td bgcolor=\"$conf->{tdtop}\"><b>" : "") 
 	. ($conf->{show_wpl} ? template_text('show_wpl')."</b></td><td bgcolor=\"$conf->{tdtop}\"><b>" : "") 
 	. ($conf->{show_cpl} ? template_text('show_cpl')."</b></td><td bgcolor=\"$conf->{tdtop}\"><b>" : "") 
 	. ($conf->{show_cpl} ? template_text('show_cpl')."</b></td><td bgcolor=\"$conf->{tdtop}\"><b>" : "") 
         . template_text('randquote') ."</b></td>");
         . template_text('randquote') ."</b></td>");
@@ -1203,9 +1224,18 @@ sub activenicks
 
 
         html("<tr><td bgcolor=\"$conf->{rankc}\" align=\"left\">");
         html("<tr><td bgcolor=\"$conf->{rankc}\" align=\"left\">");
         my $line = $line{$nick};
         my $line = $line{$nick};
-	my $w    = $words{$nick};
-	my $ch   = $length{$nick};
-        html("$i</td><td bgcolor=\"#$col_r$col_g$col_b\">$visiblenick</td><td bgcolor=\"#$col_r$col_g$col_b\">$line</td>"
+        my $w    = $words{$nick};
+        my $ch   = $length{$nick};
+        html("$i</td><td bgcolor=\"#$col_r$col_g$col_b\">$visiblenick</td>"
+        . ($conf->{show_linetime} ?
+           "<td bgcolor=\"$col_r$col_g$col_b\">".user_linetimes($nick,$active[0])."</td>"
+           : "<td bgcolor=\"#$col_r$col_g$col_b\">$line</td>")
+	. ($conf->{show_time} ?
+	 "<td bgcolor=\"$col_r$col_g$col_b\">".user_times($nick)."</td>"
+	 : "")
+	. ($conf->{show_words} ? 
+	 "<td bgcolor=\"#$col_r$col_g$col_b\">$w</td>"
+	 : "")
 	. ($conf->{show_wpl} ? 
 	. ($conf->{show_wpl} ? 
 	 "<td bgcolor=\"#$col_r$col_g$col_b\">".sprintf("%.1f",$w/$line)."</td>"
 	 "<td bgcolor=\"#$col_r$col_g$col_b\">".sprintf("%.1f",$w/$line)."</td>"
 	 : "")
 	 : "")
@@ -1246,6 +1276,39 @@ sub activenicks
 
 
 }
 }
 
 
+sub user_linetimes {
+    my $nick = shift;
+    my $top  = shift;
+    my $bar   = "";
+    my $len = ($line{$nick} / $line{$top}) * 100;
+    my $debuglen = 0;
+    for (my $i = 0; $i <= 3; $i++) {
+        next if not defined $line_time{$nick}[$i];
+        my $w = int(($line_time{$nick}[$i] / $line{$nick}) * $len);
+	$debuglen += $w;
+        if ($w) {
+            my $pic = 'pic_h_'.(6*$i);
+            $bar .= "<img src=\"$conf->{$pic}\" border=\"0\" width=\"$w\" height=\"15\">";
+        }
+    }
+    debug("Length='$len', Sum='$debuglen'");
+    return "$bar$line{$nick}";
+}
+
+sub user_times {
+    my $nick = shift;
+    my $bar   = "";
+    for (my $i = 0; $i <= 3; $i++) {
+        next if not defined $line_time{$nick}[$i];
+        my $w = int(($line_time{$nick}[$i] / $line{$nick}) * 40);
+        if ($w) {
+            my $pic = 'pic_h_'.(6*$i);
+            $bar .= "<img src=\"$conf->{$pic}\" border=\"0\" width=\"$w\" height=\"20\">";
+        }
+    }
+    return $bar;
+}
+
 sub mostusedword
 sub mostusedword
 {
 {
     # Lao the infamous word usage statistics
     # Lao the infamous word usage statistics