]> git.99rst.org Git - irssi-scripts.irssi.org.git/commitdiff
Add hilightcmd
authorramnes <redacted>
Thu, 3 Mar 2016 16:18:21 +0000 (17:18 +0100)
committerramnes <redacted>
Thu, 3 Mar 2016 16:18:31 +0000 (17:18 +0100)
_data/scripts.yaml
scripts/hilightcmd.pl [new file with mode: 0644]

index a86ef3691cbf5f731681a248a462a43aa10d7bb3..66a013929b3250b71cd4d600564c7ea5f37462c4 100644 (file)
   name: hignore.pl
   url: http://irssi.hauwaerts.be/hignore.pl
   version: '0.02'
+-
+  authors: ramnes
+  contact: contact@ramnes.eu
+  description: 'Call a system command when receiving a hilight'
+  filename: hilightcmd.pl
+  license: GPLv3
+  modified: '2016-02-29 11:44:16'
+  name: hilightcmd
+  url: https://github.com/ramnes/hilightcmd
+  version: 0.1
 -
   authors: "Timo 'cras' Sirainen, Mark 'znx' Sangster"
   contact: 'tss@iki.fi, znxster@gmail.com'
diff --git a/scripts/hilightcmd.pl b/scripts/hilightcmd.pl
new file mode 100644 (file)
index 0000000..b17f624
--- /dev/null
@@ -0,0 +1,48 @@
+#
+# Call a custom system command when receiving a hilight.
+# Originally based on hilightwin.pl work and djcraven5's idea for making remote
+# computer beep through ssh.
+#
+# Example of use, assuming you got a ssh and beep on your remote:
+# /set hilightcmd_systemcmd ssh user@host beep &
+#
+
+use Irssi;
+use POSIX;
+use vars qw($VERSION %IRSSI);
+use Text::Sprintf::Named qw(named_sprintf);
+
+$VERSION = "0.1";
+%IRSSI = (authors     => "Guillaume Gelin",
+         contact     => "contact\@ramnes.eu",
+         name        => "hilightcmd",
+         description => "Call a system command when receiving a hilight",
+         license     => "GNU GPLv3",
+         url         => "https://github.com/ramnes/hilightcmd");
+
+
+Irssi::signal_add('print text' => sub {
+    my ($dest, $text, $stripped) = @_;
+    my $opt = MSGLEVEL_HILIGHT;
+
+    if (Irssi::settings_get_bool('hilightcmd_privmsg')) {
+        $opt = MSGLEVEL_HILIGHT|MSGLEVEL_MSGS;
+    }
+
+    if (($dest->{level} & ($opt))
+       && ($dest->{level} & MSGLEVEL_NOHILIGHT) == 0
+       && (Irssi::active_win()->{refnum} != $dest->{window}->{refnum}
+            || Irssi::settings_get_bool('hilightcmd_currentwin'))) {
+
+        $stripped =~ s/"/\\"/g;
+        system(named_sprintf(
+            Irssi::settings_get_str('hilightcmd_systemcmd'),
+            message => $stripped
+        ));
+    }
+});
+
+
+Irssi::settings_add_bool('hilightcmd', 'hilightcmd_privmsg', 1);
+Irssi::settings_add_bool('hilightcmd', 'hilightcmd_currentwin', 1);
+Irssi::settings_add_str('hilightcmd', 'hilightcmd_systemcmd', '');
git clone https://git.99rst.org/PROJECT