From 72c3d0c15907024fd2cfa4426c7dfa521609d647 Mon Sep 17 00:00:00 2001 From: Zoffix Znet Date: Sat, 7 May 2016 09:52:33 -0400 Subject: Connect only after ERR_NOMOTD or END_MOTD messages --- lib/IRC/Client.pm6 | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/IRC/Client.pm6 b/lib/IRC/Client.pm6 index 2fa04dc..f9c8c88 100644 --- a/lib/IRC/Client.pm6 +++ b/lib/IRC/Client.pm6 @@ -28,6 +28,12 @@ method handle-event ($e) { return unless $res === IRC_NOT_HANDLED; } + # Wait for END_MOTD or ERR_NOMOTD before attempting to join + if $e eq '422' | '376' { + $.ssay("JOIN {@!channels[]}\n"); + .irc-connected: self for @!plugs.grep(*.^can: 'irc-connected'); + } + my $nick = $!nick; if ( ( $e eq 'PRIVMSG' and $e[0] eq $nick ) or ( $e eq 'NOTICE' and $e[0] eq $nick ) @@ -124,9 +130,6 @@ method run { $.ssay("PASS $!password\n") if $!password.defined; $.ssay("NICK $!nick\n"); $.ssay("USER $!username $!username $!host :$!userreal\n"); - $.ssay("JOIN {@!channels[]}\n"); - - .irc-connected: self for @!plugs.grep(*.^can: 'irc-connected'); # my $left-overs = ''; react { @@ -168,4 +171,4 @@ sub plug-name { $plug ~~ s:g/^ $cur '/' | '.pm6'$//; $plug ~~ s/'/'/::/; return "[$plug] "; -} \ No newline at end of file +} -- cgit v1.1