123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- #!/usr/bin/perl
-
- use v5.10;
- use strict;
- use warnings;
-
- my %config = (
- # You can specify multiple nicknames like, 'berk|bozbalci'. All will be highlighted.
-
- 'nick' => 'mort',
- 'color_nicks' => 'yellow',
- 'color_own_nick' => 'light_red',
- 'color_url' => 'light_blue',
- 'color_actions' => 'magenta',
- 'color_server' => 'black',
- 'color_time' => 'light_green'
- );
-
- my %color = (
- 'black' => "[1;30m",
- 'red' => "[1;31m",
- 'green' => "[1;32m",
- 'yellow' => "[1;33m",
- 'blue' => "[1;34m",
- 'magenta' => "[1;35m",
- 'cyan' => "[1;36m",
- 'white' => "[1;37m",
- 'light_black' => "[30m",
- 'light_red' => "[31m",
- 'light_green' => "[32m",
- 'light_yellow' => "[33m",
- 'light_blue' => "[34m",
- 'light_magenta' => "[35m",
- 'light_cyan' => "[36m",
- 'light_white' => "[37m",
- 'reset' => "[1;0m"
- );
-
- my $date = "[0-9]{4}-[0-9]{2}-[0-9]{2}";
- my $time = "([0-9]{2}:[0-9]{2})";
- my $url = "(((https?|ftp)|mailto):(//)?[^ <>\"[:blank:]]*|(www|ftp)[0-9]?\.[-a-z0-9.]+)";
- my $nick = "<(.*?)>";
- my $action = "ACTION (.*)?";
- my $useless = "^-!- (.*)";
-
- while (<>) {
- # Remove the huge date from the line's beginning
- s/^$date //;
-
- # Highlight time
- s/$time /$color{$config{'color_time'}} $1 $color{'reset'}/;
-
- # Highlight nicknames, remove <> around them
- s/$nick/$color{$config{'color_nicks'}}$1$color{'reset'} /;
-
- # Highlight me
- s/($config{'nick'})/$color{$config{'color_own_nick'}}$1$color{'reset'}/;
-
- # Highlight URLs
- s/$url/$color{$config{'color_url'}}$1$color{'reset'}/;
-
- # Highlight /me actions
- s/$action/$color{$config{'color_actions'}}* $1 *$color{'reset'}/;
-
- # Highlight "has joined", "changed mode", etc.
- s/^$useless/$color{$config{'color_server'}}$1$color{'reset'}/;
-
- # The ^C[color] color sequences:
- s/\cC0(.*)(\cC)?/$color{'white'}$1$color{'reset'}/;
- s/\cC1(.*)(\cC)?/$color{'black'}$1$color{'reset'}/;
- s/\cC2(.*)(\cC)?/$color{'blue'}$1$color{'reset'}/;
- s/\cC3(.*)(\cC)?/$color{'green'}$1$color{'reset'}/;
- s/\cC4(.*)(\cC)?/$color{'light_red'}$1$color{'reset'}/;
- s/\cC5(.*)(\cC)?/$color{'red'}$1$color{'reset'}/;
- s/\cC6(.*)(\cC)?/$color{'magenta'}$1$color{'reset'}/;
- s/\cC7(.*)(\cC)?/$color{'light_yellow'}$1$color{'reset'}/;
- s/\cC8(.*)(\cC)?/$color{'yellow'}$1$color{'reset'}/;
- s/\cC9(.*)(\cC)?/$color{'light_green'}$1$color{'reset'}/;
- s/\cC10(.*)(\cC)?/$color{'cyan'}$1$color{'reset'}/;
- s/\cC11(.*)(\cC)?/$color{'light_cyan'}$1$color{'reset'}/;
- s/\cC12(.*)(\cC)?/$color{'light_blue'}$1$color{'reset'}/;
- s/\cC13(.*)(\cC)?/$color{'light_magenta'}$1$color{'reset'}/;
- s/\cC14(.*)(\cC)?/$color{'black'}$1$color{'reset'}/;
- s/\cC15(.*)(\cC)?/$color{'light_black'}$1$color{'reset'}/;
-
- print;
- }
|