فهرست منبع

Patch from Hanno to also count words in actions, and to make new feature
'mostwords'

Morten Brix Pedersen 25 سال پیش
والد
کامیت
26452d45a5
2فایلهای تغییر یافته به همراه54 افزوده شده و 2 حذف شده
  1. 7 0
      lang.txt
  2. 47 2
      pisg.pl

+ 7 - 0
lang.txt

@@ -56,6 +56,10 @@ kick1 = "<b>[:nick]</b> is insane or just a fair op, kicked a total of [:kicked]
 kick2 = "[:oldnick]'s faithfull follower, <b>[:nick]</b>, kicked about [:kicked] people"
 kick3 = "Nice oppers here, no one got kicked!"
 
+words1 = "<b>[:nick]</b> spoke a total of [:words] words!"
+words2 = "[:oldnick]'s faithfull follower, <b>[:nick]</b>, didn't speak su much: [:words] words."
+words3 = "Nobody said anything... what a strange channel..."
+
 mono1 = "<b>[:nick]</b> is talking to himself a lot, wrote over 5 lines in a row [:monos] times!"
 mono2 = "Another lonely one was <b>[:nick]</b>, who managed to hit [:monos] times"
 
@@ -144,6 +148,9 @@ joins = "<b>[:nick]</b> konnte sich nicht entscheiden im Channel zu bleiben oder
 kick1 = "Ist <b>[:nick]</b> jetzt einfach nur ein fairer Op oder macht ihm/ihr das Spass? Er/Sie kickte [:kicked] User!"
 kick2 = "[:oldnick]'s würdiger Nachfolger, <b>[:nick]</b>, er/sie kickte [:kicked] User."
 kick3 = "Nette Opper hier, niemand wurde gekickt!"
+words1 = "<b>[:nick]</b> war mit [:words] Worten sehr mitteilungsbedürftig!"
+words2 = "[:oldnick]'s würdiger Nachfolger, <b>[:nick]</b>, schaffte es auf immerhin [:words] Worte"
+words3 = "Niemand hat etwas gesagt? Seltsamer Channel..."
 
 mono1 = "<b>[:nick]</b> spricht viel mit sich selbst, er/sie schrieb über 5 Zeilen in einer Reihe und das [:monos] mal!"
 mono2 = "Ein anderes einsames Herz ist <b>[:nick]</b>, der/die [:monos] mal mit sich selbst redete."

+ 47 - 2
pisg.pl

@@ -101,7 +101,8 @@ $normalline, $actionline, $thirdline, @ignore, $line, $processtime, @topics,
 %smile, $nicks, %longlines, %mono, %times, %question, %loud, $totallength,
 %gaveop, %tookop, %joins, %actions, %sayings, %wordcount, %lastused, %gotban,
 %setban, %foul, $days, $oldtime, $lastline, $actions, $normals, %userpics,
-%userlinks, %T, $repeated, $lastnormal, $foulwords, %shout, %spercent, %slap, %slapped, $slaps);
+%userlinks, %T, $repeated, $lastnormal, $foulwords, %shout, %spercent,
+%slap, %slapped, $slaps, %words);
 
 sub main
 {
@@ -413,6 +414,7 @@ sub parse_file
                         if ($saying =~ /\w+:\/\//);
 
                     foreach my $word (split(/[\s,!?.:;)(]+/, $saying)) {
+                        $words{$nick}++;
                         # remove uninteresting words
                         next unless (length($word) >= $conf->{wordlength});
                         # ignore contractions
@@ -455,6 +457,16 @@ sub parse_file
                 my $len = length($saying);
                 $length{$nick} += $len;
                 $totallength += $len;
+                foreach my $word (split(/[\s,!?.:;)(]+/, $saying)) {
+                    $words{$nick}++;
+                    # remove uninteresting words
+                    next unless (length($word) > $conf->{wordlength});
+                    # ignore contractions
+                    next if ($word =~ m/'..?$/);
+
+                    $wordcount{htmlentities($word)}++ unless (grep /^\Q$word\E$/i, @ignore);
+                    $lastused{htmlentities($word)} = $nick;
+                }
             }
         }
 
@@ -845,7 +857,7 @@ sub template_text
     $text = $T{$conf->{lang}}{$template};
 
     if (!$text) {
-        die("No such template $template\n");
+        die("No such template '$template' in language file.\n");
     }
 
     foreach my $key (sort keys %hash) {
@@ -932,6 +944,7 @@ sub create_html
     mostsad();
     longlines();
     shortlines();
+    mostwords();
     html("</table>"); # Needed for sections
 
     mostusedword();
@@ -1420,6 +1433,38 @@ sub mostjoins
     }
 }
 
+sub mostwords
+{
+     # The person who got words the most
+
+     my @words = sort { $words{$b} <=> $words{$a} } keys %words;
+
+     if (@words) {
+         my %hash = (
+             nick => $words[0],
+             words => $words{$words[0]}
+         );
+
+         my $text = template_text('words1', %hash);
+         html("<tr><td bgcolor=\"$conf->{hicell}\">$text");
+
+         if (@words >= 2) {
+         my %hash = (
+             oldnick => $words[0],
+             nick => $words[1],
+             words => $words{$words[1]}
+         );
+
+         my $text = template_text('words2', %hash);
+             html("<br><span class=\"small\">$text</span>");
+         }
+         html("</td></tr>");
+     } else {
+         my $text = template_text('kick3');
+         html("<tr><td bgcolor=\"$conf->{hicell}\">$text</td></tr>");
+     }
+
+}
 
 sub mostkicks
 {