ADD commands NICK, USER, PASS, CAP
This commit is contained in:
parent
8a77409158
commit
57aa57d9eb
14 changed files with 224 additions and 50 deletions
|
|
@ -3,10 +3,10 @@
|
|||
/* ::: :::::::: */
|
||||
/* commands.hpp :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* By: sben-tay <sben-tay@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/05/20 23:31:58 by rparodi #+# #+# */
|
||||
/* Updated: 2025/06/05 22:55:54 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/06/08 22:19:40 by sben-tay ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -60,7 +60,9 @@ namespace cmd
|
|||
class Quit;
|
||||
class Topic;
|
||||
class Unknown;
|
||||
class cmdUser;
|
||||
class userCmd;
|
||||
class Pass;
|
||||
class Cap;
|
||||
};
|
||||
|
||||
#include "./commands/commands.tpp"
|
||||
|
|
|
|||
21
include/commands/cap.hpp
Normal file
21
include/commands/cap.hpp
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* cap.hpp :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: sben-tay <sben-tay@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/06/08 22:08:44 by sben-tay #+# #+# */
|
||||
/* Updated: 2025/06/08 22:16:14 by sben-tay ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "commands.hpp"
|
||||
|
||||
class cmd::Cap : public ACommand {
|
||||
public:
|
||||
Cap(User *user, Channel *channel, Server *server, const std::string &line) : ACommand(user, channel, server, line) {}
|
||||
virtual void execute();
|
||||
};
|
||||
|
|
@ -3,10 +3,10 @@
|
|||
/* ::: :::::::: */
|
||||
/* nick.hpp :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* By: sben-tay <sben-tay@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/05/24 17:17:31 by rparodi #+# #+# */
|
||||
/* Updated: 2025/06/02 00:40:18 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/06/08 22:13:30 by sben-tay ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -18,5 +18,5 @@ class cmd::Nick : public ACommand {
|
|||
public:
|
||||
Nick(User *user, Channel *channel, Server *server, const std::string &line) : ACommand(user, channel, server, line) {}
|
||||
virtual void execute(void);
|
||||
virtual e_code checkArgs();
|
||||
virtual e_code checkArgs(void);
|
||||
};
|
||||
|
|
|
|||
22
include/commands/userCmd.hpp
Normal file
22
include/commands/userCmd.hpp
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* userCmd.hpp :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: sben-tay <sben-tay@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/06/08 19:19:47 by sben-tay #+# #+# */
|
||||
/* Updated: 2025/06/08 22:02:24 by sben-tay ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "commands.hpp"
|
||||
|
||||
class cmd::userCmd : public ACommand {
|
||||
public:
|
||||
userCmd(User *user, Channel *channel, Server *server, const std::string &line) : ACommand(user, channel, server, line) {}
|
||||
virtual void execute();
|
||||
virtual e_code checkArgs();
|
||||
};
|
||||
|
|
@ -1,14 +1,14 @@
|
|||
/******************************************************************************/
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* user.hpp :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: omoudni <omoudni@student.42paris.fr> +#+ +:+ +#+ */
|
||||
/* By: sben-tay <sben-tay@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/05/20 21:57:49 by rparodi #+# #+# */
|
||||
/* Updated: 2025/05/29 12:37:11 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/06/08 21:59:53 by sben-tay ### ########.fr */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
/* ************************************************************************** */
|
||||
|
||||
#pragma once
|
||||
|
||||
|
|
@ -26,6 +26,7 @@ class User
|
|||
std::string _username;
|
||||
bool _hasNick;
|
||||
bool _hasUser;
|
||||
bool _hasPass; // to check if the user has sent a PASS command
|
||||
|
||||
public:
|
||||
User(short unsigned fd);
|
||||
|
|
@ -40,4 +41,17 @@ class User
|
|||
void setNickname(const std::string &nickname);
|
||||
void setUsername(const std::string &username);
|
||||
void checkRegistration();
|
||||
|
||||
// setters and getters
|
||||
void setHasNick(bool value);
|
||||
void setHasUser(bool value);
|
||||
void setHasPass(bool value);
|
||||
bool getHasPass() const;
|
||||
std::string getNickname() const;
|
||||
|
||||
bool hasDataToSend() const;
|
||||
std::string getWriteBuffer() const;
|
||||
void clearWriteBuffer();
|
||||
|
||||
std::string getPrefix() const;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue