#!/usr/bin/perl -w

package IRC::XChat::osd;

my $script_name = "osd.pl";
my $script_version = "0.1";

IRC::register($script_name, $script_version, "", "");

my $pkg = __PACKAGE__;

IRC::add_message_handler("PRIVMSG", "${pkg}::msg_privmsg");

sub osd {
  my $msg = shift;

  $msg = quotemeta($msg);
  system("echo $msg | osd_cat -b -f lucidasanstypewriter-bold-24 -o 80 &");
#  system("beep 2");
}

sub msg_privmsg {
  my $line = shift;
  $line =~ m/\:(.*?)\!(.*?)\sPRIVMSG\s(.*?)\s\:(.*)?/;
  my ($nick, $sender, $type, $msg) = ($1, $2, $3, $4);
  my $me = IRC::get_info(1);

  print("line=$line\n");

  osd("$nick: $msg"), if (($me eq $type) || ($msg =~ /$me/));
}
