-
-
Save lejeunerenard/f2a779672e6eb3179733 to your computer and use it in GitHub Desktop.
This file contains 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
# todo: grap topic changes | |
use strict; | |
use vars qw($VERSION %IRSSI); | |
use Fcntl; | |
use Irssi; | |
$VERSION = '0.0.3'; | |
%IRSSI = ( | |
authors => 'Thorsten Leemhuis & Sean Zellmer', | |
contact => 'fedora@leemhuis.info & sean@lejeunerenard.com', | |
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) $' | |
); | |
#-------------------------------------------------------------------- | |
# 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) = @_; | |
my $FIFO = "$ENV{HOME}/.irssi/fnotify"; | |
unless (-p $FIFO) { | |
unlink $FIFO; | |
system('mknod', $FIFO, 'p') | |
&& die "can't mknod $FIFO: $!"; | |
} | |
# next line blocks until there's a reader | |
sysopen(FILE, $FIFO, O_NONBLOCK|O_RDWR) || die "can't write $FIFO: $!"; | |
print FILE $text . "\n"; | |
close (FILE); | |
} | |
#-------------------------------------------------------------------- | |
# Irssi::signal_add_last / Irssi::command_bind | |
#-------------------------------------------------------------------- | |
Irssi::signal_add_last("message private", "priv_msg"); | |
Irssi::signal_add_last("print text", "hilight"); | |
#- end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment