From 9409cdf5077b8de5949b56626f4d5cbaa2b01dd2 Mon Sep 17 00:00:00 2001 From: "Tristan B. Kildaire" Date: Wed, 23 Sep 2020 23:57:45 +0200 Subject: [PATCH] Added 'part' command --- source/dnetd/dconnection.d | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/source/dnetd/dconnection.d b/source/dnetd/dconnection.d index b38cd2f..7e73bd7 100644 --- a/source/dnetd/dconnection.d +++ b/source/dnetd/dconnection.d @@ -207,6 +207,36 @@ public class DConnection : Thread /* TODO: Implement me, use return value */ writeSocket(tag, reply); } + /* If `part` command (requires: authed) */ + else if(commandByte == 4 && hasAuthed) + { + /* Get the channel names */ + string channelList = cast(string)message.data[1..message.data.length]; + string[] channels = split(channelList, ","); + + /** + * Loop through each channel, check if it + * exists, if so leave it + */ + foreach(string channelName; channels) + { + /* Attempt to find the channel */ + DChannel channel = server.getChannelByName(channelName); + + /* Leave a channel the channel only if it exists */ + if(!(channel is null)) + { + channel.leave(this); + } + } + + /* TODO: Do reply */ + /* Encode the reply */ + byte[] reply = [true]; + + /* TODO: Implement me, use return value */ + writeSocket(tag, reply); + } /* TODO: Handle this case */ else {