summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorNicolas Hake <nh@nosebud.de>2015-11-30 15:56:22 +0100
committerNicolas Hake <nh@nosebud.de>2015-11-30 16:06:18 +0100
commit97939984bc63154c25c827d0befc7c7326a4a1c8 (patch)
tree5f8415bf9c53cd1962438991fe6d1da8a10469e1 /lib
parentMerge pull request #32 from w1gz/master (diff)
Allow use of NICK command before RPL_WELCOME
By blocking NICK before logging on finishes, the client is unable to handle ERR_NICKNAMEINUSE and ERR_UNAVAILRESOURCE. Allow NICK even when the server hasn't sent RPL_WELCOME yet, so clients can pick a different nickname.
Diffstat (limited to 'lib')
-rw-r--r--lib/exirc/client.ex6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/exirc/client.ex b/lib/exirc/client.ex
index 344ea2a..b53a0c3 100644
--- a/lib/exirc/client.ex
+++ b/lib/exirc/client.ex
@@ -342,6 +342,12 @@ defmodule ExIrc.Client do
Transport.send state, user!(user, name)
{:reply, :ok, %{state | :pass => pass, :nick => nick, :user => user, :name => name} }
end
+ # Handles call to change the client's nick.
+ def handle_call({:nick, new_nick}, _from, %ClientState{:logged_on? => false} = state) do
+ Transport.send state, nick!(new_nick)
+ # Since we've not yet logged on, we won't get a nick change message, so we have to remember the nick here.
+ {:reply, :ok, %{state | :nick => new_nick}}
+ end
# Handle call to determine if client is logged on to a server
def handle_call(:is_logged_on?, _from, state), do: {:reply, state.logged_on?, state}
# Prevents any of the following messages from being handled if the client is not logged on to a server.