Last active
August 29, 2015 13:57
-
-
Save startling/9574066 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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