Преглед изворни кода

restore/save aliases on every channel

Morten Brix Pedersen пре 24 година
родитељ
комит
36dadfbadc
2 измењених фајлова са 27 додато и 1 уклоњено
  1. 5 0
      modules/Pisg.pm
  2. 22 1
      modules/Pisg/Common.pm

+ 5 - 0
modules/Pisg.pm

@@ -443,6 +443,10 @@ sub do_channel
     } else {
     } else {
         $self->init_pisg();        # Init some general things
         $self->init_pisg();        # Init some general things
 
 
+        store_aliases();           # Save the aliases so we can restore them
+                                   # later, we don't want to add the aliases
+                                   # for this channel to the next channel
+
         # Pick our stats generator.
         # Pick our stats generator.
         my $analyzer;
         my $analyzer;
         eval <<_END;
         eval <<_END;
@@ -481,6 +485,7 @@ _END
         } elsif ($stats->{totallines} == 0) {
         } elsif ($stats->{totallines} == 0) {
             print STDERR "No lines found in logfile.. skipping.\n";
             print STDERR "No lines found in logfile.. skipping.\n";
         }
         }
+        restore_aliases();
 
 
         $self->{cfg}->{chan_done}{$self->{cfg}->{channel}} = 1;
         $self->{cfg}->{chan_done}{$self->{cfg}->{channel}} = 1;
     }
     }

+ 22 - 1
modules/Pisg/Common.pm

@@ -8,12 +8,13 @@ Pisg::Common - some common functions of pisg.
 
 
 use Exporter;
 use Exporter;
 @ISA = ('Exporter');
 @ISA = ('Exporter');
-@EXPORT = qw(add_alias add_aliaswild add_ignore add_url_ignore is_ignored url_is_ignored find_alias match_urls match_email htmlentities);
+@EXPORT = qw(add_alias add_aliaswild add_ignore add_url_ignore is_ignored url_is_ignored find_alias store_aliases restore_aliases match_urls match_email htmlentities);
 
 
 use strict;
 use strict;
 $^W = 1;
 $^W = 1;
 
 
 my (%aliases, %aliaswilds, %ignored, %aliasseen, %ignored_urls, %url_seen);
 my (%aliases, %aliaswilds, %ignored, %aliasseen, %ignored_urls, %url_seen);
+my (%aliases2, %aliaswilds2, %ignored2, %aliasseen2, %ignored_urls2, %url_seen2);
 
 
 # add_alias assumes that the first argument is the true nick and the second is
 # add_alias assumes that the first argument is the true nick and the second is
 # the alias, but will accomidate other arrangements if necessary.
 # the alias, but will accomidate other arrangements if necessary.
@@ -102,6 +103,26 @@ sub find_alias
     return $nick;
     return $nick;
 }
 }
 
 
+sub store_aliases
+{
+    %aliases2 = %aliases;
+    %aliaswilds2 = %aliaswilds;
+    %ignored2 = %ignored;
+    %aliasseen2 = %aliasseen;
+    %ignored_urls2 = %ignored_urls;
+    %url_seen2 = %url_seen;
+}
+
+sub restore_aliases
+{
+    %aliases = %aliases2;
+    %aliaswilds = %aliaswilds2;
+    %ignored = %ignored2;
+    %aliasseen = %aliasseen2;
+    %ignored_urls = %ignored_urls2;
+    %url_seen = %url_seen2;
+}
+
 sub match_urls
 sub match_urls
 {
 {
     my $str = shift;
     my $str = shift;