This repository has been archived by the owner on Apr 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmultinotify-irssi.pl
82 lines (69 loc) · 1.92 KB
/
multinotify-irssi.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
74
75
76
77
78
79
80
81
82
######
# Multinotify irssi Client
# nchowning, 2011 - [email protected]
######
######
# Parts of this script are based on my irssi-prowl-notifier script which is based
# on fnotify created by Thorsten Leemhuis
# http://www.leemhuis.info/files/fnotify/
######
use warnings;
use IO::Socket::INET;
use vars qw($VERSION %IRSSI);
use Irssi;
$VERSION = '1.5';
%IRSSI = (
authors => 'Nathan Chowning',
contact => '[email protected]',
name => 'multinotify',
description => 'A script that works with multinotify-server.py and multinotify-client.pl to send and receive irssi notifications',
url => 'http://www.nathanchowning.com/projects/multinotify',
license => 'GPL'
);
######
# Set the IP Address & Port for your server below
######
my $IPADDRESS = "IP ADDRESS IN HERE";
my $PORT = "PORT IN HERE";
$| = 1; # Flush after write
my ($socket,$client_socket);
######
# Private message parsing
######
sub private_msg {
my ($server,$msg,$nick,$address,$target) = @_;
socketsend($nick,$msg);
}
######
# Sub to catch nick hilights
######
sub nick_hilight {
my ($dest, $text, $stripped) = @_;
if ($dest->{level} & MSGLEVEL_HILIGHT) {
socketsend($dest->{target}, $stripped);
}
}
######
# Send messages to notification server
######
sub socketsend {
my(@smessage) = @_;
$socket = new IO::Socket::INET (
PeerHost => "$IPADDRESS",
PeerPort => "$PORT",
Proto => "tcp",
) or die "ERROR in Socket Creation : $!\n";
# Send "send" to the server to inform it that this is a sending client
$data = "SEND";
print $socket "$data" . "\r\n";
# Send the message to the server
$data = "$smessage[0],,$smessage[1]";
print $socket "$data" . "\r\n";
# Close the socket
close($socket);
}
######
# Irssi::signal_add_last / Irssi::command_bind
######
Irssi::signal_add_last("message private", "private_msg");
Irssi::signal_add_last("print text", "nick_hilight");