diff options
| author | ailin-nemui | 2016-03-16 12:33:09 +0100 |
|---|---|---|
| committer | ailin-nemui | 2016-03-16 12:33:09 +0100 |
| commit | 2bed9ce4b6d6038df446b570b556c5d1d8321b65 (patch) | |
| tree | bbf9abca036bdd37664b67284c8a7b40628034b2 /scripts/bitlbee_hide_password.pl | |
| parent | 5dbfd9f54b6dbc114458ea02bbb1a75e1f447302 (diff) | |
| parent | a098b519551471f4ef84f4c942b57fe9e640ab5d (diff) | |
| download | scripts.irssi.org-2bed9ce4b6d6038df446b570b556c5d1d8321b65.tar.bz2 | |
Merge pull request #245 from avar/avar-script-collection
Submit my collection of scripts from my dotfiles.git
Diffstat (limited to 'scripts/bitlbee_hide_password.pl')
| -rw-r--r-- | scripts/bitlbee_hide_password.pl | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/scripts/bitlbee_hide_password.pl b/scripts/bitlbee_hide_password.pl new file mode 100644 index 0000000..feb86b2 --- /dev/null +++ b/scripts/bitlbee_hide_password.pl @@ -0,0 +1,64 @@ +use strict; +use warnings; +use Irssi; + +our $VERSION = '1.0'; +our %IRSSI = ( + authors => 'Ævar Arnfjörð Bjarmason', + contact => 'avarab@gmail.com', + name => 'bitlbee_hide_password.pl', + description => 'Hide your REGISTER and IDENTIFY password lines in &bitlbee from screen & logs ', + license => 'Public Domain', + url => 'http://scripts.irssi.org & https://github.com/avar/dotfiles/blob/master/.irssi/scripts/bitlbee_hide_password.pl', +); + +# HOWTO: +# +# /load bitlbee_hide_password.pl +# +# When you're using Bitlbee and do either: +# +# REGISTER <password> +# +# or: +# +# IDENTIFY <password> +# +# Your password will be shown on screen, and more importantly logged +# in your logfiles. This extension intercepts these commands in your +# &bitlbee channel and hides it from screen & logs. +# +# Note: You can avoid the password going into the log without this +# plugin by doing: +# +# IDENTIFY +# /OPER +# +# But this script also makes sure that your REGISTER commands will be +# hidden, and of course "IDENTIFY <password>" commands if you ever +# forget to IDENTIFY with /OPER. + +sub msg_intercept_bitlbee_password_lines { + my ($tdest, $data, $stripped) = @_; + + # The $tdest object has various other things, like ->{target}, + # ->{window} (object) etc. + my $server = $tdest->{server}; + + # Some events just have ->{window} and no ->{server}, we can + # ignore those + return unless $server; + + # We only care about the &bitlbee control channel + my $target = $tdest->{target}; + return unless $target eq '&bitlbee'; + + # We're matching against $stripped but replacing both because the + # $data thing is escaped and much harder to match against. + if ($stripped =~ /^<.?[^>]+> (?:register|identify) .+/si) { + s/(identify|register) .+/$1 <password stripped by $IRSSI{name}>/i for $data, $stripped; + Irssi::signal_continue($tdest, $data, $stripped); + } +} + +Irssi::signal_add_first('print text', 'msg_intercept_bitlbee_password_lines'); |
