-
Notifications
You must be signed in to change notification settings - Fork 0
/
notify.pl
67 lines (58 loc) · 1.82 KB
/
notify.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
##
## NOTIFY plugin
##
## DESCRIPTION:
## This script sends notifications via libnotify on each public
## (channel) or private message. Also it notifies about users
## joining, parting the channels you are currently as well as
## quiting IRC.
##
## INSTALATION:
## 1.) Put this file into ~/.irssi/scripts
## 2.) run "/load perl" in irssi
## 3.) run "/script load notify" in irssi
##
## NOTE:
## Place this file into ~/.irssi/scripts/autorun (instead step 1)
## if you want it to be run each time irssi starts
##
use strict;
use Irssi;
use vars qw($VERSION %IRSSI);
$VERSION = "180129";
%IRSSI = (
authors => 'Aleksejus Kononovicius',
contact => 'aleksejus.kononovicius@gmail.com',
name => 'notify',
description => 'Use libnotify to alert about relevant events',
license => 'GPLv3',
);
sub sendNotify {
my ($server, $summary, $message) = @_;
system("notify-send -- \"".$summary."\" \"".$message."\"");
}
sub onMessageNotify {
my ($server, $msg, $nick, $address) = @_;
return if (!$server);
sendNotify($server, "irssi", "<".$nick."> ".$msg);
}
sub onJoinNotify {
my ($server, $channel, $nick, $address) = @_;
return if (!$server);
sendNotify($server, "irssi", $nick." has joined ".$channel);
}
sub onPartNotify {
my ($server, $channel, $nick, $address, $reason) = @_;
return if (!$server);
sendNotify($server, "irssi", $nick." has parted ".$channel);
}
sub onQuitNotify {
my ($server, $nick, $address, $reason) = @_;
return if (!$server);
sendNotify($server, "irssi", $nick." has quit");
}
Irssi::signal_add('message private', 'onMessageNotify');
Irssi::signal_add('message public', 'onMessageNotify');
Irssi::signal_add('message join', 'onJoinNotify');
Irssi::signal_add('message part', 'onPartNotify');
Irssi::signal_add('message quit', 'onQuitNotify');