fix(cmd): kick and topic in patch loading
This commit is contained in:
parent
01e142f815
commit
ff5a074d81
3 changed files with 21 additions and 11 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:09:43 by rparodi ### ########.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,15 @@ 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->_cTarget->getTopic().empty()) {
|
if (this->_args.size() == 1) {
|
||||||
std::string msg331 = ":localhost 331 " + this->_sender->getNickname() + " " + this->_cTarget->getName() + " :No topic is set" + "\r\n";
|
if (this->_cTarget->getTopic().empty()) {
|
||||||
this->_sender->appendToWriteBuffer(msg331);
|
std::string msg331 = ":localhost 331 " + this->_sender->getNickname() + " " + this->_cTarget->getName() + " :No topic is set" + "\r\n";
|
||||||
|
this->_sender->appendToWriteBuffer(msg331);
|
||||||
|
} else {
|
||||||
|
std::string msg332 = ":localhost 332 " + this->_sender->getNickname() + " " + this->_cTarget->getName() + " :" + _cTarget->getTopic() + "\r\n";
|
||||||
|
this->_sender->appendToWriteBuffer(msg332);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
std::string msg332 = ":localhost 332 " + this->_sender->getNickname() + " " + this->_cTarget->getName() + " :" + _cTarget->getTopic() + "\r\n";
|
this->_cTarget->setTopic(this->_args.at(2));
|
||||||
this->_sender->appendToWriteBuffer(msg332);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue