feat(cmd/pass): adding the start of pass command

This commit is contained in:
Raphael 2025-05-29 13:05:36 +02:00
parent 3d71d977d2
commit 8565a948ce
9 changed files with 42 additions and 16 deletions

View file

@ -6,12 +6,13 @@
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/05/24 16:11:56 by rparodi #+# #+# */
/* Updated: 2025/05/26 18:25:18 by rparodi ### ########.fr */
/* Updated: 2025/05/29 12:48:13 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include "commands.hpp"
#include "logs.hpp"
#include "pass.hpp"
/**
* @brief To send the line where a command is invoqued to execute
@ -91,6 +92,9 @@ void cmd::dispatch(::User *user, Channel *channel, Server *server, const std::st
// }
break;
case 'p':
if (command_name == "pass") {
Pass(user, channel, server, line).execute();
}
// if (command_name == "part") {
// Part(user, channel, server, line).execute();
// }

View file

@ -6,7 +6,7 @@
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/05/24 17:29:48 by rparodi #+# #+# */
/* Updated: 2025/05/26 22:50:04 by rparodi ### ########.fr */
/* Updated: 2025/05/29 12:10:25 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
@ -25,7 +25,8 @@ bool Invite::checkArgs() {
WARNING_MSG("Invalid channel name for INVITE command");
INFO_MSG("Channel names must start with a '#' character");
return false;
}
} else
_args.at(1).erase(0, 1);
_cTarget = searchList(_channels, _args.at(1));
if (_cTarget == NULL) {
WARNING_MSG("Channel not found for INVITE command");
@ -55,6 +56,10 @@ bool Invite::checkArgs() {
return true;
}
/**
* @brief Execute the invite command
* @note To invite a peapol to join a channel (from an operator)
*/
void Invite::execute() {
if (checkArgs() == false) {
ERROR_MSG("Invalid arguments for INVITE command (see warning message)");

View file

@ -6,7 +6,7 @@
/* By: omoudni <omoudni@student.42paris.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/05/13 11:11:07 by rparodi #+# #+# */
/* Updated: 2025/05/26 22:30:07 by rparodi ### ########.fr */
/* Updated: 2025/05/29 12:17:15 by rparodi ### ########.fr */
/* */
/******************************************************************************/
@ -148,6 +148,13 @@ void Server::printUsers() const
}
}
/**
* @brief The getter for the password
*
* @return the password of the server
*/
std::string Server::getPassword() const { return this->_password; }
std::list<User *> Server::getUsersList() const {
// to_delete when done
WARNING_MSG("TO DO FILL")

View file

@ -6,7 +6,7 @@
/* By: omoudni <omoudni@student.42paris.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/05/21 20:37:12 by omoudni #+# #+# */
/* Updated: 2025/05/22 17:13:35 by omoudni ### ########.fr */
/* Updated: 2025/05/29 12:38:46 by rparodi ### ########.fr */
/* */
/******************************************************************************/
@ -15,11 +15,12 @@
// Constructor
User::User(short unsigned int fd) : _fd(fd), _registered(false), _hasNick(false), _hasUser(false) {}
// Getter for fd
short unsigned int User::getFd() const
{
return _fd;
}
/**
* @brief Getter for the fd
*
* @return the fd of the user
*/
short unsigned int User::getFd() const { return this->_fd; }
/**
* @brief Getter for the nickname of the user
@ -64,6 +65,13 @@ void User::setNickname(const std::string &nickname)
}
}
/**
* @brief Setter to register a user
*/
void User::setRegistered() {
this->_registered = true;
}
// Registration state
bool User::isRegistered() const
{