package Xchat::XPI::Utils;

use strict;
use warnings;

use Xchat qw/:all/;

use lib get_info 'xchatdir';
use Xchat::XPI qw/register init/;
 
our $VERSION = '0.02';

sub dye_nick {
 my ($nick, $col) = ($_[0], 0);
 $col += ord for split //, $nick;
 my @rcolors = (nickcmp(get_info('version'), '2.4.0') < 0)
               ? (3, 4, 6, 8, 9, 10, 11, 12, 13)
               : (19, 20, 22, 24, 25, 26, 27, 28, 29);
 $col %= @rcolors;
 return sprintf "\003%d%s", $rcolors[$col], $nick;
}

use base qw/Exporter/; 
 
our @EXPORT         = ();
our %EXPORT_TAGS    = ('funcs' => [ qw/dye_nick/ ]);
our @EXPORT_OK      = map { @$_ } values %EXPORT_TAGS;
$EXPORT_TAGS{'all'} = [ @EXPORT_OK ];
 
1;
