Fix parsing messages with no parameters

This commit is contained in:
Les De Ridder 2017-03-14 17:45:28 +01:00
parent 6c0f6aa72d
commit c157a1e7a6
No known key found for this signature in database
GPG Key ID: 5EC132DFA85DB372
3 changed files with 12 additions and 2 deletions

View File

@ -120,7 +120,7 @@ class Connection
break;
default:
writeln("unknown command '", message.command, "'");
send(Message(_server.name, "421", [nick, "Unknown command"]));
send(Message(_server.name, "421", [nick, message.command, "Unknown command"]));
break;
}
}

View File

@ -24,6 +24,11 @@ struct Message
line = line[prefix.length + 1 .. $];
}
if(!line.canFind(' '))
{
return Message(prefix, line, [], false);
}
auto command = line[0 .. line.indexOf(' ')];
line = line[command.length + 1 .. $];
string[] params = [];
@ -60,6 +65,11 @@ struct Message
message = ":" ~ prefix ~ " ";
}
if(parameters.length == 0)
{
return message ~ command;
}
message ~= command ~ " ";
if(parameters.length > 1)
{

View File

@ -127,7 +127,7 @@ class Server
}
else
{
peer.send(Message(connection.mask, "QUIT"));
peer.send(Message(connection.mask, "QUIT", [connection.nick], true));
}
}
}