From 3db477e967b8369f63a6f4ad03489e231bdb7a8f Mon Sep 17 00:00:00 2001 From: fruitiex Date: Thu, 12 Nov 2009 19:34:24 +0000 Subject: [PATCH] rcon2irc plugin: allow people to view who (tries to) log in to the irc admin feature git-svn-id: svn://svn.icculus.org/nexuiz/trunk@8275 f962a42d-fe04-0410-a3ab-8c8b0445ebaa --- server/rcon2irc/showlogins.pl | 48 +++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 server/rcon2irc/showlogins.pl diff --git a/server/rcon2irc/showlogins.pl b/server/rcon2irc/showlogins.pl new file mode 100644 index 000000000..716b1360b --- /dev/null +++ b/server/rcon2irc/showlogins.pl @@ -0,0 +1,48 @@ +# Nexuiz rcon2irc plugin by Merlijn Hofstra licensed under GPL - showlogins.pl +# Place this file inside the same directory as rcon2irc.pl and add the full filename to the plugins. + +{ my %sl = ( + show_success => 1, + show_failed => 1, + failed_interval => 60, +); $store{plugin_showlogins} = \%sl; } + +sub out($$@); +sub schedule($$); + +schedule sub { + my ($timer) = @_; + if ($store{plugin_showlogins}->{failed_attempts}) { + # Generate hostmakes + my %temp = undef; + my @hostmasks = grep !$temp{$_}++, @{ $store{plugin_showlogins}->{failed_attempts} }; + + foreach my $mask (@hostmasks) { + my $count = 0; + foreach (@{ $store{plugin_showlogins}->{failed_attempts} }) { + $count++ if ($_ eq $mask); + } + + out irc => 0, "PRIVMSG $config{irc_channel} :\00305* login failed\017 \00304$mask\017 tried to become an IRC admin \00304$count\017 times"; + } + + $store{plugin_showlogins}->{failed_attempts} = undef; + } + schedule $timer => $store{plugin_showlogins}->{failed_interval};; +} => 1; + +[ irc => q{:(([^! ]*)![^ ]*) (?i:PRIVMSG) [^&#%]\S* :(.*)} => sub { + my ($hostmask, $nick, $command) = @_; + my $sl = $store{plugin_showlogins}; + + if ($command eq "login $config{irc_admin_password}") { + out irc => 0, "PRIVMSG $config{irc_channel} :\00310* login\017 $nick is now logged in as an IRC admin" if ($sl->{show_success}); + return 0; + } + + if ($command =~ m/^login/i && $sl->{show_failed}) { + push @{ $store{plugin_showlogins}->{failed_attempts} }, $hostmask; + } + + return 0; +} ], -- 2.39.2