Created
December 11, 2016 04:18
-
-
Save n8henrie/e0897891772a03dd2291645f389c42b0 to your computer and use it in GitHub Desktop.
irssi script to notify via Notification Center if I'm mentioned by nickname or receive a DM
This file contains hidden or 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
# Script for irssi to trigger macOs Notification Center | |
# Nathan Henrie (modifications, ©2016) | |
# Inspired by https://github.com/paddykontschak/irssi-notifier/blob/master/notifier.pl | |
# | |
# Currently notifies if mentioned by nickname or if PMed | |
# Only sends a static message to avoid arbitrary command execution by `system` | |
# | |
## Installation: | |
# Copy to `~/.irssi/scripts/` (and symlink to `~/.irssi/scripts/autorun` if desired) | |
use strict; | |
use Irssi; | |
use vars qw($VERSION %IRSSI); | |
$VERSION = "0.1.0"; | |
%IRSSI = ( | |
authors => "Nathan Henrie", | |
contact => "nate\@n8henrie.com", | |
name => "Notifier", | |
description => "Script for irssi to trigger macOs Notification Center", | |
license => "MIT", | |
url => "https://n8henrie.com", | |
changed => "Fri 9 Dec 2016 10:02:28 MST" | |
); | |
sub notify { | |
my ($title, $data) = @_; | |
$data =~ s/[^[:alnum:] ]//g; | |
system("osascript -e 'tell application \"Finder\" to display notification \"$data\" with title \"$title\"'"); | |
return 1 | |
} | |
sub nick_notifier { | |
my ($server, $data, $nick, $mask, $target) = @_; | |
my $current_nick = $server->{nick}; | |
if($data =~ /$current_nick/) { | |
notify("irssi", "You were mentioned"); | |
} | |
Irssi::signal_continue($server, $data, $nick, $mask, $target); | |
} | |
sub pm_notifier { | |
my ($server, $data, $nick, $mask, $target) = @_; | |
notify("irssi", "You got a private message"); | |
Irssi::signal_continue($server, $data, $nick, $mask, $target); | |
} | |
Irssi::signal_add('message public', 'nick_notifier'); | |
Irssi::signal_add('message private', 'pm_notifier'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment