Allow channel operators to invite users to a channel with +i

This commit is contained in:
Les De Ridder 2017-05-24 00:39:55 +02:00
parent 7ba5268e90
commit 4407a7419b
No known key found for this signature in database
GPG Key ID: 5EC132DFA85DB372
3 changed files with 18 additions and 2 deletions

View File

@ -21,6 +21,7 @@ class Channel
string key; string key;
Nullable!uint userLimit; Nullable!uint userLimit;
Connection[] inviteHolders;
private Server _server; private Server _server;
@ -43,6 +44,11 @@ class Channel
{ {
memberModes[connection] = []; memberModes[connection] = [];
} }
if(inviteHolders.canFind(connection))
{
inviteHolders = inviteHolders.remove!(c => c == connection);
}
} }
void part(Connection connection, string partMessage) void part(Connection connection, string partMessage)
@ -63,6 +69,11 @@ class Channel
memberModes.remove(connection); memberModes.remove(connection);
} }
void invite(Connection connection)
{
inviteHolders ~= connection;
}
void sendNames(Connection connection, bool sendRplEndOfNames = true) void sendNames(Connection connection, bool sendRplEndOfNames = true)
{ {
string channelType; string channelType;
@ -196,6 +207,8 @@ class Channel
modes ~= mode; modes ~= mode;
//TODO: If RFC-strictness is off, clear the invite list when +i is set
return true; return true;
} }

View File

@ -352,8 +352,7 @@ class Connection
{ {
send(Message(_server.name, "474", [nick, channelName, "Cannot join channel (+b)"], true)); send(Message(_server.name, "474", [nick, channelName, "Cannot join channel (+b)"], true));
} }
//TODO: Also account for invites from the INVITE command else if(channel.modes.canFind('i') && !(channel.maskLists['I'].any!(m => matchesMask(m)) || channel.inviteHolders.canFind(this)))
else if(channel.modes.canFind('i') && !channel.maskLists['I'].any!(m => matchesMask(m)))
{ {
send(Message(_server.name, "473", [nick, channelName, "Cannot join channel (+i)"], true)); send(Message(_server.name, "473", [nick, channelName, "Cannot join channel (+i)"], true));
} }

View File

@ -323,6 +323,10 @@ class Server
void invite(Connection inviter, string target, string channelName) void invite(Connection inviter, string target, string channelName)
{ {
auto user = findConnectionByNick(target)[0]; auto user = findConnectionByNick(target)[0];
auto channel = findChannelByName(channelName)[0];
channel.invite(user);
user.send(Message(inviter.prefix, "INVITE", [user.nick, channelName])); user.send(Message(inviter.prefix, "INVITE", [user.nick, channelName]));
} }