-
Notifications
You must be signed in to change notification settings - Fork 1
/
irssi-growlnotify.pl
73 lines (60 loc) · 2.3 KB
/
irssi-growlnotify.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
67
68
69
70
71
72
73
# todo: grap topic changes
use strict;
use vars qw($VERSION %IRSSI);
use Irssi;
$VERSION = '0.0.3';
%IRSSI = (
authors => 'Thorsten Leemhuis',
contact => '[email protected]',
name => 'fnotify',
description => 'Write a notification to a file that shows who is talking to you in which channel.',
url => 'http://www.leemhuis.info/files/fnotify/',
license => 'GNU General Public License',
changed => '$Date: 2007-01-13 12:00:00 +0100 (Sat, 13 Jan 2007) $'
);
#--------------------------------------------------------------------
# In parts based on knotify.pl 0.1.1 by Hugo Haas
# http://larve.net/people/hugo/2005/01/knotify.pl
# which is based on osd.pl 0.3.3 by Jeroen Coekaerts, Koenraad Heijlen
# http://www.irssi.org/scripts/scripts/osd.pl
#
# Other parts based on notify.pl from Luke Macken
# http://fedora.feedjack.org/user/918/
#
#--------------------------------------------------------------------
#--------------------------------------------------------------------
# Private message parsing
#--------------------------------------------------------------------
sub priv_msg {
my ($server,$msg,$nick,$address,$target) = @_;
filewrite($nick." " .$msg );
}
#--------------------------------------------------------------------
# Printing hilight's
#--------------------------------------------------------------------
sub hilight {
my ($dest, $text, $stripped) = @_;
if ($dest->{level} & MSGLEVEL_HILIGHT) {
filewrite($dest->{target}. " " .$stripped );
}
}
#--------------------------------------------------------------------
# The actual printing
#--------------------------------------------------------------------
sub filewrite {
my ($text) = @_;
# FIXME: there is probably a better way to get the irssi-dir...
# open(FILE,">>$ENV{HOME}/.irssi/fnotify");
#print FILE $text . "\n";
# close (FILE);
$text =~ s/\n/ /;
$text =~ s/[<@&']//g;
my @values = split(' ', $text, 2);
system("growlnotify -t Irssi -n Irssi -m '$values[1]' '$values[0]'");
}
#--------------------------------------------------------------------
# Irssi::signal_add_last / Irssi::command_bind
#--------------------------------------------------------------------
Irssi::signal_add_last("message private", "priv_msg");
Irssi::signal_add_last("print text", "hilight");
#- end