54 lines
1.5 KiB
Perl
54 lines
1.5 KiB
Perl
use Irssi;
|
|
use IO::Pipe;
|
|
use vars qw($VERSION %IRSSI);
|
|
$VERSION = "0.01";
|
|
%IRSSI = (
|
|
authors => 'Jeremy Wall (zaphar) <jeremy@marzhillstudios.com>',
|
|
contact => 'jeremy@marzhillstudios.com',
|
|
name => "hilight-notify",
|
|
description => "outputs a configurable notification for mentions of your name",
|
|
license => "Artistic License",
|
|
url => "http://gist.github.com/",
|
|
changed => "2009-11-14T20:58:00+0600"
|
|
);
|
|
|
|
sub sig_printtext {
|
|
my ($dest, $text, $stripped) = @_;
|
|
|
|
if (($dest->{level} & (MSGLEVEL_HILIGHT|MSGLEVEL_MSGS)) &&
|
|
($dest->{level} & MSGLEVEL_NOHILIGHT) == 0) {
|
|
send_notification($dest->{target}, $text);
|
|
}
|
|
}
|
|
|
|
sub send_notification {
|
|
my $title = shift;
|
|
my $message = shift;
|
|
my $pipe = IO::Pipe->new();
|
|
my $template = Irssi::settings_get_str("hilight_notify_template");
|
|
my @args =
|
|
map { $_ =~ s/\$message/$message/; $_ }
|
|
map { $_ =~ s/\$title/$title/; $_ }
|
|
split / +/, $template;
|
|
$pipe->reader(@args);
|
|
my $result;
|
|
while (<$pipe>) {
|
|
$result = shift;
|
|
}
|
|
}
|
|
|
|
sub _test_notify_me {
|
|
send_notification("jwall", "If you see this it worked");
|
|
}
|
|
|
|
#Irssi::settings_add_str('hilight-notify', 'hilight_notify_template',
|
|
# 'growlatme.pl --app=irssi --title=$title --message=$message');
|
|
|
|
#Irssi::settings_add_str('hilight-notify', 'hilight_notify_template',
|
|
# 'xmessage -timeout 20 <$title>: $message');
|
|
|
|
|
|
#Irssi::command_bind test => \&_test_notify_me;
|
|
|
|
#Irssi::signal_add('print text', 'sig_printtext');
|