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 22:44:49 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/06/05 22:49:09 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -16,32 +16,32 @@
|
|||
|
||||
using namespace cmd;
|
||||
|
||||
bool Notice::checkArgs() {
|
||||
e_code Notice::checkArgs() {
|
||||
if (_args.size() < 3) {
|
||||
WARNING_MSG("Not enough arguments for NOTICE 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 NOTICE command");
|
||||
INFO_MSG("You can only NOTICE registered users");
|
||||
return false;
|
||||
return ERR_NOSUCHNICK;
|
||||
}
|
||||
} else {
|
||||
_cTarget = searchList(_channels, _args.at(1));
|
||||
if (_cTarget == NULL) {
|
||||
WARNING_MSG("Channel not found for NOTICE command");
|
||||
INFO_MSG("You can only NOTICE 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 Notice::checkArgs() {
|
|||
* @note To send a private message to a user / a channel (like privmsg but without error)
|
||||
*/
|
||||
void Notice::execute() {
|
||||
if (checkArgs() == false) {
|
||||
if (checkArgs() == _PARSING_OK) {
|
||||
ERROR_MSG("Invalid arguments for NOTICE command (see warning message)");
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue