]> git.vpit.fr Git - perl/scripts/xchat.git/blob - hl.pl
Complete the highlight list
[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.04';
13
14 my $ph;
15
16 sub guihl {
17  command 'GUI FLASH';
18  command 'GUI COLOR 3';
19 }
20
21 sub guiclear {
22  command 'GUI COLOR 0';
23 }
24
25 hook_print 'Private Message to Dialog', sub { guihl; return EAT_NONE };
26
27 my %hl = (
28  '#cpantesters' => [ qw/
29     Acme-CPANAuthors-You-re_using
30     B-RecDeparse
31     Bit-MorseSignals
32     CPANPLUS-Dist-Gentoo
33     IPC-MorseSignals
34     Lexical-Types
35     Linux-SysInfo
36     Perl-Critic-Policy-Dynamic-NoIndirect
37     Regexp-Wildcards
38     Scalar-Vec-Util
39     Scope-Upper
40     Sub-Nary
41     Sub-Op
42     Sub-Prototype-Util
43     Test-Valgrind
44     Thread-Cleanup
45     Variable-Magic
46     autovivification-
47     indirect-
48     rgit-
49     subs-auto
50     \bwith-
51   / ],
52 );
53
54 for (keys %hl) {
55  my $rx = '(?:' . join('|', @{$hl{$_}}) . ')';
56  $hl{$_} =  qr/$rx/;
57 }
58
59 filter 'Channel Action' => sub {
60  my $chan = lc get_info 'channel';
61  if ($hl{$chan} and $_[1] =~ /$hl{$chan}/) {
62   guihl;
63   1;
64  } else {
65   0;
66  }
67 } => 'Channel Action Hilight';
68
69 my %skip = (
70  '#p5p' => [
71    '(?i:jesse.vincent)',
72  ],
73 );
74
75 for (keys %skip) {
76  my $rx = '(?:' . join('|', @{$skip{$_}}) . ')';
77  $skip{$_} =  qr/$rx/;
78 }
79
80 filter 'Channel Action Hilight' => sub {
81  my $chan = lc get_info 'channel';
82  if ($skip{$chan} and $_[1] =~ /$skip{$chan}/) {
83   guiclear;
84   1;
85  } else {
86   0;
87  }
88 } => 'Channel Action';
89
90 $ph = Xchat::XPI->new(
91  name   => 'Smart highlighting',
92  tag    => 'HL',
93  desc   => 'Highlight on private messages',
94  author => 'Vincent Pit (VPIT)',
95  email  => 'perl@profvince.com',
96  url    => 'http://www.profvince.com',
97 );
98  
99 1;
100