1 # Automatically colors personals by hashing the username. Inspired by geofft's
2 # .bashrc. Needs a lot of tweaking to make perfect...
5 # :perl do '/mit/snippets/barnowl/personal-colors.pl'
8 package BarnOwl::Style::Colors;
9 our @ISA=qw(BarnOwl::Style::Default);
12 sub description {"Colors for personals";}
17 my $body = $self->indent_body($m);
18 if ($m->is_personal) {
19 my @colors = qw{red green blue yellow magenta cyan};
20 my $hash = ord Digest::MD5::md5(($m->direction eq "out") ? $m->pretty_recipient : $m->pretty_sender);
21 $body = '@[@color(' . $colors[$hash % scalar @colors] . ")$body]";
23 return $self->chat_header($m) . "\n". $body;
26 BarnOwl::create_style("colors", "BarnOwl::Style::Colors");