]> git.99rst.org Git - irssi-scripts.irssi.org.git/commitdiff
add conceal script
authorAilin Nemui <redacted>
Thu, 22 Oct 2020 14:28:09 +0000 (16:28 +0200)
committerAilin Nemui <redacted>
Thu, 22 Oct 2020 14:28:09 +0000 (16:28 +0200)
a script to hide nickserv passwords when typing them manually

scripts/conceal.pl [new file with mode: 0644]

diff --git a/scripts/conceal.pl b/scripts/conceal.pl
new file mode 100644 (file)
index 0000000..5f3444b
--- /dev/null
@@ -0,0 +1,49 @@
+use strict;
+use warnings;
+
+our $VERSION = '0.1'; # d975c6bb59df06d
+our %IRSSI = (
+    authors     => 'Nei',
+    contact     => 'Nei @ anti@conference.jabber.teamidiot.de',
+    url         => "http://anti.teamidiot.de/",
+    name        => 'conceal',
+    description => 'conceals passwords on the input line',
+    license     => 'ISC',
+   );
+
+use Irssi;
+use Irssi::TextUI;
+die "This script requires Irssi 1.2.0\n"
+    unless Irssi->can('gui_input_set_extent');
+
+my $utf8;
+my $cmdchars;
+
+sub check_input {
+    my $inputline = Irssi::parse_special('$L');
+    if ($utf8) {
+        Encode::_utf8_on($inputline);
+    }
+    Irssi::gui_input_set_extent(length $inputline, '%n');
+    my $c = qr/^[\Q$cmdchars\E]/;
+    for ($inputline) {
+       if (m{${c}(?:(?:
+                     (?:msg|quote) \s+ (?:nickserv|ns|\w\@\S+)
+                   |quote) \s+ )?
+             (?: id(?:ent(?:ify)?)?
+               | (?:auth|login) \s+ (?:\S+) ) \s+ (\S+) (?:\s|$)}ix
+          ) {
+           Irssi::gui_input_clear_extents($-[1], $+[1] - $-[1]);
+           Irssi::gui_input_set_extents($-[1], $+[1] - $-[1], '%c%6', '%n');
+       }
+    }
+}
+
+sub setup_changed {
+    $utf8 = lc Irssi::settings_get_str('term_charset') eq 'utf-8';
+    $cmdchars = Irssi::settings_get_str('cmdchars');
+}
+
+setup_changed();
+Irssi::signal_add('setup changed', 'setup_changed');
+Irssi::signal_add_last('gui key pressed', 'check_input');
git clone https://git.99rst.org/PROJECT