mirror of
https://github.com/Ladebeze66/ft_irc.git
synced 2025-12-16 05:58:09 +01:00
fef
This commit is contained in:
parent
0fa9a1b3ea
commit
79a4688520
@ -6,7 +6,7 @@
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/21 18:09:05 by fgras-ca #+# #+# */
|
||||
/* Updated: 2024/05/21 19:46:40 by fgras-ca ### ########.fr */
|
||||
/* Updated: 2024/05/28 14:16:57 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/15 12:41:35 by fgras-ca #+# #+# */
|
||||
/* Updated: 2024/05/28 11:13:12 by fgras-ca ### ########.fr */
|
||||
/* Updated: 2024/05/28 14:16:55 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/15 12:15:42 by fgras-ca #+# #+# */
|
||||
/* Updated: 2024/05/28 14:09:24 by fgras-ca ### ########.fr */
|
||||
/* Updated: 2024/05/28 14:17:16 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/15 18:30:07 by fgras-ca #+# #+# */
|
||||
/* Updated: 2024/05/21 18:01:47 by fgras-ca ### ########.fr */
|
||||
/* Updated: 2024/05/28 14:17:28 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/15 18:14:12 by fgras-ca #+# #+# */
|
||||
/* Updated: 2024/05/21 20:15:58 by fgras-ca ### ########.fr */
|
||||
/* Updated: 2024/05/28 14:17:40 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/21 19:51:08 by fgras-ca #+# #+# */
|
||||
/* Updated: 2024/05/28 11:09:22 by fgras-ca ### ########.fr */
|
||||
/* Updated: 2024/05/28 14:17:52 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/19 15:12:47 by fgras-ca #+# #+# */
|
||||
/* Updated: 2024/05/28 13:56:19 by fgras-ca ### ########.fr */
|
||||
/* Updated: 2024/05/28 15:26:33 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -71,6 +71,12 @@ inline std::string RPL_ISUPPORT(Client* client, const std::string& tokens) {
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
inline std::string RPL_UMODEIS(int clientFd, const std::string& modes) {
|
||||
std::ostringstream oss;
|
||||
oss << ":" << SERVER_NAME << " 221 " << clientFd << " :" << modes << "\r\n";
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
inline std::string RPL_AWAY(int clientFd, const std::string& target, const std::string& message) {
|
||||
std::ostringstream oss;
|
||||
oss << ":" << SERVER_NAME << " 301 " << clientFd << " " << target << " :" << message << "\r\n";
|
||||
@ -131,6 +137,19 @@ inline std::string RPL_CHANNELMODEIS(int clientFd, const std::string& channel, c
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
inline std::string RPL_CREATIONTIME(int clientFd, const std::string& channel, time_t creationTime) {
|
||||
std::ostringstream oss;
|
||||
oss << ":" << SERVER_NAME << " 329 " << clientFd << " " << channel << " " << creationTime << "\r\n";
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
inline std::string RPL_NOTOPIC(Client* client, const std::string& channel) {
|
||||
std::ostringstream oss;
|
||||
oss << ":" << SERVER_NAME << " 331 " << CLIENT_NICK(client) << " " << channel
|
||||
<< " :No topic is set\r\n";
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
inline std::string RPL_TOPIC(Client* client, const std::string& channel, const std::string& topic) {
|
||||
std::ostringstream oss;
|
||||
oss << ":" << SERVER_NAME << " 332 " << CLIENT_NICK(client) << " " << channel << " :" << topic << "\r\n";
|
||||
@ -143,6 +162,37 @@ inline std::string RPL_TOPICWHOTIME(Client* client, const std::string& channel,
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
inline std::string RPL_INVITELIST(int clientFd, const std::string& channel, const std::string& inviteMask) {
|
||||
std::ostringstream oss;
|
||||
oss << ":" << SERVER_NAME << " 336 " << clientFd << " " << channel << " " << inviteMask << "\r\n";
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
inline std::string RPL_ENDOFINVITELIST(int clientFd, const std::string& channel) {
|
||||
std::ostringstream oss;
|
||||
oss << ":" << SERVER_NAME << " 337 " << clientFd << " " << channel << " :End of channel invite list\r\n";
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
// Ajoutez cette fonction pour RPL_INVITING
|
||||
inline std::string RPL_INVITING(Client* client, const std::string& channel, const std::string& nick) {
|
||||
std::ostringstream oss;
|
||||
oss << ":" << SERVER_NAME << " 341 " << CLIENT_NICK(client) << " " << nick << " " << channel << "\r\n";
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
inline std::string RPL_EXCEPTLIST(int clientFd, const std::string& channel, const std::string& exceptionMask) {
|
||||
std::ostringstream oss;
|
||||
oss << ":" << SERVER_NAME << " 348 " << clientFd << " " << channel << " " << exceptionMask << "\r\n";
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
inline std::string RPL_ENDOFEXCEPTLIST(int clientFd, const std::string& channel) {
|
||||
std::ostringstream oss;
|
||||
oss << ":" << SERVER_NAME << " 349 " << clientFd << " " << channel << " :End of channel exception list\r\n";
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
inline std::string RPL_NAMREPLY(Client* client, const std::string& channel, const std::string& users) {
|
||||
std::ostringstream oss;
|
||||
oss << ":" << SERVER_NAME << " 353 " << CLIENT_NICK(client) << " = " << channel << " :" << users << "\r\n";
|
||||
@ -164,6 +214,18 @@ inline std::string RPL_ENDOFNAMES(Client* client, const std::string& channel) {
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
inline std::string RPL_BANLIST(int clientFd, const std::string& channel, const std::string& banMask) {
|
||||
std::ostringstream oss;
|
||||
oss << ":" << SERVER_NAME << " 367 " << clientFd << " " << channel << " " << banMask << "\r\n";
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
inline std::string RPL_ENDOFBANLIST(int clientFd, const std::string& channel) {
|
||||
std::ostringstream oss;
|
||||
oss << ":" << SERVER_NAME << " 368 " << clientFd << " " << channel << " :End of channel ban list\r\n";
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
inline std::string RPL_MOTD(Client* client, const std::string& line) {
|
||||
std::ostringstream oss;
|
||||
oss << ":" << SERVER_NAME << " 372 " << CLIENT_FD(client)
|
||||
@ -265,12 +327,27 @@ inline std::string ERR_NICKNAMEINUSE(Client* client, const std::string& nickname
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
inline std::string ERR_USERNOTINCHANNEL(int clientFd, const std::string& nick, const std::string& channel) {
|
||||
std::ostringstream oss;
|
||||
oss << ":" << SERVER_NAME << " 441 " << clientFd << " " << nick << " " << channel
|
||||
<< " :They aren't on that channel\r\n";
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
inline std::string ERR_NOTONCHANNEL(int clientFd, const std::string& channel) {
|
||||
std::ostringstream oss;
|
||||
oss << ":" << SERVER_NAME << " 442 " << clientFd << " " << channel << " :You're not on that channel\r\n";
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
// Ajoutez cette fonction pour ERR_USERONCHANNEL
|
||||
inline std::string ERR_USERONCHANNEL(Client* client, const std::string& nick, const std::string& channel) {
|
||||
std::ostringstream oss;
|
||||
oss << ":" << SERVER_NAME << " 443 " << CLIENT_NICK(client) << " " << nick << " " << channel
|
||||
<< " :is already on channel\r\n";
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
inline std::string ERR_NOTREGISTERED(Client* client)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
@ -345,6 +422,18 @@ inline std::string ERR_CHANOPRIVSNEEDED(int clientFd, const std::string& channel
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
inline std::string ERR_UMODEUNKNOWNFLAG(int clientFd) {
|
||||
std::ostringstream oss;
|
||||
oss << ":" << SERVER_NAME << " 501 " << clientFd << " :Unknown MODE flag\r\n";
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
inline std::string ERR_USERSDONTMATCH(int clientFd) {
|
||||
std::ostringstream oss;
|
||||
oss << ":" << SERVER_NAME << " 502 " << clientFd << " :Cannot change mode for other users\r\n";
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
// PONG Reply
|
||||
inline std::string RPL_PONG(const std::string& token)
|
||||
{
|
||||
|
||||
BIN
ft_irc3/ircserv
Executable file
BIN
ft_irc3/ircserv
Executable file
Binary file not shown.
0
ft_irc3/logs/irc_server.log
Normal file
0
ft_irc3/logs/irc_server.log
Normal file
BIN
ft_irc3/obj/AdditionalCommands.o
Normal file
BIN
ft_irc3/obj/AdditionalCommands.o
Normal file
Binary file not shown.
BIN
ft_irc3/obj/Channel.o
Normal file
BIN
ft_irc3/obj/Channel.o
Normal file
Binary file not shown.
BIN
ft_irc3/obj/Client.o
Normal file
BIN
ft_irc3/obj/Client.o
Normal file
Binary file not shown.
BIN
ft_irc3/obj/ClientManager.o
Normal file
BIN
ft_irc3/obj/ClientManager.o
Normal file
Binary file not shown.
BIN
ft_irc3/obj/CommandHandler.o
Normal file
BIN
ft_irc3/obj/CommandHandler.o
Normal file
Binary file not shown.
BIN
ft_irc3/obj/Join.o
Normal file
BIN
ft_irc3/obj/Join.o
Normal file
Binary file not shown.
BIN
ft_irc3/obj/Server.o
Normal file
BIN
ft_irc3/obj/Server.o
Normal file
Binary file not shown.
BIN
ft_irc3/obj/Utils.o
Normal file
BIN
ft_irc3/obj/Utils.o
Normal file
Binary file not shown.
BIN
ft_irc3/obj/Welcome.o
Normal file
BIN
ft_irc3/obj/Welcome.o
Normal file
Binary file not shown.
BIN
ft_irc3/obj/Who.o
Normal file
BIN
ft_irc3/obj/Who.o
Normal file
Binary file not shown.
BIN
ft_irc3/obj/main.o
Normal file
BIN
ft_irc3/obj/main.o
Normal file
Binary file not shown.
@ -6,7 +6,7 @@
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/15 12:17:42 by fgras-ca #+# #+# */
|
||||
/* Updated: 2024/05/28 14:10:21 by fgras-ca ### ########.fr */
|
||||
/* Updated: 2024/05/28 14:32:11 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -15,51 +15,97 @@
|
||||
Client::Client(int fd, const std::string &nickname, const std::string &user, const std::string &host, const std::string &password, const std::string &realname)
|
||||
: _fd(fd), _nickname(nickname), _user(user), _host(host), _password(password), _realname(realname), _authenticated(false), _operator(false), _away(false) {}
|
||||
|
||||
int Client::getFd() const { return _fd; }
|
||||
const std::string &Client::getNickname() const { return _nickname; }
|
||||
void Client::setNickname(const std::string &nickname) { _nickname = nickname; }
|
||||
const std::string &Client::getUser() const { return _user; }
|
||||
void Client::setUser(const std::string &user) { _user = user; }
|
||||
const std::string &Client::getHost() const { return _host; }
|
||||
void Client::setHost(const std::string &host) { _host = host; }
|
||||
const std::string &Client::getPassword() const { return _password; }
|
||||
void Client::setPassword(const std::string &password) { _password = password; }
|
||||
const std::string &Client::getRealName() const { return _realname; }
|
||||
void Client::setRealName(const std::string &realname) { _realname = realname; }
|
||||
bool Client::isAuthenticated() const { return _authenticated; }
|
||||
void Client::authenticate() { _authenticated = true; }
|
||||
bool Client::isOperator() const { return _operator; }
|
||||
void Client::setOperator(bool isOperator) { _operator = isOperator; }
|
||||
|
||||
bool Client::isAway() const { return _away; }
|
||||
const std::string &Client::getAwayMessage() const { return _awayMessage; }
|
||||
void Client::setAwayMessage(const std::string &message) { _awayMessage = message; }
|
||||
void Client::setAway(bool away) { _away = away; }
|
||||
|
||||
/*Client::Client(int fd)
|
||||
|
||||
Description: Constructeur de la classe Client. Initialise le client avec le descripteur de fichier fourni.
|
||||
Paramètres:
|
||||
int fd: Le descripteur de fichier du client.
|
||||
Client::~Client()
|
||||
|
||||
Description: Destructeur de la classe Client. Gère la destruction de l'objet.
|
||||
int Client::getFd() const
|
||||
{
|
||||
return _fd;
|
||||
}
|
||||
|
||||
const std::string &Client::getNickname() const
|
||||
{
|
||||
return _nickname;
|
||||
}
|
||||
|
||||
void Client::setNickname(const std::string &nickname)
|
||||
{
|
||||
_nickname = nickname;
|
||||
}
|
||||
|
||||
const std::string &Client::getUser() const
|
||||
{
|
||||
return _user;
|
||||
}
|
||||
|
||||
void Client::setUser(const std::string &user)
|
||||
{
|
||||
_user = user;
|
||||
}
|
||||
|
||||
const std::string &Client::getHost() const
|
||||
{
|
||||
return _host;
|
||||
}
|
||||
|
||||
void Client::setHost(const std::string &host)
|
||||
{
|
||||
_host = host;
|
||||
}
|
||||
|
||||
const std::string &Client::getPassword() const
|
||||
{
|
||||
return _password;
|
||||
}
|
||||
|
||||
Description: Renvoie le descripteur de fichier du client.
|
||||
Retourne: Le descripteur de fichier du client.
|
||||
void Client::setPassword(const std::string &password)
|
||||
{
|
||||
_password = password;
|
||||
}
|
||||
|
||||
const std::string &Client::getRealName() const
|
||||
{
|
||||
return _realname;
|
||||
}
|
||||
|
||||
void Client::setRealName(const std::string &realname)
|
||||
{
|
||||
_realname = realname;
|
||||
}
|
||||
|
||||
Description: Définit le mot de passe du client et le marque comme authentifié.
|
||||
Paramètres:
|
||||
const std::string &password: Le mot de passe à définir.
|
||||
bool Client::isAuthenticated() const
|
||||
{
|
||||
return _authenticated;
|
||||
}
|
||||
|
||||
Description: Vérifie si le client est authentifié.
|
||||
Retourne: true si le client est authentifié, false sinon.
|
||||
void logMessage(const std::string &message, const std::string &color)
|
||||
void Client::authenticate()
|
||||
{
|
||||
_authenticated = true;
|
||||
}
|
||||
|
||||
Description: Enregistre un message dans les logs et l'affiche avec des couleurs dans la console.
|
||||
Paramètres:
|
||||
const std::string &message: Le message à enregistrer.
|
||||
const std::string &color: La couleur du message.*/
|
||||
bool Client::isOperator() const
|
||||
{
|
||||
return _operator;
|
||||
}
|
||||
|
||||
void Client::setOperator(bool isOperator)
|
||||
{
|
||||
_operator = isOperator;
|
||||
}
|
||||
|
||||
bool Client::isAway() const
|
||||
{
|
||||
return _away;
|
||||
}
|
||||
|
||||
const std::string &Client::getAwayMessage() const
|
||||
{
|
||||
return _awayMessage;
|
||||
}
|
||||
|
||||
void Client::setAwayMessage(const std::string &message)
|
||||
{
|
||||
_awayMessage = message;
|
||||
}
|
||||
|
||||
void Client::setAway(bool away)
|
||||
{
|
||||
_away = away;
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/15 18:32:23 by fgras-ca #+# #+# */
|
||||
/* Updated: 2024/05/21 20:28:41 by fgras-ca ### ########.fr */
|
||||
/* Updated: 2024/05/28 14:32:28 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/21 19:51:31 by fgras-ca #+# #+# */
|
||||
/* Updated: 2024/05/28 13:07:53 by fgras-ca ### ########.fr */
|
||||
/* Updated: 2024/05/28 14:33:01 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/17 16:09:20 by fgras-ca #+# #+# */
|
||||
/* Updated: 2024/05/28 13:08:30 by fgras-ca ### ########.fr */
|
||||
/* Updated: 2024/05/28 14:33:29 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user