X-Git-Url: https://git.xonotic.org/?p=xonotic%2Fxonotic.git;a=blobdiff_plain;f=server%2Frcon2irc%2Frcon2irc.pl;h=42909cc8636219dd450984a6695f0061a19891f4;hp=489a7e17a3eb9a1d7bfbe04bcd639338a96bb9f1;hb=06ec0374a4d3b8e29a44044749290dcf02dea204;hpb=2ec7592650fe8ad01d877f7c6887d9f9dda143af diff --git a/server/rcon2irc/rcon2irc.pl b/server/rcon2irc/rcon2irc.pl index 489a7e17..42909cc8 100755 --- a/server/rcon2irc/rcon2irc.pl +++ b/server/rcon2irc/rcon2irc.pl @@ -514,7 +514,7 @@ sub recvchallenge($) if not defined $s; length $s or last; - if($s =~ /^\377\377\377\377challenge (.*)$/s) + if($s =~ /^\377\377\377\377challenge (.*)(?:$|\0)/s) { return $1; } @@ -862,7 +862,7 @@ sub irc_error() return; # this will keep irc_error_active } - $channels{irc} = new Channel::Line(new Connection::Socket(tcp => "" => $config{irc_server} => 6667)); + $channels{irc} = new Channel::Line(new Connection::Socket(tcp => $config{irc_local} => $config{irc_server} => 6667)); delete $store{$_} for grep { /^irc_/ } keys %store; $store{irc_nick} = ""; schedule sub { @@ -1293,6 +1293,18 @@ sub cond($) [ irc => q{:[^ ]* 001 .*} => sub { $store{irc_seen_welcome} = 1; $store{irc_nick} = $store{irc_nick_requested}; + + # If users for quakenet are listed, parse them into a hash and schedule a sub to query information + if ($config{irc_quakenet_authusers} ne '') { + $store{irc_quakenet_users} = { map { $_ => 1 } split / /, $config{irc_quakenet_authusers} }; + + schedule sub { + my ($timer) = @_; + out irc => 0, "PRIVMSG Q :users " . $config{irc_channel}; + schedule $timer => 300;; + } => 1; + } + return irc_joinstage(0); } ], @@ -1309,12 +1321,20 @@ sub cond($) return irc_joinstage(0); } ], - # Catch joins of people in a channel the bot is in and catch our own joins of a channel + # Catch joins of people in a channel the bot is in and catch our own joins of a channel, + # detect channel join message and note hostname length to get the maximum allowed line length [ irc => q{:(([^! ]*)![^ ]*) JOIN (#.+)} => sub { my ($hostmask, $nick, $chan) = @_; + + if ($nick eq $store{irc_nick}) { + $store{irc_maxlen} = 510 - length($hostmask); + $store{irc_joined_channel} = 1; + print "* detected maximum line length for channel messages: $store{irc_maxlen}\n"; + } + return 0 unless ($store{irc_quakenet_users}); - if ($nick eq $config{irc_nick}) { + if ($nick eq $store{irc_nick}) { out irc => 0, "PRIVMSG Q :users $chan"; # get auths for all users } else { $store{quakenet_hosts}->{$nick} = $hostmask; @@ -1383,14 +1403,6 @@ sub cond($) return 0; } ], - # detect channel join message and note hostname length to get the maximum allowed line length - [ irc => q{(:(?i:(??{$store{irc_nick}}))![^ ]* )(?i:JOIN) :(?i:(??{$config{irc_channel}}))} => sub { - $store{irc_maxlen} = 510 - length($1); - $store{irc_joined_channel} = 1; - print "* detected maximum line length for channel messages: $store{irc_maxlen}\n"; - return 0; - } ], - # chat: Xonotic server -> IRC channel [ dp => q{\001(.*?)\^7: (.*)} => sub { my ($nick, $message) = map { color_dp2irc $_ } @_; @@ -1688,17 +1700,6 @@ for my $p(split ' ', $config{plugins}) } -# If users for quakenet are listed, parse them into a hash and schedule a sub to query information -if ($config{irc_quakenet_authusers} ne '') { - $store{irc_quakenet_users} = { map { $_ => 1 } split / /, $config{irc_quakenet_authusers} }; - - schedule sub { - my ($timer) = @_; - out irc => 0, "PRIVMSG Q :users " . $config{irc_channel}; - schedule $timer => 300;; - } => 1; -} - # verify that the server is up by letting it echo back a string that causes # re-initialization of the required aliases @@ -1726,7 +1727,7 @@ schedule sub { my ($timer) = @_; # log on to IRC when needed - if(exists $store{dp_hostname} && !exists $store{irc_logged_in}) + if(exists $store{dp_hostname} && !exists $store{irc_seen_welcome}) { $store{irc_nick_requested} = $config{irc_nick}; out irc => 1, "NICK $config{irc_nick}", "USER $config{irc_user} localhost localhost :$store{dp_hostname}";