From 1c0e771dd57f3fc4133921714f9f32f649354229 Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 18 Jun 2025 12:58:04 +0200 Subject: [PATCH] fix(cmds): sending the message ERR_NEEDMOREPARAMS (461) --- sources/commands/cap.cpp | 10 +++++----- sources/commands/invite.cpp | 5 +++-- sources/commands/join.cpp | 5 +++-- sources/commands/kick.cpp | 5 +++-- sources/commands/list.cpp | 5 +++-- sources/commands/modes.cpp | 7 +++++-- sources/commands/notice.cpp | 5 +++-- sources/commands/part.cpp | 5 +++-- sources/commands/pass.cpp | 5 +++-- sources/commands/ping.cpp | 5 +++-- sources/commands/privmsg.cpp | 5 +++-- sources/commands/userCmd.cpp | 5 +++-- 12 files changed, 40 insertions(+), 27 deletions(-) diff --git a/sources/commands/cap.cpp b/sources/commands/cap.cpp index 7a0418c..3b1510d 100644 --- a/sources/commands/cap.cpp +++ b/sources/commands/cap.cpp @@ -6,7 +6,7 @@ /* By: sben-tay +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/06/08 22:10:24 by sben-tay #+# #+# */ -/* Updated: 2025/06/14 22:26:07 by sben-tay ### ########.fr */ +/* Updated: 2025/06/18 12:54:41 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -16,12 +16,12 @@ using namespace cmd; e_code Cap::checkArgs() { - if (_args.size() < 2){ + if (_args.size() < 2) { + std::string msg461 = ":localhost 461 " + this->_sender->getNickname() + " " + this->_command + " :Not enough parameters\r\n"; + this->_sender->appendToWriteBuffer(msg461); return ERR_NEEDMOREPARAMS; - - _sender->appendToReadBuffer(_command); - } + _sender->appendToReadBuffer(_command); return (_PARSING_OK); } diff --git a/sources/commands/invite.cpp b/sources/commands/invite.cpp index e1996d8..a4a3545 100644 --- a/sources/commands/invite.cpp +++ b/sources/commands/invite.cpp @@ -6,7 +6,7 @@ /* By: sben-tay +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/05/24 17:29:48 by rparodi #+# #+# */ -/* Updated: 2025/06/12 13:24:05 by sben-tay ### ########.fr */ +/* Updated: 2025/06/18 12:52:35 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,7 +18,8 @@ using namespace cmd; e_code Invite::checkArgs() { if (_args.size() < 3) { - WARNING_MSG("Not enough arguments for INVITE command"); + std::string msg461 = ":localhost 461 " + this->_sender->getNickname() + " " + this->_command + " :Not enough parameters\r\n"; + this->_sender->appendToWriteBuffer(msg461); return ERR_NEEDMOREPARAMS; } if (_args.at(1).at(0) != '#') { diff --git a/sources/commands/join.cpp b/sources/commands/join.cpp index 2bfe86d..ebc4667 100644 --- a/sources/commands/join.cpp +++ b/sources/commands/join.cpp @@ -6,7 +6,7 @@ /* By: sben-tay +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/05/24 17:29:48 by rparodi #+# #+# */ -/* Updated: 2025/06/18 00:58:16 by sben-tay ### ########.fr */ +/* Updated: 2025/06/18 12:51:54 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -19,7 +19,8 @@ using namespace cmd; e_code Join::checkArgs() { if (_args.size() < 2 || _args[1].empty()) { - WARNING_MSG("Not enough arguments for Join command"); + std::string msg461 = ":localhost 461 " + this->_sender->getNickname() + " " + this->_command + " :Not enough parameters\r\n"; + this->_sender->appendToWriteBuffer(msg461); return ERR_NEEDMOREPARAMS; } if (_args[1][0] != '#') { diff --git a/sources/commands/kick.cpp b/sources/commands/kick.cpp index 2bce2e9..2dc0820 100644 --- a/sources/commands/kick.cpp +++ b/sources/commands/kick.cpp @@ -6,7 +6,7 @@ /* By: sben-tay +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/05/24 17:29:48 by rparodi #+# #+# */ -/* Updated: 2025/06/12 13:24:16 by sben-tay ### ########.fr */ +/* Updated: 2025/06/18 12:55:06 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,7 +18,8 @@ using namespace cmd; e_code Kick::checkArgs() { if (_args.size() < 3) { - WARNING_MSG("Not enough arguments for KICK command"); + std::string msg461 = ":localhost 461 " + this->_sender->getNickname() + " " + this->_command + " :Not enough parameters\r\n"; + this->_sender->appendToWriteBuffer(msg461); return ERR_NEEDMOREPARAMS; } if (_args.at(1).at(0) != '#') { diff --git a/sources/commands/list.cpp b/sources/commands/list.cpp index 132e025..026df47 100644 --- a/sources/commands/list.cpp +++ b/sources/commands/list.cpp @@ -6,7 +6,7 @@ /* By: sben-tay +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/05/24 17:29:48 by rparodi #+# #+# */ -/* Updated: 2025/06/12 13:24:21 by sben-tay ### ########.fr */ +/* Updated: 2025/06/18 12:52:13 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,7 +18,8 @@ using namespace cmd; e_code List::checkArgs() { if (_args.size() < 3) { - WARNING_MSG("Not enough arguments for LIST command"); + std::string msg461 = ":localhost 461 " + this->_sender->getNickname() + " " + this->_command + " :Not enough parameters\r\n"; + this->_sender->appendToWriteBuffer(msg461); return ERR_NEEDMOREPARAMS; } if (this->_sender->isRegistered() == false) { diff --git a/sources/commands/modes.cpp b/sources/commands/modes.cpp index 5239739..c9be75a 100644 --- a/sources/commands/modes.cpp +++ b/sources/commands/modes.cpp @@ -6,7 +6,7 @@ /* By: sben-tay +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/05/24 17:29:48 by rparodi #+# #+# */ -/* Updated: 2025/06/17 18:00:26 by rparodi ### ########.fr */ +/* Updated: 2025/06/18 12:53:44 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -74,8 +74,11 @@ void Mode::checkMode() { * @return return the e_code if there is an error else return _PARSING_OK */ e_code Mode::checkArgs() { - if (this->_args.size() < 2) + if (this->_args.size() < 2) { + std::string msg461 = ":localhost 461 " + this->_sender->getNickname() + " " + this->_command + " :Not enough parameters\r\n"; + this->_sender->appendToWriteBuffer(msg461); return ERR_NEEDMOREPARAMS; + } if (this->_args.at(1).at(0) != '#') { WARNING_MSG("Invalid channel name for INVITE command"); INFO_MSG("Channel names must start with a '#' character"); diff --git a/sources/commands/notice.cpp b/sources/commands/notice.cpp index b9d42ee..7f81a09 100644 --- a/sources/commands/notice.cpp +++ b/sources/commands/notice.cpp @@ -6,7 +6,7 @@ /* By: sben-tay +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/05/24 17:29:48 by rparodi #+# #+# */ -/* Updated: 2025/06/12 13:24:35 by sben-tay ### ########.fr */ +/* Updated: 2025/06/18 12:56:37 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,7 +18,8 @@ using namespace cmd; e_code Notice::checkArgs() { if (_args.size() < 3) { - WARNING_MSG("Not enough arguments for NOTICE command"); + std::string msg461 = ":localhost 461 " + this->_sender->getNickname() + " " + this->_command + " :Not enough parameters\r\n"; + this->_sender->appendToWriteBuffer(msg461); return ERR_NEEDMOREPARAMS; } if (_args.at(1).at(0) != '#') { diff --git a/sources/commands/part.cpp b/sources/commands/part.cpp index 6532dbd..d8fde2c 100644 --- a/sources/commands/part.cpp +++ b/sources/commands/part.cpp @@ -6,7 +6,7 @@ /* By: sben-tay +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/05/24 17:29:48 by rparodi #+# #+# */ -/* Updated: 2025/06/12 13:24:39 by sben-tay ### ########.fr */ +/* Updated: 2025/06/18 12:55:38 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -19,7 +19,8 @@ using namespace cmd; e_code Part::checkArgs() { if (_args.size() < 2) { - WARNING_MSG("Not enough arguments for PART command"); + std::string msg461 = ":localhost 461 " + this->_sender->getNickname() + " " + this->_command + " :Not enough parameters\r\n"; + this->_sender->appendToWriteBuffer(msg461); return ERR_NEEDMOREPARAMS; } if (_args.at(1).at(0) != '#') { diff --git a/sources/commands/pass.cpp b/sources/commands/pass.cpp index f16983d..0b917fc 100644 --- a/sources/commands/pass.cpp +++ b/sources/commands/pass.cpp @@ -6,7 +6,7 @@ /* By: sben-tay +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/05/24 17:29:48 by rparodi #+# #+# */ -/* Updated: 2025/06/16 17:33:20 by sben-tay ### ########.fr */ +/* Updated: 2025/06/18 12:55:50 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,7 +18,8 @@ using namespace cmd; e_code Pass::checkArgs() { if (_args.size() != 2) { - WARNING_MSG("Not correct for Pass command"); + std::string msg461 = ":localhost 461 " + this->_sender->getNickname() + " " + this->_command + " :Not enough parameters\r\n"; + this->_sender->appendToWriteBuffer(msg461); return ERR_NEEDMOREPARAMS; } return _PARSING_OK; diff --git a/sources/commands/ping.cpp b/sources/commands/ping.cpp index 5bc63c2..989d657 100644 --- a/sources/commands/ping.cpp +++ b/sources/commands/ping.cpp @@ -6,7 +6,7 @@ /* By: sben-tay +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/05/24 17:29:48 by rparodi #+# #+# */ -/* Updated: 2025/06/17 16:58:06 by sben-tay ### ########.fr */ +/* Updated: 2025/06/18 12:53:01 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -20,7 +20,8 @@ using namespace cmd; e_code Ping::checkArgs() { if (_args.size() < 2) { - WARNING_MSG("Not enough arguments for PING command"); + std::string msg461 = ":localhost 461 " + this->_sender->getNickname() + " " + this->_command + " :Not enough parameters\r\n"; + this->_sender->appendToWriteBuffer(msg461); return ERR_NEEDMOREPARAMS; } return _PARSING_OK; diff --git a/sources/commands/privmsg.cpp b/sources/commands/privmsg.cpp index a1df043..16d9dbb 100644 --- a/sources/commands/privmsg.cpp +++ b/sources/commands/privmsg.cpp @@ -6,7 +6,7 @@ /* By: sben-tay +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/05/24 17:29:48 by rparodi #+# #+# */ -/* Updated: 2025/06/18 00:56:49 by sben-tay ### ########.fr */ +/* Updated: 2025/06/18 12:51:56 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -21,7 +21,8 @@ using namespace cmd; e_code PrivMsg::checkArgs() { if (_args.size() < 3) { - WARNING_MSG("Not enough arguments for PRIVMSG command"); + std::string msg461 = ":localhost 461 " + this->_sender->getNickname() + " " + this->_command + " :Not enough parameters\r\n"; + this->_sender->appendToWriteBuffer(msg461); return ERR_NEEDMOREPARAMS; } diff --git a/sources/commands/userCmd.cpp b/sources/commands/userCmd.cpp index 3ec72a5..9d44325 100644 --- a/sources/commands/userCmd.cpp +++ b/sources/commands/userCmd.cpp @@ -6,7 +6,7 @@ /* By: sben-tay +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/06/08 19:16:10 by sben-tay #+# #+# */ -/* Updated: 2025/06/17 23:17:54 by sben-tay ### ########.fr */ +/* Updated: 2025/06/18 12:56:17 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -17,7 +17,8 @@ using namespace cmd; e_code cmd::userCmd::checkArgs() { if (_args.size() < 5) { - WARNING_MSG("USER: Not enough parameters"); + std::string msg461 = ":localhost 461 " + this->_sender->getNickname() + " " + this->_command + " :Not enough parameters\r\n"; + this->_sender->appendToWriteBuffer(msg461); return ERR_NEEDMOREPARAMS; } return _PARSING_OK;