From c0c61225213f664d4840fac08288a260a6e1f843 Mon Sep 17 00:00:00 2001 From: Thorsten Leemhuis Date: Tue, 25 Nov 2014 19:34:33 +0100 Subject: fnotify.pl: import v0.0.3 Source: http://www.leemhuis.info/files/fnotify/fnotify Signed-off-by: Serge van Ginderachter --- scripts/fnotify.pl | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 scripts/fnotify.pl diff --git a/scripts/fnotify.pl b/scripts/fnotify.pl new file mode 100644 index 0000000..983a262 --- /dev/null +++ b/scripts/fnotify.pl @@ -0,0 +1,68 @@ +# todo: grap topic changes + +use strict; +use vars qw($VERSION %IRSSI); + +use Irssi; +$VERSION = '0.0.3'; +%IRSSI = ( + authors => 'Thorsten Leemhuis', + contact => 'fedora@leemhuis.info', + 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); +} + +#-------------------------------------------------------------------- +# Irssi::signal_add_last / Irssi::command_bind +#-------------------------------------------------------------------- + +Irssi::signal_add_last("message private", "priv_msg"); +Irssi::signal_add_last("print text", "hilight"); + +#- end -- cgit v1.2.3 From a11c7830eeb4ad4f32575d87b72012ecaa4c9c98 Mon Sep 17 00:00:00 2001 From: James Shubin Date: Tue, 25 Nov 2014 19:59:07 +0100 Subject: fnotify.pl: Update to version 0.0.4 by James Shubin "Implement Consistent output formatting" Source: https://ttboj.wordpress.com/2013/10/18/desktop-notifications-for-irssi-in-screen-through-ssh-in-gnome-terminal/ Signed-off-by: Serge van Ginderachter --- scripts/fnotify.pl | 90 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 50 insertions(+), 40 deletions(-) diff --git a/scripts/fnotify.pl b/scripts/fnotify.pl index 983a262..58b2957 100644 --- a/scripts/fnotify.pl +++ b/scripts/fnotify.pl @@ -1,68 +1,78 @@ -# todo: grap topic changes - use strict; use vars qw($VERSION %IRSSI); use Irssi; -$VERSION = '0.0.3'; +$VERSION = '0.0.4'; %IRSSI = ( - authors => 'Thorsten Leemhuis', - contact => 'fedora@leemhuis.info', - 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) $' + name => 'fnotify', + authors => 'Thorsten Leemhuis, James Shubin', + description => 'Write notifications to a file in a consistent format.', + license => 'GNU General Public License', ); -#-------------------------------------------------------------------- -# In parts based on knotify.pl 0.1.1 by Hugo Haas +# +# README +# +# To use: +# $ cp fnotify.pl ~/.irssi/scripts/fnotify.pl +# irssi> /load perl +# irssi> /script load fnotify +# + +# +# AUTHORS +# +# Consistent output formatting by James Shubin: +# https://ttboj.wordpress.com/ +# +# Modified from the Thorsten Leemhuis version: +# http://www.leemhuis.info/files/fnotify/fnotify +# +# 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 +# +# 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 +# Other parts based on notify.pl from Luke Macken: # http://fedora.feedjack.org/user/918/ # -#-------------------------------------------------------------------- - -#-------------------------------------------------------------------- -# Private message parsing -#-------------------------------------------------------------------- +# +# catch private messages +# sub priv_msg { - my ($server,$msg,$nick,$address,$target) = @_; - filewrite($nick." " .$msg ); + my ($server, $msg, $nick, $address, $target) = @_; + my $network = $server->{tag}; + filewrite('' . $network . ' ' . $nick . ' ' . $msg); } -#-------------------------------------------------------------------- -# Printing hilight's -#-------------------------------------------------------------------- - +# +# catch 'hilight's +# sub hilight { - my ($dest, $text, $stripped) = @_; - if ($dest->{level} & MSGLEVEL_HILIGHT) { - filewrite($dest->{target}. " " .$stripped ); - } + my ($dest, $text, $stripped) = @_; + if ($dest->{level} & MSGLEVEL_HILIGHT) { + my $server = $dest->{server}; + my $network = $server->{tag}; + filewrite($network . ' ' . $dest->{target} . ' ' . $stripped); + } } -#-------------------------------------------------------------------- -# The actual printing -#-------------------------------------------------------------------- - +# +# write to file +# sub filewrite { my ($text) = @_; # FIXME: there is probably a better way to get the irssi-dir... - open(FILE,">>$ENV{HOME}/.irssi/fnotify"); + open(FILE, ">>$ENV{HOME}/.irssi/fnotify"); print FILE $text . "\n"; - close (FILE); + close(FILE); } -#-------------------------------------------------------------------- -# Irssi::signal_add_last / Irssi::command_bind -#-------------------------------------------------------------------- - +# +# irssi signals +# Irssi::signal_add_last("message private", "priv_msg"); Irssi::signal_add_last("print text", "hilight"); -#- end -- cgit v1.2.3 From 4de929f87ba2bf90177ac03d8df6b708c4acb73d Mon Sep 17 00:00:00 2001 From: Serge van Ginderachter Date: Tue, 25 Nov 2014 21:00:23 +0100 Subject: fnotify.pl: Strip non-parsed left over codes (Bitlbee otr messages) Signed-off-by: Serge van Ginderachter --- scripts/fnotify.pl | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/scripts/fnotify.pl b/scripts/fnotify.pl index 58b2957..f53205e 100644 --- a/scripts/fnotify.pl +++ b/scripts/fnotify.pl @@ -1,11 +1,11 @@ use strict; use vars qw($VERSION %IRSSI); - use Irssi; -$VERSION = '0.0.4'; + +$VERSION = '0.0.5'; %IRSSI = ( name => 'fnotify', - authors => 'Thorsten Leemhuis, James Shubin', + authors => 'Thorsten Leemhuis, James Shubin, Serge van Ginderachter', description => 'Write notifications to a file in a consistent format.', license => 'GNU General Public License', ); @@ -22,10 +22,17 @@ $VERSION = '0.0.4'; # # AUTHORS # +# Strip non-parsed left over codes (Bitlbee otr messages) +# version: 0.0.5 +# Serge van Ginderachter +# # Consistent output formatting by James Shubin: +# version: 0.0.4 # https://ttboj.wordpress.com/ +# note: changed license back to original GPL from Thorsten Leemhuis (svg) # -# Modified from the Thorsten Leemhuis version: +# Modified from the Thorsten Leemhuis +# version: 0.0.3 # http://www.leemhuis.info/files/fnotify/fnotify # # In parts based on knotify.pl 0.1.1 by Hugo Haas: @@ -43,8 +50,9 @@ $VERSION = '0.0.4'; # sub priv_msg { my ($server, $msg, $nick, $address, $target) = @_; + my $msg_stripped = Irssi::strip_codes($msg); my $network = $server->{tag}; - filewrite('' . $network . ' ' . $nick . ' ' . $msg); + filewrite('' . $network . ' ' . $nick . ' ' . $msg_stripped); } # -- cgit v1.2.3 From f818d80fe33e3a0754d52bd10a0823ff06f6de70 Mon Sep 17 00:00:00 2001 From: Serge van Ginderachter Date: Tue, 25 Nov 2014 21:11:54 +0100 Subject: fnotif.pl: add entry in scripts.yaml Signed-off-by: Serge van Ginderachter --- _data/scripts.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/_data/scripts.yaml b/_data/scripts.yaml index c25007e..3d81a14 100644 --- a/_data/scripts.yaml +++ b/_data/scripts.yaml @@ -1337,6 +1337,16 @@ url: "http://www.krukowiecki.net/code/irssi/" version: "0.0.2i" +- authors: "Thorsten Leemhuis, James Shubin, Serge van Ginderachter" + contact: "fedora@leemhuis.info, serge@vanginderachter.be" + description: "Write notifications to a file in a consistent format." + filename: "fnotify.pl" + modified: "2014-11-25 21:02" + license: "GNU General Public License" + name: "fnotify" + url: "http://www.leemhuis.info/files/fnotify/fnotify https://ttboj.wordpress.com/" + version: "0.0.5" + - authors: "Juerd" contact: "juerd@juerd.nl" description: "Automatically switch to active windows" -- cgit v1.2.3 From 3a92a5e3d05d2eee78fc9202a673b1861563c60c Mon Sep 17 00:00:00 2001 From: Serge van Ginderachter Date: Wed, 26 Nov 2014 13:57:28 +0100 Subject: fnotify.pl: fix perlcritic errors --- scripts/fnotify.pl | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/fnotify.pl b/scripts/fnotify.pl index f53205e..42a7eb8 100644 --- a/scripts/fnotify.pl +++ b/scripts/fnotify.pl @@ -1,4 +1,5 @@ use strict; +use warnings; use vars qw($VERSION %IRSSI); use Irssi; @@ -73,9 +74,14 @@ sub hilight { sub filewrite { my ($text) = @_; # FIXME: there is probably a better way to get the irssi-dir... - open(FILE, ">>$ENV{HOME}/.irssi/fnotify"); + my $fnfile = "$ENV{HOME}/.irssi/fnotify"; + if (!open(FILE, ">>", $fnfile)) { + print_err("cannot open $fnfile: $!"); + } print FILE $text . "\n"; - close(FILE); + if (!close(FILE)) { + print_err("cannot close $fnfile: $!"); + } } # -- cgit v1.2.3 From 8c80ff735d60ce8bb3f8c7267682a55d1f8065bb Mon Sep 17 00:00:00 2001 From: Serge van Ginderachter Date: Thu, 27 Nov 2014 18:34:31 +0100 Subject: fnotify.pl: fixes: fix proper way to get the irssi-dir replace unknown err function, and do better error handling --- scripts/fnotify.pl | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/scripts/fnotify.pl b/scripts/fnotify.pl index 42a7eb8..76e46b4 100644 --- a/scripts/fnotify.pl +++ b/scripts/fnotify.pl @@ -51,7 +51,7 @@ $VERSION = '0.0.5'; # sub priv_msg { my ($server, $msg, $nick, $address, $target) = @_; - my $msg_stripped = Irssi::strip_codes($msg); + my $msg_stripped = Irssi::strip_codes($msg); my $network = $server->{tag}; filewrite('' . $network . ' ' . $nick . ' ' . $msg_stripped); } @@ -73,15 +73,15 @@ sub hilight { # sub filewrite { my ($text) = @_; - # FIXME: there is probably a better way to get the irssi-dir... - my $fnfile = "$ENV{HOME}/.irssi/fnotify"; - if (!open(FILE, ">>", $fnfile)) { - print_err("cannot open $fnfile: $!"); - } - print FILE $text . "\n"; - if (!close(FILE)) { - print_err("cannot close $fnfile: $!"); - } + my $fnfile = Irssi::get_irssi_dir() . "/fnotify"; + if (!open(FILE, ">>", $fnfile)) { + print CLIENTCRAP "Error: cannot open $fnfile: $!"; + } else { + print FILE $text . "\n"; + if (!close(FILE)) { + print CLIENTCRAP "Error: cannot close $fnfile: $!"; + } + } } # -- cgit v1.2.3