]> git.xonotic.org Git - xonotic/xonotic.git/blob - server/rcon2irc/bans.pl
build index at a better place; fix exit code
[xonotic/xonotic.git] / server / rcon2irc / bans.pl
1 # Xonotic rcon2irc plugin by Merlijn Hofstra licensed under GPL - bans.pl
2 # Place this file inside the same directory as rcon2irc.pl and add the full filename to the plugins.
3
4 $store{plugin_bans}->{interval} = 60; #interval to displays bans
5
6 sub out ($$@);
7 sub schedule($$);
8
9 if (defined %config) {
10         schedule sub {
11                 my ($timer) = @_;
12                 if ($store{plugin_bans}->{attempts}) {
13                         foreach (sort keys %{ $store{plugin_bans}->{attempts} }) {
14                                 # Generate names
15                                 my %temp = undef;
16                                 my @names = grep !$temp{$_}++, @{ $store{plugin_bans}->{names}->{$_} };
17                         
18                                 out irc => 0, "PRIVMSG $config{irc_channel} :\00305* banned client\017 \00304$_\017 was denied access \00304" .
19                                         $store{plugin_bans}->{attempts}->{$_} . "\017 times" . 
20                                         (scalar(@names) ? ' with name(s): ' . join("\017, ", @names) : '');
21                         }
22                         $store{plugin_bans}->{attempts} = undef;
23                         $store{plugin_bans}->{names} = undef;
24                 }
25                 schedule $timer => $store{plugin_bans}->{interval};;
26         } => 1;
27 }
28
29
30 # old style without names
31 [ dp => q{(?:\^\d)?NOTE:(?:\^\d)? banned client (\d+\.\d+\.\d+\.\d+) just tried to enter} => sub {
32         my ($ip) = @_;
33         $store{plugin_bans}->{attempts}->{$ip} += 1;
34         return 0;
35 } ],
36
37 # new style with names if known
38 [ dp => q{(?:\^\d)?NOTE:(?:\^\d)? banned client (\d+\.\d+\.\d+\.\d+) \((.*)\) just tried to enter} => sub {
39         my ($ip,$name) = @_;
40         $name = color_dp2irc $name;
41         $store{plugin_bans}->{attempts}->{$ip} += 1;
42         if ($name && $name ne 'unconnected') {
43                 push @{ $store{plugin_bans}->{names}->{$ip} }, $name;
44         }
45         return 0;
46 } ],
47
48 [ dp => q{(?:\^\d)?NOTE:(?:\^\d)? banned client (.*) has to go} => sub {
49         my ($name) = @_;
50         $name = color_dp2irc $name;
51         out irc => 0, "PRIVMSG $config{irc_channel} :\00305* banned client\017 $name\017 was removed from the server";
52         return 0;
53 } ],