From 037118afa9ef7907cd9310e3401a35141513ac8a Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Sat, 25 Mar 2023 13:11:58 +0200 Subject: [PATCH] Client - Added `nick(string)` command to allow setting of nickname Unit tests - Moved from `client.command(Message)` to `client.nick(string)` for setting nickname --- source/birchwood/client/client.d | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/source/birchwood/client/client.d b/source/birchwood/client/client.d index 0654a5e..8b312a0 100644 --- a/source/birchwood/client/client.d +++ b/source/birchwood/client/client.d @@ -188,6 +188,29 @@ public class Client : Thread } } + /** + * Requests setting of the provided nickname + * + * Params: + * nickname = the nickname to request + * Throws: + * BirchwoodException on invalid nickname + */ + public void nick(string nickname) + { + /* Ensure no illegal characters in nick name */ + if(isValidText(nickname)) + { + /* Set the nick */ + Message nickMessage = new Message("", "NICK", nickname); + sendMessage(nickMessage); + } + else + { + throw new BirchwoodException(ErrorType.ILLEGAL_CHARACTERS); + } + } + /** * Joins the requested channel * @@ -1030,7 +1053,8 @@ public class Client : Thread // TODO: The below should all be automatic, maybe once IRCV3 is done // ... we should automate sending in NICK and USER stuff Thread.sleep(dur!("seconds")(2)); - client.command(new Message("", "NICK", "birchwood")); // TODO: add nickcommand + // client.command(new Message("", "NICK", "birchwood")); // TODO: add nickcommand + client.nick("birchwood"); Thread.sleep(dur!("seconds")(2)); client.command(new Message("", "USER", "doggie doggie irc.frdeenode.net :Tristan B. Kildaire"));