]> icculus.org git repositories - divverent/nexuiz.git/blob - server/rcon2irc/qnetauth.pl
Fix quakenet auth and add a new plugin to stop abusive votes
[divverent/nexuiz.git] / server / rcon2irc / qnetauth.pl
1 # Nexuiz rcon2irc plugin by Merlijn Hofstra licensed under GPL - qnetauth.pl
2 # Place this file inside the same directory as rcon2irc.pl and add the full filename to the plugins.
3
4 # This plugin will automatically authenticate users who have a login for Quakenet (on the Q bot).
5 # If you login to the Q bot, this plugin will pick this up and users in the list below can automatically
6 # execute commands on the rcon2irc bot.
7 { my @users = qw{merlijn};
8
9 $store{plugin_qnetauth}->{users} = \@users; }
10
11 sub out($$@);
12 sub schedule($$);
13
14 if (defined %config) {
15         schedule sub {
16                 my ($timer) = @_;
17                 out irc => 0, "PRIVMSG Q :users " . $config{irc_channel};
18                 schedule $timer => 300;;
19         } => 1;
20 }
21
22 # Catch joins of people in a channel the bot is in and catch our own joins of a channel
23 [ irc => q{:(([^! ]*)![^ ]*) JOIN (#.+)} => sub {
24         my ($hostmask, $nick, $chan) = @_;
25         my $qa = $store{plugin_qnetauth};
26         
27         if ($nick eq $config{irc_nick}) {
28                 out irc => 0, "PRIVMSG Q :users $chan"; # get auths for all users
29         } else {
30                 $qa->{hosts}->{$nick} = $hostmask;
31                 out irc => 0, "PRIVMSG Q :whois $nick"; # get auth for single user
32         }
33         
34         return 0;
35 } ],
36
37 # Catch response of users request
38 [ irc => q{:Q!TheQBot@CServe.quakenet.org NOTICE [^:]+ :[@\+\s]?(\S+)\s+(\S+)\s*(\S*)\s*\((.*)\)} => sub {
39         my ($nick, $username, $flags, $host) = @_;
40         my $qa = $store{plugin_qnetauth};
41         
42         foreach my $user (@{ $qa->{users} }) {
43                 $store{logins}{"$nick!$host"} = time() + 600 if ($user eq $username);
44         }
45         
46         return 0;
47 } ],
48
49 # Catch response of whois request
50 [ irc => q{:Q!TheQBot@CServe.quakenet.org NOTICE [^:]+ :-Information for user (.*) \(using account (.*)\):} => sub {
51         my ($nick, $username) = @_;
52         my $qa = $store{plugin_qnetauth};
53         
54         foreach my $user (@{ $qa->{users} }) {
55                 if ($user eq $username) {
56                         my $hostmask = $qa->{hosts}->{$nick};
57                         $store{logins}{$hostmask} = time() + 600;
58                 }
59         }
60         
61         return 0;
62 } ],