From d673ff5fad72660bbc87e2d5295b448dd7f65c8e Mon Sep 17 00:00:00 2001 From: Badlop Date: Tue, 28 Jun 2011 23:04:12 +0200 Subject: [PATCH] Support servers that reply error on any command before registration (thanks to Gelraen) This makes mod_irc actually work with servers that reply with error on any command before the registration procedure is completed. Such servers, after NICK/USER they send PING and wait for client response. In such situation they reply with message 451 to CODEPAGE command, and mod_irc thinks that connection failed. Example IRC server that works thanks to the patch: irc.mibbit.com --- src/mod_irc/mod_irc_connection.erl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mod_irc/mod_irc_connection.erl b/src/mod_irc/mod_irc_connection.erl index c342f2877..62abd0556 100644 --- a/src/mod_irc/mod_irc_connection.erl +++ b/src/mod_irc/mod_irc_connection.erl @@ -132,8 +132,6 @@ open_socket(init, StateData) -> StateData#state.nick, StateData#state.host, StateData#state.nick])), - send_text(NewStateData, - io_lib:format("CODEPAGE ~s\r\n", [StateData#state.encoding])), {next_state, wait_for_registration, NewStateData}; {error, Reason} -> @@ -498,6 +496,8 @@ handle_info({ircstring, [$: | String]}, wait_for_registration, StateData) -> {NewState, NewStateData} = case Words of [_, "001" | _] -> + send_text(StateData, + io_lib:format("CODEPAGE ~s\r\n", [StateData#state.encoding])), {stream_established, StateData}; [_, "433" | _] -> {error,