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

Change ignores to use $users->{ignores} rather than $conf->{ignores} since it is in user statements.

Also, add support for setting sex in pisg.cfg
sbingner 25 лет назад
Родитель
Сommit
0671317405
1 измененных файлов с 24 добавлено и 11 удалено
  1. 24 11
      pisg.pl

+ 24 - 11
pisg.pl

@@ -329,7 +329,11 @@ sub init_config
                 }
                 }
 
 
                 if ($line =~ /ignore="Y"/i) {
                 if ($line =~ /ignore="Y"/i) {
-                    $conf->{ignores}{$nick} = 1;
+                    $users->{ignores}{$nick} = 1;
+                }
+
+                if ($line =~ /sex="([MmFf])"/i) {
+                    $users->{sex}{$nick} = lc($1);
                 }
                 }
 
 
             } elsif ($line =~ /<set(.*)>/) {
             } elsif ($line =~ /<set(.*)>/) {
@@ -450,7 +454,7 @@ sub parse_file
                 # Timestamp collecting
                 # Timestamp collecting
                 $times{$hour}++;
                 $times{$hour}++;
 
 
-                unless ($conf->{ignores}{$nick}) {
+                unless ($users->{ignores}{$nick}) {
                     $normals++;
                     $normals++;
                     $line{$nick}++;
                     $line{$nick}++;
                     $line_time{$nick}[int($hour/6)]++;
                     $line_time{$nick}[int($hour/6)]++;
@@ -530,7 +534,7 @@ sub parse_file
             $times{$hour}++;
             $times{$hour}++;
             $line = strip_mirccodes($line);
             $line = strip_mirccodes($line);
 
 
-            unless ($conf->{ignores}{$nick}) {
+            unless ($users->{ignores}{$nick}) {
                 $actions++;
                 $actions++;
                 $actions{$nick}++;
                 $actions{$nick}++;
                 $actionline{$nick} = $line;
                 $actionline{$nick} = $line;
@@ -571,10 +575,10 @@ sub parse_file
             $times{$hour}++;
             $times{$hour}++;
             $line = strip_mirccodes($line);
             $line = strip_mirccodes($line);
 
 
-            unless ($conf->{ignores}{$nick}) {
+            unless ($users->{ignores}{$nick}) {
 
 
                 if (defined($kicker)) {
                 if (defined($kicker)) {
-                    unless ($conf->{ignores}{$kicker}) {
+                    unless ($users->{ignores}{$kicker}) {
                         $gotkick{$nick}++;
                         $gotkick{$nick}++;
                         $kicked{$kicker}++;
                         $kicked{$kicker}++;
                         $kickline{$nick} = $line;
                         $kickline{$nick} = $line;
@@ -897,7 +901,7 @@ sub parse_words
         # ignore contractions
         # ignore contractions
         next if ($word =~ m/'..?$/);
         next if ($word =~ m/'..?$/);
 
 
-        $wordcount{$word}++ unless ($conf->{ignores}{$word});
+        $wordcount{$word}++ unless ($users->{ignores}{$word});
         $lastused{$word} = $nick;
         $lastused{$word} = $nick;
     }
     }
 
 
@@ -956,20 +960,29 @@ sub template_text
 
 
     my $text;
     my $text;
 
 
-    $text = $T{$conf->{lang}}{$template};
-
-    if (!$T{$conf->{lang}}{$template}) {
+    unless ($text = $T{$conf->{lang}}{$template}) {
         # Fall back to English if the language template doesn't exist
         # Fall back to English if the language template doesn't exist
 
 
-        if ($T{EN}{$template}) {
+        if ($text = $T{EN}{$template}) {
             print "Note: There was no translation in $conf->{lang} for '$template' - falling back to English..\n";
             print "Note: There was no translation in $conf->{lang} for '$template' - falling back to English..\n";
-            $text = $T{EN}{$template};
         } else {
         } else {
             die("No such template '$template' in language file.\n");
             die("No such template '$template' in language file.\n");
         }
         }
 
 
     }
     }
 
 
+    if ($hash{nick}) {
+        if ($users->{sex}{$hash{nick}}) {
+            $hash{posessive} = template_text($users->{sex}{$hash{nick}} . "posessive");
+            $hash{subj} = template_text($users->{sex}{$hash{nick}} . "subj");
+            $hash{sex} = template_text($users->{sex}{$hash{nick}} . "sex");
+        } else {
+            $hash{posessive} = template_text("uposessive");
+            $hash{subj} = template_text("usubj");
+            $hash{sex} = template_text("usex");
+        }
+    }
+
     foreach my $key (sort keys %hash) {
     foreach my $key (sort keys %hash) {
         $text =~ s/\[:$key\]/$hash{$key}/;
         $text =~ s/\[:$key\]/$hash{$key}/;
         $text =~ s/ü/&uuml;/g;
         $text =~ s/ü/&uuml;/g;