summaryrefslogtreecommitdiffstats
path: root/scripts/nickban.pl
diff options
context:
space:
mode:
authorAlexander Færøy2014-05-31 13:10:46 +0200
committerAlexander Færøy2014-05-31 13:10:46 +0200
commit2d0759e6ca5767b48bcc85bf38c2c43d5f0b63b1 (patch)
tree1c5e6d817c88e67b46e216a50e0aef5428bf63df /scripts/nickban.pl
parent2d080422d79d1fd49d6c5528593ccaaff9bfc583 (diff)
downloadscripts.irssi.org-2d0759e6ca5767b48bcc85bf38c2c43d5f0b63b1.tar.bz2
Import scripts from scripts.irssi.org
Diffstat (limited to 'scripts/nickban.pl')
-rw-r--r--scripts/nickban.pl50
1 files changed, 50 insertions, 0 deletions
diff --git a/scripts/nickban.pl b/scripts/nickban.pl
new file mode 100644
index 0000000..c24e579
--- /dev/null
+++ b/scripts/nickban.pl
@@ -0,0 +1,50 @@
+$VERSION = "1.1";
+%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 strict;
+use Irssi;
+
+# The channels the nicks are banned on (on which this script is active)
+my @channels = qw(#worldchat #chat-world #php);
+
+# The banned nicks
+my @nicks = qw(evildude evilgirl);
+
+# Your kickreason
+my $kickreason = "Not welcome here.";
+
+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.");
+}
+
+Irssi::signal_add_last('message join', 'nick_banner');