#!/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' => "", 'red' => "", 'green' => "", 'yellow' => "", 'blue' => "", 'magenta' => "", 'cyan' => "", 'white' => "", 'light_black' => "", 'light_red' => "", 'light_green' => "", 'light_yellow' => "", 'light_blue' => "", 'light_magenta' => "", 'light_cyan' => "", 'light_white' => "", 'reset' => "" ); 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; }