Ignore JOIN if user is already on channel

This commit is contained in:
Les De Ridder 2020-02-12 14:06:10 +01:00
parent f80070aa92
commit 786a3f17e8
2 changed files with 15 additions and 4 deletions

View File

@ -389,4 +389,9 @@ class Channel
return true;
}
bool hasMember(Connection connection)
{
return members.canFind(connection);
}
}

View File

@ -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);
}