add some parss
This commit is contained in:
52
.vscode/settings.json
vendored
52
.vscode/settings.json
vendored
@@ -1,6 +1,56 @@
|
|||||||
{
|
{
|
||||||
"files.associations": {
|
"files.associations": {
|
||||||
"cstring": "cpp",
|
"cstring": "cpp",
|
||||||
"iostream": "cpp"
|
"iostream": "cpp",
|
||||||
|
"array": "cpp",
|
||||||
|
"atomic": "cpp",
|
||||||
|
"bit": "cpp",
|
||||||
|
"*.tcc": "cpp",
|
||||||
|
"cctype": "cpp",
|
||||||
|
"clocale": "cpp",
|
||||||
|
"cmath": "cpp",
|
||||||
|
"compare": "cpp",
|
||||||
|
"concepts": "cpp",
|
||||||
|
"csignal": "cpp",
|
||||||
|
"cstdarg": "cpp",
|
||||||
|
"cstddef": "cpp",
|
||||||
|
"cstdint": "cpp",
|
||||||
|
"cstdio": "cpp",
|
||||||
|
"cstdlib": "cpp",
|
||||||
|
"ctime": "cpp",
|
||||||
|
"cwchar": "cpp",
|
||||||
|
"cwctype": "cpp",
|
||||||
|
"deque": "cpp",
|
||||||
|
"map": "cpp",
|
||||||
|
"string": "cpp",
|
||||||
|
"unordered_map": "cpp",
|
||||||
|
"vector": "cpp",
|
||||||
|
"exception": "cpp",
|
||||||
|
"algorithm": "cpp",
|
||||||
|
"functional": "cpp",
|
||||||
|
"iterator": "cpp",
|
||||||
|
"memory": "cpp",
|
||||||
|
"memory_resource": "cpp",
|
||||||
|
"numeric": "cpp",
|
||||||
|
"optional": "cpp",
|
||||||
|
"random": "cpp",
|
||||||
|
"string_view": "cpp",
|
||||||
|
"system_error": "cpp",
|
||||||
|
"tuple": "cpp",
|
||||||
|
"type_traits": "cpp",
|
||||||
|
"utility": "cpp",
|
||||||
|
"initializer_list": "cpp",
|
||||||
|
"iomanip": "cpp",
|
||||||
|
"iosfwd": "cpp",
|
||||||
|
"istream": "cpp",
|
||||||
|
"limits": "cpp",
|
||||||
|
"new": "cpp",
|
||||||
|
"numbers": "cpp",
|
||||||
|
"ostream": "cpp",
|
||||||
|
"sstream": "cpp",
|
||||||
|
"stdexcept": "cpp",
|
||||||
|
"streambuf": "cpp",
|
||||||
|
"cinttypes": "cpp",
|
||||||
|
"typeinfo": "cpp"
|
||||||
}
|
}
|
||||||
}
|
}
|
36
Server.cpp
36
Server.cpp
@@ -770,7 +770,7 @@ void Server::handleClientData(int fd)
|
|||||||
std::getline(iss, message);
|
std::getline(iss, message);
|
||||||
if (iss.fail())
|
if (iss.fail())
|
||||||
{
|
{
|
||||||
std::string errorMessage = "Error: You Just missing an argument\n";
|
std::string errorMessage = "Error: You Just missing an argument(5)\n";
|
||||||
send(fd, errorMessage.c_str(), errorMessage.length(), 0);
|
send(fd, errorMessage.c_str(), errorMessage.length(), 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -801,9 +801,16 @@ void Server::handleClientData(int fd)
|
|||||||
else if (startsWith(command, "KICK ") || startsWith(command, "kick "))
|
else if (startsWith(command, "KICK ") || startsWith(command, "kick "))
|
||||||
{
|
{
|
||||||
std::string channelName, userToKick, reason;
|
std::string channelName, userToKick, reason;
|
||||||
std::istringstream iss(command.substr(6));
|
std::istringstream iss(command.substr(5));
|
||||||
iss >> channelName >> userToKick;
|
iss >> channelName >> userToKick;
|
||||||
|
if (iss.fail())
|
||||||
|
{
|
||||||
|
std::string errorMessage = "Error: You Just missing an argument(4)\n";
|
||||||
|
send(fd, errorMessage.c_str(), errorMessage.length(), 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
std::getline(iss, reason);
|
std::getline(iss, reason);
|
||||||
|
channelName = channelName.substr(1);
|
||||||
channelName = trim(channelName);
|
channelName = trim(channelName);
|
||||||
userToKick = trim(userToKick);
|
userToKick = trim(userToKick);
|
||||||
reason = trim(reason);
|
reason = trim(reason);
|
||||||
@@ -837,9 +844,16 @@ void Server::handleClientData(int fd)
|
|||||||
else if (startsWith(command, "TOPIC ") || startsWith(command, "topic "))
|
else if (startsWith(command, "TOPIC ") || startsWith(command, "topic "))
|
||||||
{
|
{
|
||||||
std::string channelName, topic;
|
std::string channelName, topic;
|
||||||
std::istringstream iss(command.substr(7));
|
std::istringstream iss(command.substr(6));
|
||||||
iss >> channelName;
|
iss >> channelName;
|
||||||
std::getline(iss, topic);
|
std::getline(iss, topic);
|
||||||
|
if (iss.fail())
|
||||||
|
{
|
||||||
|
std::string errorMessage = "Error: You Just missing an argument(3)\n";
|
||||||
|
send(fd, errorMessage.c_str(), errorMessage.length(), 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
channelName = channelName.substr(1);
|
||||||
channelName = trim(channelName);
|
channelName = trim(channelName);
|
||||||
topic = trim(topic);
|
topic = trim(topic);
|
||||||
topic = topic.substr(1);
|
topic = topic.substr(1);
|
||||||
@@ -865,6 +879,12 @@ void Server::handleClientData(int fd)
|
|||||||
std::string channelName, nickname;
|
std::string channelName, nickname;
|
||||||
std::istringstream iss(command.substr(7));
|
std::istringstream iss(command.substr(7));
|
||||||
iss >> nickname >> channelName;
|
iss >> nickname >> channelName;
|
||||||
|
if (iss.fail())
|
||||||
|
{
|
||||||
|
std::string errorMessage = "Error: You Just missing an argument(2)\n";
|
||||||
|
send(fd, errorMessage.c_str(), errorMessage.length(), 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
channelName = trim(channelName);
|
channelName = trim(channelName);
|
||||||
nickname = trim(nickname);
|
nickname = trim(nickname);
|
||||||
channelName = channelName.substr(1);
|
channelName = channelName.substr(1);
|
||||||
@@ -922,8 +942,12 @@ void Server::handleClientData(int fd)
|
|||||||
{
|
{
|
||||||
std::string channelName, mode , nick;
|
std::string channelName, mode , nick;
|
||||||
int limit;
|
int limit;
|
||||||
std::istringstream iss(command.substr(6));
|
std::istringstream iss(command.substr(5));
|
||||||
iss >> channelName >> mode >> nick;
|
iss >> channelName >> mode >> nick;
|
||||||
|
if (iss.fail())
|
||||||
|
return;
|
||||||
|
// std::getline(iss, nick);
|
||||||
|
channelName = channelName.substr(1);
|
||||||
channelName = trim(channelName);
|
channelName = trim(channelName);
|
||||||
mode = trim(mode);
|
mode = trim(mode);
|
||||||
// if (mode == "+l") // what is this ?
|
// if (mode == "+l") // what is this ?
|
||||||
@@ -1030,7 +1054,7 @@ void Server::handleClientData(int fd)
|
|||||||
}
|
}
|
||||||
else if (mode == "-k")
|
else if (mode == "-k")
|
||||||
{
|
{
|
||||||
std::string ChanPass = (mode.substr(2));
|
// std::string ChanPass = (mode.substr(2));
|
||||||
if (channels.find(channelName) != channels.end() && channels[channelName].isOperator(fd))
|
if (channels.find(channelName) != channels.end() && channels[channelName].isOperator(fd))
|
||||||
{
|
{
|
||||||
std::string modeChangeMessage = ":server.host MODE #" + channelName + " -k by " + channels[channelName].getNickname(fd) + "\n";
|
std::string modeChangeMessage = ":server.host MODE #" + channelName + " -k by " + channels[channelName].getNickname(fd) + "\n";
|
||||||
|
Reference in New Issue
Block a user