From: Michael Davies Date: Mon, 22 Jul 2019 11:37:28 +0000 (+0930) Subject: [fnotify] Add own messages to fnotify writes (#650) X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=3e66621b0c303e0b7b50e95aa3c74df9d09878b1;p=irssi-scripts.irssi.org.git [fnotify] Add own messages to fnotify writes (#650) * Add own messages to fnotify writes fnotify allows you to do things like turn on blinkenlights when you are hilighted in messages. Adding your own messages allows you to turn off any local notifications once you respond. Sample of how to do this is at https://github.com/mrda/junkcode/blob/master/irssi-notify.sh --- diff --git a/scripts/fnotify.pl b/scripts/fnotify.pl index 83cc858..11707dd 100644 --- a/scripts/fnotify.pl +++ b/scripts/fnotify.pl @@ -3,11 +3,11 @@ use warnings; use vars qw($VERSION %IRSSI); use Irssi; -$VERSION = '0.0.6'; +$VERSION = '0.0.7'; %IRSSI = ( name => 'fnotify', authors => 'Tyler Abair, Thorsten Leemhuis, James Shubin' . - ', Serge van Ginderachter', + ', Serge van Ginderachter, Michael Davies', contact => 'fedora@leemhuis.info, serge@vanginderachter.be', description => 'Write notifications to a file in a consistent format.', license => 'GNU General Public License', @@ -22,11 +22,16 @@ $VERSION = '0.0.6'; # irssi> /load perl # irssi> /script load fnotify # irssi> /set fnotify_ignore_hilight 0 # ignore hilights of priority 0 +# irssi> /set fnotify_own on # turn on own notifications # # # AUTHORS # +# Add self to notification file +# version 0.0.7 +# Michael Davies +# # Ignore hilighted messages with priority = fnotify_ignore_hilight # version: 0.0.6 # Tyler Abair @@ -59,9 +64,13 @@ my %config; Irssi::settings_add_int('fnotify', 'fnotify_ignore_hilight' => -1); $config{'ignore_hilight'} = Irssi::settings_get_int('fnotify_ignore_hilight'); +Irssi::settings_add_bool('fnotify', 'fnotify_own', 0); +$config{'own'} = Irssi::settings_get_bool('fnotify_own'); + Irssi::signal_add( 'setup changed' => sub { $config{'ignore_hilight'} = Irssi::settings_get_int('fnotify_ignore_hilight'); + $config{'own'} = Irssi::settings_get_bool('fnotify_own'); } ); @@ -88,6 +97,23 @@ sub hilight { } } +# +# catch own messages +# +sub own_public { + my ($dest, $msg, $target) = @_; + if ($config{'own'}) { + filewrite($dest->{'nick'} . ' ' .$msg ); + } +} + +sub own_private { + my ($dest, $msg, $target, $orig_target) = @_; + if ($config{'own'}) { + filewrite($dest->{'nick'} . ' ' .$msg ); + } +} + # # write to file # @@ -109,4 +135,6 @@ sub filewrite { # Irssi::signal_add_last("message private", "priv_msg"); Irssi::signal_add_last("print text", "hilight"); +Irssi::signal_add_last("message own_public", "own_public"); +Irssi::signal_add_last("message own_private", "own_private");