From fe91adde0a2b2f8f1b3e13dfa9ac715acd071339 Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Thu, 9 Mar 2023 08:37:38 +0200 Subject: [PATCH] Client - Fixed bug in `channelMessage(string, string[])` in the case where multiple channels were specified then the message would fail to send to the channels after the first one specified Unit tests - Disabled using `command(string, string, string)` to join a channel, rather use `joinChannel(string)` - Added tests for singular `channelMessage(string, string[])` and multiple `channelMessage(string, string[])` --- source/birchwood/client.d | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/source/birchwood/client.d b/source/birchwood/client.d index 38da76e..bcf4df4 100644 --- a/source/birchwood/client.d +++ b/source/birchwood/client.d @@ -507,6 +507,9 @@ public class Client : Thread /* Ensure valid characters in first channel */ if(isValidText(channelLine)) { + /* Append on a trailing `,` */ + channelLine ~= ","; + for(ulong i = 1; i < channels.length; i++) { string currentChannel = channels[i]; @@ -1177,7 +1180,10 @@ public class Client : Thread client.command(new Message("", "USER", "doggie doggie irc.frdeenode.net :Tristan B. Kildaire")); Thread.sleep(dur!("seconds")(4)); - client.command(new Message("", "JOIN", "#birchwood")); + // client.command(new Message("", "JOIN", "#birchwood")); + client.joinChannel("#birchwood"); + // TODO: Add a joinChannels(string[]) + client.joinChannel("#birchwood2"); Thread.sleep(dur!("seconds")(2)); client.command(new Message("", "NAMES", "")); @@ -1188,6 +1194,17 @@ public class Client : Thread Thread.sleep(dur!("seconds")(2)); client.command(new Message("", "PRIVMSG", "deavmi naai")); + + /** + * Test sending a message to a channel + */ + client.channelMessage("This is a test message sent to a channel", ["#birchwood"]); + + /** + * Test sending a message to multiple channels + */ + client.channelMessage("This is a message sent to multiple channels one-shot", ["#birchwood", "#birchwood2"]); + /* TODO: Add a check here to make sure the above worked I guess? */ /* TODO: Make this end */ // while(true)