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