diff options
| author | ramnes | 2016-03-03 17:18:21 +0100 | 
|---|---|---|
| committer | ramnes | 2016-03-03 17:18:31 +0100 | 
| commit | 0c43cce461b9ced27adbdd6973a93adb2a859a93 (patch) | |
| tree | d2aead12ed6f976beeba60d334c03764150d13d2 /scripts | |
| parent | 53d48d7c51095d2c9ffe199ce37083367f0691ba (diff) | |
| download | scripts.irssi.org-0c43cce461b9ced27adbdd6973a93adb2a859a93.tar.bz2 | |
Add hilightcmd
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/hilightcmd.pl | 48 | 
1 files changed, 48 insertions, 0 deletions
diff --git a/scripts/hilightcmd.pl b/scripts/hilightcmd.pl new file mode 100644 index 0000000..b17f624 --- /dev/null +++ b/scripts/hilightcmd.pl @@ -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', '');  | 
