From 786a3f17e83aa51fd1e90a714c0ee6318c72466d Mon Sep 17 00:00:00 2001 From: Les De Ridder Date: Wed, 12 Feb 2020 14:06:10 +0100 Subject: [PATCH] Ignore JOIN if user is already on channel --- source/ircd/channel.d | 5 +++++ source/ircd/connection.d | 14 ++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/source/ircd/channel.d b/source/ircd/channel.d index a5f75ae..a9b8a4b 100644 --- a/source/ircd/channel.d +++ b/source/ircd/channel.d @@ -389,4 +389,9 @@ class Channel return true; } + + bool hasMember(Connection connection) + { + return members.canFind(connection); + } } diff --git a/source/ircd/connection.d b/source/ircd/connection.d index 1cdfa2e..d3399f6 100644 --- a/source/ircd/connection.d +++ b/source/ircd/connection.d @@ -398,7 +398,6 @@ class Connection auto channelList = message.parameters[0].split(','); foreach (channelName; channelList) { - //TODO: Check if the user isn't already on the channel if (!Server.isValidChannelName(channelName)) { sendErrNoSuchChannel(channelName); @@ -413,6 +412,15 @@ class Connection else { auto channel = channelRange[0]; + + if (channel.hasMember(this)) + { + return; + } + + //TODO: Implement channel limit + //TODO: Implement channel key + if (channel.maskLists['b'].any!(m => matchesMask(m))) { send(Message(_server.name, "474", [ @@ -427,9 +435,7 @@ class Connection nick, channelName, "Cannot join channel (+i)" ], true)); } - //TODO: Implement channel limit - //TODO: Implement channel key - else + else { _server.join(this, channelName); }