fix(core/error_code): now commands use the correct error code
This commit is contained in:
parent
8ea4da3b82
commit
bc8410a21d
19 changed files with 81 additions and 77 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/05/24 17:29:48 by rparodi #+# #+# */
|
||||
/* Updated: 2025/06/02 01:15:00 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/06/05 22:46:54 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -16,32 +16,32 @@
|
|||
|
||||
using namespace cmd;
|
||||
|
||||
bool PrivMsg::checkArgs() {
|
||||
e_code PrivMsg::checkArgs() {
|
||||
if (_args.size() < 3) {
|
||||
WARNING_MSG("Not enough arguments for PRIVMSG command");
|
||||
return false;
|
||||
return ERR_NEEDMOREPARAMS;
|
||||
}
|
||||
if (_args.at(1).at(0) != '#') {
|
||||
_uTarget = searchList(this->_users, _args.at(2));
|
||||
if (this->_uTarget == NULL) {
|
||||
WARNING_MSG("User not found");
|
||||
return false;
|
||||
return ERR_NOSUCHNICK;
|
||||
}
|
||||
if (this->_uTarget->isRegistered() == false) {
|
||||
WARNING_MSG("User is not registered for PRIVMSG command");
|
||||
INFO_MSG("You can only privmsg registered users");
|
||||
return false;
|
||||
return ERR_NOSUCHNICK;
|
||||
}
|
||||
} else {
|
||||
_cTarget = searchList(_channels, _args.at(1));
|
||||
if (_cTarget == NULL) {
|
||||
WARNING_MSG("Channel not found for PRIVMSG command");
|
||||
INFO_MSG("You can only privmsg users to channels you are in");
|
||||
return false;
|
||||
return ERR_NOSUCHCHANNEL;
|
||||
} else
|
||||
_args.at(1).erase(0, 1);
|
||||
}
|
||||
return true;
|
||||
return _PARSING_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -49,7 +49,7 @@ bool PrivMsg::checkArgs() {
|
|||
* @note To send a private message to a user / a channel
|
||||
*/
|
||||
void PrivMsg::execute() {
|
||||
if (checkArgs() == false) {
|
||||
if (checkArgs() == _PARSING_OK) {
|
||||
ERROR_MSG("Invalid arguments for PRIVMSG command (see warning message)");
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue