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
|
#!/usr/bin/perl
#
use IO::Socket;
my $sock = new IO::Socket::INET (
LocalHost => '127.0.0.1',
LocalPort => '7090',
Proto => 'tcp',
Listen => 1,
Reuse => 1,
);
die "Could not create socket: $!\n" unless $sock;
while(true) {
my $new_sock = $sock->accept();
while(<$new_sock>) {
my ($server, $channel, $text, $active) = split(/:::/);
#print "$_\n";
my ($second, $minute, $hour, $dayOfMonth, $month, $yearOffset, $dayOfWeek, $dayOfYear, $daylightSavings) = localtime();
# zero padding
if ($hour < 10) {
$hour = "0$hour";
}
if ($minute < 10) {
$minute = "0$minute";
}
if ($channel =~ m/#/ ) {
$timeout = 10;
}
else {
if ($channel =~ m/bitlbee/ ) {
$timeout = 10;
}
else {
$timeout = 5;
}
}
## filter invalid chars
# allowed: [#x1-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
$text =~ s/[^\x01-\x{D7FF}\x{E000}-\x{FFFD}\x{10000}-\x{10FFFF}]//go;
# # restricted:[#x1-#x8][#xB-#xC][#xE-#x1F][#x7F-#x84][#x86-#x9F]
$text =~ s/[\x01-\x08\x0B-\x0C\x0E-\x1F\x7F-\x84\x86-\x9F]//go;
## replace otr information
$text =~ s/^03/OTR:\ /;
## remove '
$text =~ s/\'//g;
## remove "
$text =~ s/\"//g;
print "message({action=\"new\", timeout=$timeout, active=$active, title=\"$hour:$minute $channel\", text=\"$text\"})\n";
## AWESOME custom function
system("echo 'message({action=\"new\", timeout=$timeout, active=$active, title=\"$hour:$minute $channel\", text=\"$text\"})' | awesome-client");
## AWESOME
# system("echo 'notify_irssi=naughty.notify({timeout = $timeout, title = \"$hour:$minute $channel\", text = \"$text\"})' | awesome-client");
## NOTIFY-SEND timeout in ms
# system("notify-send -t $timeout*1000 \"$hour:$minute $channel\" \"$text\"");
}
}
close($sock);
|