]> git.vpit.fr Git - perl/scripts/xchat.git/blobdiff - hl.pl
Just say no to indirect object notation
[perl/scripts/xchat.git] / hl.pl
diff --git a/hl.pl b/hl.pl
index 1af2f58d2e683d7363cb4a18a443903c5da4233d..fdaaf5cb89477d755e54fc52d7b37c39b0a3539c 100755 (executable)
--- a/hl.pl
+++ b/hl.pl
@@ -9,7 +9,7 @@ use lib get_info 'xchatdir';
 use Xchat::XPI;
 use Xchat::XPI::Events qw/filter/;
 
-our $VERSION = '0.02';
+our $VERSION = '0.03';
 
 my $ph;
 
@@ -18,9 +18,13 @@ sub guihl {
  command 'GUI COLOR 3';
 }
 
+sub guiclear {
+ command 'GUI COLOR 0';
+}
+
 hook_print 'Private Message to Dialog', sub { guihl; return EAT_NONE };
 
-my %words = (
+my %hl = (
  '#cpantesters' => [ qw/
     Acme-CPANAuthors-You-re_using
     B-RecDeparse
@@ -44,14 +48,14 @@ my %words = (
   / ],
 );
 
-for (keys %words) {
- my $rx = '(?:' . (join '|', @{$words{$_}}) . ')';
- $words{$_} =  qr/$rx/;
+for (keys %hl) {
+ my $rx = '(?:' . join('|', @{$hl{$_}}) . ')';
+ $hl{$_} =  qr/$rx/;
 }
 
 filter 'Channel Action' => sub {
  my $chan = lc get_info 'channel';
- if ($words{$chan} and $_[1] =~ /$words{$chan}/) {
+ if ($hl{$chan} and $_[1] =~ /$hl{$chan}/) {
   guihl;
   1;
  } else {
@@ -59,12 +63,35 @@ filter 'Channel Action' => sub {
  }
 } => 'Channel Action Hilight';
 
-$ph = new Xchat::XPI name   => 'Smart highlighting',
-                     tag    => 'HL',
-                     desc   => 'Highlight on private messages',
-                     author => 'Vincent Pit (VPIT)',
-                     email  => 'perl@profvince.com',
-                     url    => 'http://www.profvince.com';
+my %skip = (
+ '#p5p' => [
+   '(?i:jesse.vincent)',
+ ],
+);
+
+for (keys %skip) {
+ my $rx = '(?:' . join('|', @{$skip{$_}}) . ')';
+ $skip{$_} =  qr/$rx/;
+}
+
+filter 'Channel Action Hilight' => sub {
+ my $chan = lc get_info 'channel';
+ if ($skip{$chan} and $_[1] =~ /$skip{$chan}/) {
+  guiclear;
+  1;
+ } else {
+  0;
+ }
+} => 'Channel Action';
+
+$ph = Xchat::XPI->new(
+ name   => 'Smart highlighting',
+ tag    => 'HL',
+ desc   => 'Highlight on private messages',
+ author => 'Vincent Pit (VPIT)',
+ email  => 'perl@profvince.com',
+ url    => 'http://www.profvince.com',
+);
  
 1;