forked from lesderid/salty-ircd
Fix miscellaneous bugs and TODOs
This commit is contained in:
parent
6a6006c2c5
commit
b8484c60d4
|
@ -39,6 +39,10 @@ class Channel
|
||||||
{
|
{
|
||||||
memberModes[connection] ~= 'o';
|
memberModes[connection] ~= 'o';
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
memberModes[connection] = [];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void part(Connection connection, string partMessage)
|
void part(Connection connection, string partMessage)
|
||||||
|
@ -300,20 +304,22 @@ class Channel
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
string prefixedNick(Connection member)
|
string nickPrefix(Connection member)
|
||||||
{
|
{
|
||||||
if(memberModes[member].canFind('o'))
|
if(memberModes[member].canFind('o'))
|
||||||
{
|
{
|
||||||
return '@' ~ member.nick;
|
return "@";
|
||||||
}
|
}
|
||||||
else if(memberModes[member].canFind('v'))
|
else if(memberModes[member].canFind('v'))
|
||||||
{
|
{
|
||||||
return '+' ~ member.nick;
|
return "+";
|
||||||
}
|
}
|
||||||
|
|
||||||
return member.nick;
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string prefixedNick(Connection member) { return nickPrefix(member) ~ member.nick; }
|
||||||
|
|
||||||
bool visibleTo(Connection connection)
|
bool visibleTo(Connection connection)
|
||||||
{
|
{
|
||||||
return members.canFind(connection) || !modes.canFind('s') && !modes.canFind('p');
|
return members.canFind(connection) || !modes.canFind('s') && !modes.canFind('p');
|
||||||
|
|
|
@ -41,6 +41,9 @@ class Connection
|
||||||
@property bool isOperator() { return modes.canFind('o') || modes.canFind('O'); }
|
@property bool isOperator() { return modes.canFind('o') || modes.canFind('O'); }
|
||||||
@property string servername() { return _server.name; } //TODO: Support server linking
|
@property string servername() { return _server.name; } //TODO: Support server linking
|
||||||
|
|
||||||
|
//TODO: Maybe replace string's opEquals (or make a new string class/struct) to compare with toIRCLower
|
||||||
|
//TODO: Read errata
|
||||||
|
|
||||||
this(TCPConnection connection, Server server)
|
this(TCPConnection connection, Server server)
|
||||||
{
|
{
|
||||||
_connection = connection;
|
_connection = connection;
|
||||||
|
@ -263,7 +266,6 @@ class Connection
|
||||||
|
|
||||||
auto wasRegistered = registered;
|
auto wasRegistered = registered;
|
||||||
|
|
||||||
//TODO: Check validity etc.
|
|
||||||
nick = newNick;
|
nick = newNick;
|
||||||
|
|
||||||
if(!wasRegistered && registered)
|
if(!wasRegistered && registered)
|
||||||
|
@ -323,7 +325,10 @@ class Connection
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto channel = message.parameters[0];
|
auto channelList = message.parameters[0].split(',');
|
||||||
|
foreach(channel; channelList)
|
||||||
|
{
|
||||||
|
//TODO: Check if the user isn't already on the channel
|
||||||
if(!Server.isValidChannelName(channel))
|
if(!Server.isValidChannelName(channel))
|
||||||
{
|
{
|
||||||
sendErrNoSuchChannel(channel);
|
sendErrNoSuchChannel(channel);
|
||||||
|
@ -333,6 +338,7 @@ class Connection
|
||||||
_server.join(this, channel);
|
_server.join(this, channel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void onPart(Message message)
|
void onPart(Message message)
|
||||||
{
|
{
|
||||||
|
@ -342,14 +348,14 @@ class Connection
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: Support channel lists
|
auto channelList = message.parameters[0].split(',');
|
||||||
//TODO: Check if user is member of channel(s)
|
foreach(channel; channelList)
|
||||||
auto channel = message.parameters[0];
|
{
|
||||||
if(!Server.isValidChannelName(channel))
|
if(!Server.isValidChannelName(channel))
|
||||||
{
|
{
|
||||||
sendErrNoSuchChannel(channel);
|
sendErrNoSuchChannel(channel);
|
||||||
}
|
}
|
||||||
else if(!_server.canFindChannelByName(channel))
|
else if(!_server.canFindChannelByName(channel) || !channels.canFind!(c => c.name.toIRCLower == channel.toIRCLower))
|
||||||
{
|
{
|
||||||
send(Message(_server.name, "442", [nick, channel, "You're not on that channel"], true));
|
send(Message(_server.name, "442", [nick, channel, "You're not on that channel"], true));
|
||||||
}
|
}
|
||||||
|
@ -365,6 +371,7 @@ class Connection
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void onPrivMsg(Message message)
|
void onPrivMsg(Message message)
|
||||||
{
|
{
|
||||||
|
@ -1041,7 +1048,7 @@ Lforeach:
|
||||||
{
|
{
|
||||||
limit = limitString.to!uint;
|
limit = limitString.to!uint;
|
||||||
}
|
}
|
||||||
catch(Exception)
|
catch(Throwable)
|
||||||
{
|
{
|
||||||
break Lforeach;
|
break Lforeach;
|
||||||
}
|
}
|
||||||
|
@ -1090,11 +1097,11 @@ Lforeach:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void sendWhoReply(string channel, Connection user, uint hopCount)
|
void sendWhoReply(string channel, Connection user, string nickPrefix, uint hopCount)
|
||||||
{
|
{
|
||||||
auto flags = user.modes.canFind('a') ? "G" : "H";
|
auto flags = user.modes.canFind('a') ? "G" : "H";
|
||||||
if(user.isOperator) flags ~= "*";
|
if(user.isOperator) flags ~= "*";
|
||||||
//TODO: Add channel prefix
|
flags ~= nickPrefix;
|
||||||
|
|
||||||
send(Message(_server.name, "352", [nick, channel, user.user, user.hostname, user.servername, user.nick, flags, hopCount.to!string ~ " " ~ user.realname], true));
|
send(Message(_server.name, "352", [nick, channel, user.user, user.hostname, user.servername, user.nick, flags, hopCount.to!string ~ " " ~ user.realname], true));
|
||||||
}
|
}
|
||||||
|
|
|
@ -208,7 +208,7 @@ class Server
|
||||||
.filter!(c => c.visibleTo(origin)))
|
.filter!(c => c.visibleTo(origin)))
|
||||||
{
|
{
|
||||||
//TODO: Support hop count
|
//TODO: Support hop count
|
||||||
origin.sendWhoReply(channelName, c, 0);
|
origin.sendWhoReply(channelName, c, channel.nickPrefix(c), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,8 +220,9 @@ class Server
|
||||||
{
|
{
|
||||||
//TODO: Don't leak secret/private channels if RFC-strictness is off (the RFCs don't seem to say anything about it?)
|
//TODO: Don't leak secret/private channels if RFC-strictness is off (the RFCs don't seem to say anything about it?)
|
||||||
auto channelName = c.channels.empty ? "*" : c.channels.array[0].name;
|
auto channelName = c.channels.empty ? "*" : c.channels.array[0].name;
|
||||||
|
auto nickPrefix = c.channels.empty ? "" : c.channels.array[0].nickPrefix(c);
|
||||||
//TODO: Support hop count
|
//TODO: Support hop count
|
||||||
origin.sendWhoReply(channelName, c, 0);
|
origin.sendWhoReply(channelName, c, nickPrefix, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -374,8 +375,7 @@ class Server
|
||||||
}
|
}
|
||||||
auto idleSeconds = (Clock.currTime - user.lastMessageTime).total!"seconds";
|
auto idleSeconds = (Clock.currTime - user.lastMessageTime).total!"seconds";
|
||||||
connection.send(Message(name, "317", [connection.nick, user.nick, idleSeconds.to!string, "seconds idle"], true));
|
connection.send(Message(name, "317", [connection.nick, user.nick, idleSeconds.to!string, "seconds idle"], true));
|
||||||
//TODO: Prepend nick prefix (i.e. '@' or '+') when applicable
|
auto userChannels = user.channels.map!(c => c.nickPrefix(user) ~ c.name).join(' ');
|
||||||
auto userChannels = user.channels.map!(c => c.name).join(' ');
|
|
||||||
connection.send(Message(name, "319", [connection.nick, user.nick, userChannels], true));
|
connection.send(Message(name, "319", [connection.nick, user.nick, userChannels], true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -385,10 +385,8 @@ class Server
|
||||||
|
|
||||||
user.send(Message(killer.prefix, "KILL", [nick, comment], true));
|
user.send(Message(killer.prefix, "KILL", [nick, comment], true));
|
||||||
|
|
||||||
//TODO: Find out if any RFC specifies a QUIT message
|
|
||||||
quit(user, "Killed by " ~ killer.nick ~ " (" ~ comment ~ ")");
|
quit(user, "Killed by " ~ killer.nick ~ " (" ~ comment ~ ")");
|
||||||
|
|
||||||
//TODO: Find out if what we have to send here
|
|
||||||
user.send(Message(null, "ERROR", ["Closing Link: Killed by " ~ killer.nick ~ " (" ~ comment ~ ")"], true));
|
user.send(Message(null, "ERROR", ["Closing Link: Killed by " ~ killer.nick ~ " (" ~ comment ~ ")"], true));
|
||||||
user.closeConnection();
|
user.closeConnection();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue