]> git.99rst.org Git - irssi-scripts.irssi.org.git/commitdiff
[fnotify] Add own messages to fnotify writes (#650)
authorMichael Davies <redacted>
Mon, 22 Jul 2019 11:37:28 +0000 (21:07 +0930)
committerbw1 <redacted>
Mon, 22 Jul 2019 11:37:28 +0000 (13:37 +0200)
* 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

scripts/fnotify.pl

index 83cc858e90ffaafbeae3dece46cfc2fde0a9b550..11707ddafe6a587e274402cde284e87403c71a3a 100644 (file)
@@ -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 <michael@the-davies.net>
+#
 # Ignore hilighted messages with priority = fnotify_ignore_hilight
 # version: 0.0.6
 # Tyler Abair <tyler.abair@gmail.com>
@@ -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");
 
git clone https://git.99rst.org/PROJECT