feat(cmd/pass): adding the start of pass command
This commit is contained in:
parent
3d71d977d2
commit
8565a948ce
9 changed files with 42 additions and 16 deletions
3
Makefile
3
Makefile
|
|
@ -6,7 +6,7 @@
|
||||||
# By: omoudni <omoudni@student.42paris.fr> +#+ +:+ +#+ #
|
# By: omoudni <omoudni@student.42paris.fr> +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2025/05/02 15:40:00 by rparodi #+# #+# #
|
# Created: 2025/05/02 15:40:00 by rparodi #+# #+# #
|
||||||
# Updated: 2025/05/26 18:22:38 by rparodi ### ########.fr #
|
# Updated: 2025/05/29 12:31:53 by rparodi ### ########.fr #
|
||||||
# #
|
# #
|
||||||
#******************************************************************************#
|
#******************************************************************************#
|
||||||
|
|
||||||
|
|
@ -32,6 +32,7 @@ SRC = sources/channel/channel.cpp \
|
||||||
sources/core/parser.cpp \
|
sources/core/parser.cpp \
|
||||||
sources/user/user.cpp \
|
sources/user/user.cpp \
|
||||||
sources/commands/commands.cpp \
|
sources/commands/commands.cpp \
|
||||||
|
sources/commands/pass.cpp \
|
||||||
sources/commands/invite.cpp
|
sources/commands/invite.cpp
|
||||||
|
|
||||||
INC_DIR = include/core \
|
INC_DIR = include/core \
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/05/20 23:31:58 by rparodi #+# #+# */
|
/* Created: 2025/05/20 23:31:58 by rparodi #+# #+# */
|
||||||
/* Updated: 2025/05/26 18:25:49 by rparodi ### ########.fr */
|
/* Updated: 2025/05/29 12:47:57 by rparodi ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -53,7 +53,6 @@ namespace cmd
|
||||||
class Nick;
|
class Nick;
|
||||||
class Notice;
|
class Notice;
|
||||||
class Part;
|
class Part;
|
||||||
class Pass;
|
|
||||||
class Ping;
|
class Ping;
|
||||||
class Pong;
|
class Pong;
|
||||||
class PrivMsg;
|
class PrivMsg;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/05/24 17:34:30 by rparodi #+# #+# */
|
/* Created: 2025/05/24 17:34:30 by rparodi #+# #+# */
|
||||||
/* Updated: 2025/05/26 18:20:34 by rparodi ### ########.fr */
|
/* Updated: 2025/05/27 14:34:56 by rparodi ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: omoudni <omoudni@student.42paris.fr> +#+ +:+ +#+ */
|
/* By: omoudni <omoudni@student.42paris.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/05/20 21:50:32 by rparodi #+# #+# */
|
/* Created: 2025/05/20 21:50:32 by rparodi #+# #+# */
|
||||||
/* Updated: 2025/05/26 22:26:04 by rparodi ### ########.fr */
|
/* Updated: 2025/05/29 12:17:55 by rparodi ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
|
|
@ -37,6 +37,7 @@ public:
|
||||||
unsigned short int getPort() const;
|
unsigned short int getPort() const;
|
||||||
std::list<User *> getUsersList() const;
|
std::list<User *> getUsersList() const;
|
||||||
std::list<Channel *> getChannelsList() const;
|
std::list<Channel *> getChannelsList() const;
|
||||||
|
std::string getPassword() const;
|
||||||
void showInfo() const;
|
void showInfo() const;
|
||||||
void printUsers() const;
|
void printUsers() const;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: omoudni <omoudni@student.42paris.fr> +#+ +:+ +#+ */
|
/* By: omoudni <omoudni@student.42paris.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/05/20 21:57:49 by rparodi #+# #+# */
|
/* Created: 2025/05/20 21:57:49 by rparodi #+# #+# */
|
||||||
/* Updated: 2025/05/26 18:10:24 by rparodi ### ########.fr */
|
/* Updated: 2025/05/29 12:37:11 by rparodi ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
|
|
@ -34,6 +34,7 @@ class User
|
||||||
bool isRegistered() const;
|
bool isRegistered() const;
|
||||||
std::string getName() const;
|
std::string getName() const;
|
||||||
std::string extractFullCommand();
|
std::string extractFullCommand();
|
||||||
|
void setRegistered();
|
||||||
void appendToReadBuffer(const std::string &data);
|
void appendToReadBuffer(const std::string &data);
|
||||||
void appendToWriteBuffer(const std::string &data);
|
void appendToWriteBuffer(const std::string &data);
|
||||||
void setNickname(const std::string &nickname);
|
void setNickname(const std::string &nickname);
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,13 @@
|
||||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/05/24 16:11:56 by rparodi #+# #+# */
|
/* 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 "commands.hpp"
|
||||||
#include "logs.hpp"
|
#include "logs.hpp"
|
||||||
|
#include "pass.hpp"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief To send the line where a command is invoqued to execute
|
* @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;
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
|
if (command_name == "pass") {
|
||||||
|
Pass(user, channel, server, line).execute();
|
||||||
|
}
|
||||||
// if (command_name == "part") {
|
// if (command_name == "part") {
|
||||||
// Part(user, channel, server, line).execute();
|
// Part(user, channel, server, line).execute();
|
||||||
// }
|
// }
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/05/24 17:29:48 by rparodi #+# #+# */
|
/* 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");
|
WARNING_MSG("Invalid channel name for INVITE command");
|
||||||
INFO_MSG("Channel names must start with a '#' character");
|
INFO_MSG("Channel names must start with a '#' character");
|
||||||
return false;
|
return false;
|
||||||
}
|
} else
|
||||||
|
_args.at(1).erase(0, 1);
|
||||||
_cTarget = searchList(_channels, _args.at(1));
|
_cTarget = searchList(_channels, _args.at(1));
|
||||||
if (_cTarget == NULL) {
|
if (_cTarget == NULL) {
|
||||||
WARNING_MSG("Channel not found for INVITE command");
|
WARNING_MSG("Channel not found for INVITE command");
|
||||||
|
|
@ -55,6 +56,10 @@ bool Invite::checkArgs() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Execute the invite command
|
||||||
|
* @note To invite a peapol to join a channel (from an operator)
|
||||||
|
*/
|
||||||
void Invite::execute() {
|
void Invite::execute() {
|
||||||
if (checkArgs() == false) {
|
if (checkArgs() == false) {
|
||||||
ERROR_MSG("Invalid arguments for INVITE command (see warning message)");
|
ERROR_MSG("Invalid arguments for INVITE command (see warning message)");
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: omoudni <omoudni@student.42paris.fr> +#+ +:+ +#+ */
|
/* By: omoudni <omoudni@student.42paris.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/05/13 11:11:07 by rparodi #+# #+# */
|
/* 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 {
|
std::list<User *> Server::getUsersList() const {
|
||||||
// to_delete when done
|
// to_delete when done
|
||||||
WARNING_MSG("TO DO FILL")
|
WARNING_MSG("TO DO FILL")
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: omoudni <omoudni@student.42paris.fr> +#+ +:+ +#+ */
|
/* By: omoudni <omoudni@student.42paris.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/05/21 20:37:12 by omoudni #+# #+# */
|
/* 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
|
// Constructor
|
||||||
User::User(short unsigned int fd) : _fd(fd), _registered(false), _hasNick(false), _hasUser(false) {}
|
User::User(short unsigned int fd) : _fd(fd), _registered(false), _hasNick(false), _hasUser(false) {}
|
||||||
|
|
||||||
// Getter for fd
|
/**
|
||||||
short unsigned int User::getFd() const
|
* @brief Getter for the fd
|
||||||
{
|
*
|
||||||
return _fd;
|
* @return the fd of the user
|
||||||
}
|
*/
|
||||||
|
short unsigned int User::getFd() const { return this->_fd; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Getter for the nickname of the user
|
* @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
|
// Registration state
|
||||||
bool User::isRegistered() const
|
bool User::isRegistered() const
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue