X-Git-Url: http://git.vpit.fr/?p=perl%2Fscripts%2Fxchat.git;a=blobdiff_plain;f=hl.pl;h=e4692ef775a2ab2ddaf887bf9fc3e640cd86fc22;hp=c2f32b9f68deb62b11e0db03a44d2098ca52605e;hb=HEAD;hpb=263b6777b90548951a13bd56419fa911b010eb9b diff --git a/hl.pl b/hl.pl index c2f32b9..e4692ef 100755 --- a/hl.pl +++ b/hl.pl @@ -3,48 +3,93 @@ package Xchat::VPIT::Highlight; use strict; use warnings; -use Xchat qw/:all/; +use Xchat qw<:all>; use lib get_info 'xchatdir'; use Xchat::XPI; -use Xchat::XPI::Events qw/filter/; +use Xchat::XPI::Events qw; +use Xchat::XPI::Utils qw; -our $VERSION = '0.02'; +our $VERSION = '0.04'; my $ph; -sub guihl { - command 'GUI FLASH'; - command 'GUI COLOR 3'; -} - -hook_print 'Private Message to Dialog', sub { guihl; return EAT_NONE }; +hook_print 'Private Message to Dialog', sub { + gui 'highlight'; + return EAT_NONE; +}; -my %words = ( - '#cpantesters' => [ qw/Linux-SysInfo MorseSignals Regexp-Wildcards Scalar-Vec-Util Sub-Prototype-Util Test-Valgrind Variable-Magic with- B-RecDeparse Sub-Nary indirect- subs-auto/ ] +my %hl = ( + '#cpantesters' => [ qw< + Acme-CPANAuthors-You-re_using + B-RecDeparse + Bit-MorseSignals + CPANPLUS-Dist-Gentoo + IPC-MorseSignals + Lexical-Types + Linux-SysInfo + Perl-Critic-Policy-Dynamic-NoIndirect + Regexp-Wildcards + Scalar-Vec-Util + Scope-Upper + Sub-Nary + Sub-Op + Sub-Prototype-Util + Test-Valgrind + Thread-Cleanup + Variable-Magic + autovivification- + indirect- + rgit- + subs-auto + \bwith- + > ], ); -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}/) { - guihl; + my $chan = irc_lc get_info 'channel'; + if ($hl{$chan} and $_[1] =~ /$hl{$chan}/) { + gui 'highlight'; 1; } else { 0; } } => '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 = irc_lc get_info 'channel'; + if ($skip{$chan} and $_[1] =~ /$skip{$chan}/) { + gui 'clear'; + 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;