use strict;
use Irssi;
use vars qw($VERSION %IRSSI); 
$VERSION = "1.00";
%IRSSI = (
    authors     => "f0rked",
    contact     => "root\@f0rked.com", 
    name        => "hilightcmd",
    description => "Executes command on hilight",
    license     => "Public Domain",
    url         => "http://f0rked.com",
    changed     => "2005-06-16"
);

# Command to run on hilight
my $cmd = "~/save/notify.sh &";
# Run the command when away?
my $run_cmd_when_away = 0;

sub sig_printtext {
    my ($dest, $text, $stripped) = @_;
    my $server = $dest->{server};
    
    # Do not run the command if we're not supposed to when away
    if ($server->{usermode_away} && !$run_cmd_when_away) { return; }

    # Run the command if we're hilighted
    if (($dest->{level} & (MSGLEVEL_HILIGHT)) && ($dest->{level} & MSGLEVEL_NOHILIGHT) == 0) {
        system($cmd);
    }
}

Irssi::signal_add("print text",\&sig_printtext);
