diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 20:19:02 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 20:19:02 +0000 |
commit | 03929dac2a29664878d2c971648a4fe1fb698462 (patch) | |
tree | 02c5e2b3e006234aa29545f7a93a1ce01b291a8b /scripts/nickban.pl | |
parent | Initial commit. (diff) | |
download | irssi-scripts-upstream/20231031.tar.xz irssi-scripts-upstream/20231031.zip |
Adding upstream version 20231031.upstream/20231031upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'scripts/nickban.pl')
-rw-r--r-- | scripts/nickban.pl | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/scripts/nickban.pl b/scripts/nickban.pl new file mode 100644 index 0000000..e1a134d --- /dev/null +++ b/scripts/nickban.pl @@ -0,0 +1,66 @@ +use strict; +use vars qw($VERSION %IRSSI); +$VERSION = "1.2"; +%IRSSI = ( + authors => "Roeland 'Trancer' Nieuwenhuis", + contact => "irssi\@trancer.nl", + name => "nickban", + description => "A simple nick banner. If it encounters a nick it bans its host", + license => "Public Domain" +); + +use Irssi; + +# The channels the nicks are banned on (on which this script is active) +my @channels; + +# The banned nicks +my @nicks; + +# Your kickreason +my $kickreason; + +sub nick_banner { + + my($server, $channel, $nick, $address) = @_; + + # Are we opped? + return unless $server->channel_find($channel)->{chanop}; + + # If the nick is a server, stop it. + return if $nick eq $server->{nick}; + + # Is the user a banned nick? + my $nono = 0; + foreach (@nicks) { $nono = 1 if lc($nick) eq lc($_) } + return unless $nono; + + # Is the user on one of the banned channels? + my $react = 0; + foreach (@channels) { $react = 1 if lc($channel) eq lc($_) } + return unless $react; + + # User voiced or op'd? + # Pretty useless, but ok + return if $server->channel_find($channel)->nick_find($nick)->{op} || $server->channel_find($channel)->nick_find($nick)->{voice}; + + $server->command("kickban $channel $nick $kickreason"); + Irssi::print("Nick banning $nick on $channel. Banned."); +} + +sub sig_setup_changed { + @channels = split(/\s+/,Irssi::settings_get_str($IRSSI{name}.'_channels')); + @nicks = split(/\s+/,Irssi::settings_get_str($IRSSI{name}.'_nicks')); + $kickreason = Irssi::settings_get_str($IRSSI{name}.'_reason'); +} + +Irssi::settings_add_str($IRSSI{name}, $IRSSI{name}.'_channels', '#worldchat #chat-world #php'); +Irssi::settings_add_str($IRSSI{name}, $IRSSI{name}.'_nicks', 'evildude evilgirl'); +Irssi::settings_add_str($IRSSI{name}, $IRSSI{name}.'_reason', "Not welcome here."); + +Irssi::signal_add_last('message join', 'nick_banner'); +Irssi::signal_add('setup changed', 'sig_setup_changed'); + +sig_setup_changed(); + +# vim:set ts=4 sw=4 expandtab: |