parse parse parse
This commit is contained in:
23
Server.cpp
23
Server.cpp
@@ -153,7 +153,6 @@ std::string art =
|
|||||||
|
|
||||||
// FUNCTIONS OF TOP GGGGGG.. START FROM HEEEREEE
|
// FUNCTIONS OF TOP GGGGGG.. START FROM HEEEREEE
|
||||||
|
|
||||||
//triiiiiiiiiiiimmmmmm
|
|
||||||
std::string trim(const std::string& str) {
|
std::string trim(const std::string& str) {
|
||||||
size_t first = str.find_first_not_of(" \t\n\r");
|
size_t first = str.find_first_not_of(" \t\n\r");
|
||||||
if (std::string::npos == first) {
|
if (std::string::npos == first) {
|
||||||
@@ -606,7 +605,7 @@ void Server::handleClientData(int fd)
|
|||||||
else if (startsWith(command, "PING"))
|
else if (startsWith(command, "PING"))
|
||||||
{
|
{
|
||||||
std::istringstream iss(command);
|
std::istringstream iss(command);
|
||||||
std::string serverHostname = command.substr(5); // Skip the "PING " prefix
|
std::string serverHostname = command.substr(5);
|
||||||
std::string pongMessage = "PONG " + serverHostname + "\r\n";
|
std::string pongMessage = "PONG " + serverHostname + "\r\n";
|
||||||
send(fd, pongMessage.c_str(), pongMessage.length(), 0);
|
send(fd, pongMessage.c_str(), pongMessage.length(), 0);
|
||||||
std::cout << "ping was sent" << std::endl;
|
std::cout << "ping was sent" << std::endl;
|
||||||
@@ -928,27 +927,19 @@ void Server::handleClientData(int fd)
|
|||||||
|
|
||||||
else if (startsWith(command, "BOT ") || startsWith(command, "bot "))
|
else if (startsWith(command, "BOT ") || startsWith(command, "bot "))
|
||||||
{
|
{
|
||||||
std::cout << "HHHDFGFGD " << std::endl;
|
|
||||||
std::string start, end, guessed;
|
std::string start, end, guessed;
|
||||||
std::istringstream iss(command.substr(4));
|
std::istringstream iss(command.substr(4));
|
||||||
iss >> start >> end >> guessed;
|
iss >> start >> end >> guessed;
|
||||||
if (iss.fail())
|
std::string reme;
|
||||||
|
if (iss.fail() || iss >> reme)
|
||||||
{
|
{
|
||||||
std::string errorMessage = "Error: You Just missing arguments(2)\n";
|
std::string errorMessage = "Error: Command take 3 parameters\n";
|
||||||
send(fd, errorMessage.c_str(), errorMessage.length(), 0);
|
send(fd, errorMessage.c_str(), errorMessage.length(), 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
start = trim(start);
|
start = trim(start);
|
||||||
end = trim(end);
|
end = trim(end);
|
||||||
guessed = trim(guessed);
|
guessed = trim(guessed);
|
||||||
// std::string channelName, botname, start, end, guessed;
|
|
||||||
// std::istringstream iss(command.substr(4));
|
|
||||||
// iss >> channelName >> botname >> start >> end >> guessed;
|
|
||||||
// channelName = trim(channelName);
|
|
||||||
// botname = trim(botname);
|
|
||||||
// start = trim(start);
|
|
||||||
// end = trim(end);
|
|
||||||
// guessed = trim(guessed);
|
|
||||||
if (stringToInt(start) < stringToInt(end) && stringToInt(guessed) >= stringToInt(start) && stringToInt(guessed) <= stringToInt(end))
|
if (stringToInt(start) < stringToInt(end) && stringToInt(guessed) >= stringToInt(start) && stringToInt(guessed) <= stringToInt(end))
|
||||||
{
|
{
|
||||||
int r = randomInRange(stringToInt(start), stringToInt(end));
|
int r = randomInRange(stringToInt(start), stringToInt(end));
|
||||||
@@ -983,14 +974,9 @@ void Server::handleClientData(int fd)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
// std::getline(iss, nick);
|
|
||||||
channelName = channelName.substr(1);
|
channelName = channelName.substr(1);
|
||||||
channelName = trim(channelName);
|
channelName = trim(channelName);
|
||||||
mode = trim(mode);
|
mode = trim(mode);
|
||||||
|
|
||||||
// if (mode == "+l") // what is this ?
|
|
||||||
// nick = trim(nick);
|
|
||||||
|
|
||||||
std::cout << "this is the mode : " << mode << std::endl;
|
std::cout << "this is the mode : " << mode << std::endl;
|
||||||
if (mode == "+o")
|
if (mode == "+o")
|
||||||
{
|
{
|
||||||
@@ -1090,7 +1076,6 @@ void Server::handleClientData(int fd)
|
|||||||
}
|
}
|
||||||
else if (mode == "-k")
|
else if (mode == "-k")
|
||||||
{
|
{
|
||||||
// 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