Merge pull request #28 from EniumRaphael/raph
🛠️ Patch Notes — ft_irc v1.3.5
This commit is contained in:
commit
4f108e0125
5 changed files with 40 additions and 15 deletions
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: sben-tay <sben-tay@student.42.fr> +#+ +:+ +#+ */
|
/* By: sben-tay <sben-tay@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/05/24 17:29:48 by rparodi #+# #+# */
|
/* Created: 2025/05/24 17:29:48 by rparodi #+# #+# */
|
||||||
/* Updated: 2025/06/19 13:53:17 by sben-tay ### ########.fr */
|
/* Updated: 2025/06/20 16:57:53 by rparodi ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: sben-tay <sben-tay@student.42.fr> +#+ +:+ +#+ */
|
/* By: sben-tay <sben-tay@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/05/24 17:29:48 by rparodi #+# #+# */
|
/* Created: 2025/05/24 17:29:48 by rparodi #+# #+# */
|
||||||
/* Updated: 2025/06/20 16:47:40 by rparodi ### ########.fr */
|
/* Updated: 2025/06/20 17:01:49 by rparodi ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -72,7 +72,7 @@ void Kick::execute() {
|
||||||
msgKick += " :" + _args.at(4);
|
msgKick += " :" + _args.at(4);
|
||||||
msgKick += "\r\n";
|
msgKick += "\r\n";
|
||||||
|
|
||||||
this->_sender->appendToWriteBuffer(msgKick + msgPart);
|
this->_uTarget->appendToWriteBuffer(msgKick + msgPart);
|
||||||
_cTarget->removeUser(this->_uTarget);
|
_cTarget->removeUser(this->_uTarget);
|
||||||
_cTarget->removeOperator(this->_uTarget);
|
_cTarget->removeOperator(this->_uTarget);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: sben-tay <sben-tay@student.42.fr> +#+ +:+ +#+ */
|
/* By: sben-tay <sben-tay@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/05/24 17:29:48 by rparodi #+# #+# */
|
/* Created: 2025/05/24 17:29:48 by rparodi #+# #+# */
|
||||||
/* Updated: 2025/06/18 12:51:40 by rparodi ### ########.fr */
|
/* Updated: 2025/06/20 17:55:27 by sben-tay ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -18,12 +18,18 @@
|
||||||
using namespace cmd;
|
using namespace cmd;
|
||||||
|
|
||||||
e_code Topic::checkArgs() {
|
e_code Topic::checkArgs() {
|
||||||
if (_args.size() < 2) {
|
if (_args.size() < 3) {
|
||||||
std::string msg461 = ":localhost 461 " + this->_sender->getNickname() + " " + this->_command + " :Not enough parameters\r\n";
|
std::string msg461 = ":localhost 461 " + this->_sender->getNickname() + " " + this->_command + " :Not enough parameters\r\n";
|
||||||
this->_sender->appendToWriteBuffer(msg461);
|
this->_sender->appendToWriteBuffer(msg461);
|
||||||
return ERR_NEEDMOREPARAMS;
|
return ERR_NEEDMOREPARAMS;
|
||||||
}
|
}
|
||||||
this->_cTarget = searchList(this->_channels, this->_args[1]);
|
if (_args.at(1).at(0) != '#') {
|
||||||
|
WARNING_MSG("Invalid channel name for KICK command");
|
||||||
|
INFO_MSG("Channel names must start with a '#' character");
|
||||||
|
return ERR_NOSUCHCHANNEL;
|
||||||
|
} else
|
||||||
|
_args.at(1).erase(0, 1);
|
||||||
|
this->_cTarget = searchList(this->_server->getChannelsList(), this->_args[1]);
|
||||||
if (this->_cTarget == NULL)
|
if (this->_cTarget == NULL)
|
||||||
return ERR_NOSUCHCHANNEL;
|
return ERR_NOSUCHCHANNEL;
|
||||||
if (this->_cTarget->getProtectTopic()) {
|
if (this->_cTarget->getProtectTopic()) {
|
||||||
|
|
@ -46,11 +52,25 @@ void Topic::execute() {
|
||||||
ERROR_MSG("Invalid arguments for TOPIC command (see warning message)");
|
ERROR_MSG("Invalid arguments for TOPIC command (see warning message)");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this->_args.size() == 1) {
|
||||||
if (this->_cTarget->getTopic().empty()) {
|
if (this->_cTarget->getTopic().empty()) {
|
||||||
std::string msg331 = ":localhost 331 " + this->_sender->getNickname() + " " + this->_cTarget->getName() + " :No topic is set" + "\r\n";
|
std::string msg331 = ":localhost 331 " + this->_sender->getNickname() + " " + this->_cTarget->getName() + " :No topic is set\r\n";
|
||||||
this->_sender->appendToWriteBuffer(msg331);
|
this->_sender->appendToWriteBuffer(msg331);
|
||||||
} else {
|
} else {
|
||||||
std::string msg332 = ":localhost 332 " + this->_sender->getNickname() + " " + this->_cTarget->getName() + " :" + _cTarget->getTopic() + "\r\n";
|
std::string msg332 = ":localhost 332 " + this->_sender->getNickname() + " " + this->_cTarget->getName() + " :" + this->_cTarget->getTopic() + "\r\n";
|
||||||
this->_sender->appendToWriteBuffer(msg332);
|
this->_sender->appendToWriteBuffer(msg332);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
std::string newTopic;
|
||||||
|
for (size_t i = 2; i < this->_args.size(); ++i) {
|
||||||
|
newTopic += this->_args[i];
|
||||||
|
if (i != this->_args.size() - 1)
|
||||||
|
newTopic += " ";
|
||||||
|
}
|
||||||
|
this->_cTarget->setTopic(newTopic);
|
||||||
|
|
||||||
|
std::string topicMsg = ":" + this->_sender->getPrefix() + " TOPIC " + this->_cTarget->getName() + " :" + newTopic + "\r\n";
|
||||||
|
this->_cTarget->sendAllClientInAChannel(topicMsg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: sben-tay <sben-tay@student.42.fr> +#+ +:+ +#+ */
|
/* By: sben-tay <sben-tay@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/05/13 11:11:07 by rparodi #+# #+# */
|
/* Created: 2025/05/13 11:11:07 by rparodi #+# #+# */
|
||||||
/* Updated: 2025/06/19 02:24:05 by sben-tay ### ########.fr */
|
/* Updated: 2025/06/20 15:13:42 by sben-tay ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -106,9 +106,11 @@ void Server::start()
|
||||||
_users[fd]->appendToReadBuffer(data);
|
_users[fd]->appendToReadBuffer(data);
|
||||||
std::string rawCmd;
|
std::string rawCmd;
|
||||||
|
|
||||||
|
DEBUG_MSG("cmd = " << _users[fd]->extractFullCommand());
|
||||||
while (!(rawCmd = _users[fd]->extractFullCommand()).empty()) {
|
while (!(rawCmd = _users[fd]->extractFullCommand()).empty()) {
|
||||||
std::vector<std::string> lines = splitLines(rawCmd);
|
std::vector<std::string> lines = splitLines(rawCmd);
|
||||||
for (size_t i = 0; i < lines.size(); ++i) {
|
for (size_t i = 0; i < lines.size(); ++i) {
|
||||||
|
DEBUG_MSG("cmd = " << _users[fd]->extractFullCommand());
|
||||||
std::cout << "Client " << fd << " says: " << lines[i] << std::endl;
|
std::cout << "Client " << fd << " says: " << lines[i] << std::endl;
|
||||||
cmd::dispatch(_users[fd], NULL, this, lines[i]);
|
cmd::dispatch(_users[fd], NULL, this, lines[i]);
|
||||||
}
|
}
|
||||||
|
|
@ -126,8 +128,9 @@ void Server::start()
|
||||||
std::cerr << "Erreur send sur fd " << fd << std::endl;
|
std::cerr << "Erreur send sur fd " << fd << std::endl;
|
||||||
disconnectClient(fd);
|
disconnectClient(fd);
|
||||||
} else {
|
} else {
|
||||||
_users[fd]->consumeWriteBuffer(bytesSent);
|
_users[fd]->clearWriteBuffer();
|
||||||
if (_users[fd]->getWriteBuffer().empty())
|
// _users[fd]->consumeWriteBuffer(bytesSent);
|
||||||
|
// if (_users[fd]->getWriteBuffer().empty())
|
||||||
_pollManager.setWritable(fd, false);
|
_pollManager.setWritable(fd, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: sben-tay <sben-tay@student.42.fr> +#+ +:+ +#+ */
|
/* By: sben-tay <sben-tay@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/05/21 20:37:12 by omoudni #+# #+# */
|
/* Created: 2025/05/21 20:37:12 by omoudni #+# #+# */
|
||||||
/* Updated: 2025/06/19 02:23:06 by sben-tay ### ########.fr */
|
/* Updated: 2025/06/20 13:40:14 by sben-tay ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -123,6 +123,7 @@ std::string User::extractFullCommand() {
|
||||||
if (pos != std::string::npos) {
|
if (pos != std::string::npos) {
|
||||||
std::string command = _read_buffer.substr(0, pos);
|
std::string command = _read_buffer.substr(0, pos);
|
||||||
_read_buffer.erase(0, pos + 2);
|
_read_buffer.erase(0, pos + 2);
|
||||||
|
DEBUG_MSG(command);
|
||||||
return command;
|
return command;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -130,6 +131,7 @@ std::string User::extractFullCommand() {
|
||||||
if (pos != std::string::npos) {
|
if (pos != std::string::npos) {
|
||||||
std::string command = _read_buffer.substr(0, pos);
|
std::string command = _read_buffer.substr(0, pos);
|
||||||
_read_buffer.erase(0, pos + 1);
|
_read_buffer.erase(0, pos + 1);
|
||||||
|
DEBUG_MSG(command);
|
||||||
return command;
|
return command;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue