Przeglądaj źródła

ShowFoulLine option added by Adam Spiers <adam@spiers.net>

Morten Brix Pedersen 24 lat temu
rodzic
commit
df227999c7

+ 3 - 0
docs/Changelog

@@ -4,6 +4,9 @@ pisg (x.xx)
    * Foul-words matching is now more strict. It no longer matches inside a
    * 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
      word, but only in the end or at the start of a word (thanks, Matthew
      Cheetah Gabeler-Lee <msg2@po.cwru.edu>)
      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>)
 
 
 pisg (0.38) - Thu Apr, 25th 2002
 pisg (0.38) - Thu Apr, 25th 2002
    * Grammar fixes in documentation (thanks, Azhrarn <diablo2@krock.com>)
    * Grammar fixes in documentation (thanks, Azhrarn <diablo2@krock.com>)

+ 1 - 0
docs/dev/API

@@ -27,6 +27,7 @@ shouts        hash   <nick>  Number of lines ending in exclamation points.
 allcaps       hash   <nick>  Number of lines in ALL CAPS.
 allcaps       hash   <nick>  Number of lines in ALL CAPS.
 allcaplines   hash   <nick>  Random line containing ALL CAPS.
 allcaplines   hash   <nick>  Random line containing ALL CAPS.
 foul          hash   <nick>  Number of lines containing foul words.
 foul          hash   <nick>  Number of lines containing foul words.
+foullines     hash   <nick>  Lines containing foul words.
 smiles        hash   <nick>  Number of lines containing smiling faces.
 smiles        hash   <nick>  Number of lines containing smiling faces.
 frowns        hash   <nick>  Number of lines containing sad faces.
 frowns        hash   <nick>  Number of lines containing sad faces.
 urlcounts     hash   <url>   Number of times each URL was mentioned.
 urlcounts     hash   <url>   Number of times each URL was mentioned.

+ 35 - 0
docs/pisg-doc.sgml

@@ -1336,6 +1336,41 @@
     </refsect1>
     </refsect1>
     </refentry>
     </refentry>
 
 
+    <!-- *** SHOWFOULLINE *** -->
+    <refentry id="ShowFoulLine">
+
+    <refmeta> <refentrytitle>ShowFoulLine</refentrytitle> </refmeta>
+
+    <refnamediv>
+    <refname>ShowFoulLine</refname>
+    <refpurpose>enable or disable the foulline</refpurpose>
+    </refnamediv>
+
+    <refsynopsisdiv><programlisting>
+      <![CDATA[
+        <channel="#channel">
+         Logfile = "channel.log"
+         Format = "bobot"
+         ShowFoulLine = "0"
+        </channel>
+
+        <set ShowFoulLine="1">
+      ]]>
+    </programlisting></refsynopsisdiv>
+
+    <refsect1>
+    <title>Description</title>
+    <para>
+    By default, pisg doesn't show an example foulline in the "Most
+    fouls"-stats.  With this option it can be enabled.
+    </para>
+    </refsect1>
+    <refsect1>
+    <title>Default</title>
+    <para> 0 (disabled) </para>
+    </refsect1>
+    </refentry>
+
     <!-- *** SHOWVIOLENTLINES *** -->
     <!-- *** SHOWVIOLENTLINES *** -->
     <refentry id="ShowViolentLines">
     <refentry id="ShowViolentLines">
 
 

+ 2 - 1
lang.txt

@@ -97,9 +97,10 @@ long2 = "[:channel] average was [:avg] letters per line."
 short1 = "<b>[:nick]</b> wrote the shortest lines, averaging [:letters] characters per line."
 short1 = "<b>[:nick]</b> wrote the shortest lines, averaging [:letters] characters per line."
 short2 = "<b>[:nick]</b> was tight-lipped, too, averaging [:letters] characters."
 short2 = "<b>[:nick]</b> was tight-lipped, too, averaging [:letters] characters."
 
 
-foul1 = "<b>[:nick]</b> has quite a potty mouth.  [:per]% lines contained foul language."
+foul1 = "<b>[:nick]</b> has quite a potty mouth.  [:per]% words were foul language."
 foul2 = "<b>[:nick]</b> also makes sailors blush, [:per]% of the time."
 foul2 = "<b>[:nick]</b> also makes sailors blush, [:per]% of the time."
 foul3 = "Nobody is foul-mouthed in [:channel]!  Get out much?"
 foul3 = "Nobody is foul-mouthed in [:channel]!  Get out much?"
+foultext = "For example, like this:</b><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[:line]"
 
 
 smiles1 = "<b>[:nick]</b> brings happiness to the world.  [:per]% lines contained smiling faces.  :)"
 smiles1 = "<b>[:nick]</b> brings happiness to the world.  [:per]% lines contained smiling faces.  :)"
 smiles2 = "<b>[:nick]</b> isn't a sad person either, smiling [:per]% of the time."
 smiles2 = "<b>[:nick]</b> isn't a sad person either, smiling [:per]% of the time."

+ 1 - 0
modules/Pisg.pm

@@ -140,6 +140,7 @@ sub get_default_config_settings
         showlegend => 1,
         showlegend => 1,
         showkickline => 1,
         showkickline => 1,
         showactionline => 1,
         showactionline => 1,
+        showfoulline => 0,
         showshoutline => 1,
         showshoutline => 1,
         showviolentlines => 1,
         showviolentlines => 1,
         showrandquote => 1,
         showrandquote => 1,

+ 9 - 3
modules/Pisg/HTMLGenerator.pm

@@ -984,7 +984,7 @@ sub _mostfoul
 
 
     foreach my $nick (sort keys %{ $self->{stats}->{foul} }) {
     foreach my $nick (sort keys %{ $self->{stats}->{foul} }) {
         if ($self->{stats}->{lines}{$nick} > 15) {
         if ($self->{stats}->{lines}{$nick} > 15) {
-            $spercent{$nick} = $self->{stats}->{foul}{$nick} / $self->{stats}->{lines}{$nick} * 100;
+            $spercent{$nick} = $self->{stats}->{foul}{$nick} / $self->{stats}->{words}{$nick} * 100;
             $spercent{$nick} =~ s/(\.\d)\d+/$1/;
             $spercent{$nick} =~ s/(\.\d)\d+/$1/;
         }
         }
     }
     }
@@ -995,12 +995,18 @@ sub _mostfoul
 
 
         my %hash = (
         my %hash = (
             nick => $foul[0],
             nick => $foul[0],
-            per  => $spercent{$foul[0]}
+            per  => $spercent{$foul[0]},
+            line => $self->{stats}{foullines}{$foul[0]},
         );
         );
 
 
         my $text = $self->_template_text('foul1', %hash);
         my $text = $self->_template_text('foul1', %hash);
 
 
-        _html("<tr><td class=\"hicell\">$text");
+        if($self->{cfg}->{showfoulline}) {
+            my $exttext = $self->_template_text('foultext', %hash);
+            _html("<tr><td class=\"hicell\">$text<br /><span class=\"small\">$exttext</span><br />");
+        } else {
+            _html("<tr><td class=\"hicell\">$text");
+        }
 
 
         if (@foul >= 2) {
         if (@foul >= 2) {
             my %hash = (
             my %hash = (

+ 5 - 2
modules/Pisg/Parser/Logfile.pm

@@ -270,8 +270,11 @@ sub _parse_file
                         }
                         }
                     }
                     }
 
 
-                    $stats->{foul}{$nick}++
-                        if ($saying =~ /(\b$self->{cfg}->{foulwords}|$self->{cfg}->{foulwords}\b)/io);
+                    if (my @foul = $saying =~ /(\b$self->{cfg}->{foulwords}|$self->{cfg}->{foulwords}\b)/io) {
+                        $stats->{foul}{$nick} += scalar @foul;
+                        push @{ $lines->{foullines}{$nick} }, $saying;
+                    }
+
 
 
                     # Who smiles the most?
                     # Who smiles the most?
                     # A regex matching al lot of smilies
                     # A regex matching al lot of smilies