]> git.vpit.fr Git - perl/scripts/xchat.git/blob - hl.pl
Implement HGREP
[perl/scripts/xchat.git] / hl.pl
1 package Xchat::VPIT::Highlight;
2
3 use strict;
4 use warnings;
5
6 use Xchat qw/:all/;
7
8 use lib get_info 'xchatdir';
9 use Xchat::XPI;
10 use Xchat::XPI::Events qw/filter/;
11
12 our $VERSION = '0.02';
13
14 my $ph;
15
16 sub guihl {
17  command 'GUI FLASH';
18  command 'GUI COLOR 3';
19 }
20
21 hook_print 'Private Message to Dialog', sub { guihl; return EAT_NONE };
22
23 my %words = (
24  '#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/ ]
25 );
26
27 for (keys %words) {
28  my $rx = '(?:' . (join '|', @{$words{$_}}) . ')';
29  $words{$_} =  qr/$rx/;
30 }
31
32 filter 'Channel Action' => sub {
33  my $chan = lc get_info 'channel';
34  if ($words{$chan} and $_[1] =~ /$words{$chan}/) {
35   guihl;
36   1;
37  } else {
38   0;
39  }
40 } => 'Channel Action Hilight';
41
42 $ph = new Xchat::XPI name   => 'Smart highlighting',
43                      tag    => 'HL',
44                      desc   => 'Highlight on private messages',
45                      author => 'Vincent Pit (VPIT)',
46                      email  => 'perl@profvince.com',
47                      url    => 'http://www.profvince.com';
48  
49 1;
50