Skip to content

Instantly share code, notes, and snippets.

@startling
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save startling/9574066 to your computer and use it in GitHub Desktop.
Save startling/9574066 to your computer and use it in GitHub Desktop.
use strict;
use warnings;
use Irssi;
our $VERSION = "0.0";
our %IRSSI = (
authors => "startling",
contact => "tdixon51793\@gmail.com",
name => "Renotify",
description => "Trigger OS X 10.8's Notification Center on certain events.",
license => "MIT",
url => "https://gist.github.com/startling/9574066",
changed => "Sat 15 Mar 2014"
);
sub notify {
my ($title, $data) = @_;
my @command = ("terminal-notifier", "-message", $data, "-title", $title || "irc");
return system(@command);
}
sub notify_privmsg {
my($server, $data, $nick, $host) = @_;
# If we're subscribed to privmsgs, notify us.
if (Irssi::settings_get_str('notify_on_privmsg')) {
notify($nick, $data);
}
Irssi::signal_continue(@_);
}
sub notify_msg {
my ($server, $data, $nick, $host) = @_;
my $me = $server->{nick};
# If we're subscribed to all messages or if we're subscribed to our
# nick and the message contains it, notify us.
if ($nick ne $me
&& (Irssi::settings_get_str('notify_on_msg')
|| (Irssi::settings_get_str('notify_on_nick') && $data =~ /$me/))) {
notify($nick, $data);
}
Irssi::signal_continue(@_);
}
Irssi::settings_add_str('renotify', 'notify_on_nick', 1);
Irssi::settings_add_str('renotify', 'notify_on_msg', 0);
Irssi::settings_add_str('renotify', 'notify_on_privmsg', 1);
Irssi::signal_add('message private', 'notify_privmsg');
Irssi::signal_add('message public', 'notify_msg');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment