]> git.vpit.fr Git - perl/scripts/xchat.git/blob - Xchat/XPI/Utils.pm
Restyle Xchat::XPI::Utils
[perl/scripts/xchat.git] / Xchat / XPI / Utils.pm
1 package Xchat::XPI::Utils;
2
3 use strict;
4 use warnings;
5
6 use Xchat qw<:all>;
7
8 our $VERSION = '0.02';
9
10 my @rcolors;
11 BEGIN {
12  if (nickcmp(get_info('version'), '2.4.0') < 0) {
13   @rcolors = (3, 4, 6, 8, 9, 10, 11, 12, 13);
14  } else {
15   @rcolors = (19, 20, 22, 24, 25, 26, 27, 28, 29);
16  }
17 }
18
19 sub dye_nick {
20  my $nick = $_[0];
21  my $col  = 0;
22  $col    += ord for split //, $nick;
23  return sprintf "\003%d%s", $rcolors[$col % @rcolors], $nick;
24 }
25
26 use base qw<Exporter>; 
27  
28 our @EXPORT         = ();
29 our %EXPORT_TAGS    = ('funcs' => [ qw<dye_nick> ]);
30 our @EXPORT_OK      = map { @$_ } values %EXPORT_TAGS;
31 $EXPORT_TAGS{'all'} = [ @EXPORT_OK ];
32  
33 1;