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

complain about b0rked ChartsRegexps

Christoph Berg 21 лет назад
Родитель
Сommit
4e862c703d
3 измененных файлов с 15 добавлено и 11 удалено
  1. 2 1
      docs/Changelog
  2. 3 2
      docs/pisg-doc.xml
  3. 10 8
      modules/Pisg/Parser/Logfile.pm

+ 2 - 1
docs/Changelog

@@ -1,7 +1,8 @@
 pisg (0.67) - ??
 pisg (0.67) - ??
    Christoph:
    Christoph:
    * Features:
    * Features:
-     + Recognize ogg and wma suffixes in song stats.
+     + Recognize ogg and wma suffixes in song stats, complain about invalid
+       ChartsRegexp.
      + Added support for multiple channels in config with the same name.
      + Added support for multiple channels in config with the same name.
        Even multiple channel directives for the very same channel are
        Even multiple channel directives for the very same channel are
        supported (closes SF tracker #967404, patch by Torbjörn Svensson).
        supported (closes SF tracker #967404, patch by Torbjörn Svensson).

+ 3 - 2
docs/pisg-doc.xml

@@ -2968,8 +2968,9 @@
     <title>Description</title>
     <title>Description</title>
     <para>
     <para>
     This option is a perl regexp that is used to recognize songs played. Please
     This option is a perl regexp that is used to recognize songs played. Please
-    tell the pisg mailing list if you have a better default. See also
-    <xref linkend="ShowCharts" /> and <xref linkend="ChartsHistory" />.
+    tell the pisg mailing list if you have a better default. The regexp MUST
+    contain a single () pair to extract the song name. See also the perlre(1)
+    manpage, <xref linkend="ShowCharts" /> and <xref linkend="ChartsHistory" />.
     </para>
     </para>
     </refsect1>
     </refsect1>
     <refsect1>
     <refsect1>

+ 10 - 8
modules/Pisg/Parser/Logfile.pm

@@ -413,14 +413,12 @@ sub _parse_file
                         $stats->{smileynicks}{$1} = $nick;
                         $stats->{smileynicks}{$1} = $nick;
                     }
                     }
 
 
-                    if ($self->{cfg}->{showkarma}) {
-                        # require 2 chars (catches C++), nick must not end in [+=-]
-                        if ($saying =~ /^(\S*\w\S*\w\S*(?<![+=-]))(\+\+|==|--)$/o) {
-                            my $thing = lc $1;
-                            my $k = $2 eq "++" ? 1 : ($2 eq "==" ? 0 : -1);
-                            $stats->{karma}{$thing}{$nick} = $k
-                                if !is_ignored($thing) and $thing ne lc($nick);
-                        }
+                    # require 2 chars (catches C++), nick must not end in [+=-]
+                    if ($saying =~ /^(\S*\w\S*\w\S*(?<![+=-]))(\+\+|==|--)$/o) {
+                        my $thing = lc $1;
+                        my $k = $2 eq "++" ? 1 : ($2 eq "==" ? 0 : -1);
+                        $stats->{karma}{$thing}{$nick} = $k
+                            if !is_ignored($thing) and $thing ne lc($nick);
                     }
                     }
 
 
                     # Find URLs
                     # Find URLs
@@ -657,6 +655,10 @@ sub _parse_words
 sub _charts
 sub _charts
 {
 {
     my ($self, $stats, $Song, $nick) = @_;
     my ($self, $stats, $Song, $nick) = @_;
+    unless (defined $Song) {
+        warn "Your ChartsRegexp is b0rked. Read the manual! This happened";
+        return;
+    }
     $Song =~ s/_/ /g;
     $Song =~ s/_/ /g;
     $Song =~ s/\d+ ?- ?//;
     $Song =~ s/\d+ ?- ?//;
     $Song =~ s/\.(mp3|ogg|wma)//ig;
     $Song =~ s/\.(mp3|ogg|wma)//ig;