|
|
|
|
@@ -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/30 13:27:52 by fgras-ca ### ########.fr */
|
|
|
|
|
/* Updated: 2024/05/30 17:49:15 by fgras-ca ### ########.fr */
|
|
|
|
|
/* */
|
|
|
|
|
/* ************************************************************************** */
|
|
|
|
|
|
|
|
|
|
@@ -16,11 +16,12 @@
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <sstream>
|
|
|
|
|
#include "Client.hpp"
|
|
|
|
|
#include "Utils.hpp"
|
|
|
|
|
|
|
|
|
|
#define SERVER_NAME "IRC_Server"
|
|
|
|
|
#define SERVER_VERSION "1.0"
|
|
|
|
|
#define USER_MODES "+o"
|
|
|
|
|
#define CHANNEL_MODES "i/t/k/o/l"
|
|
|
|
|
#define USER_MODES "+o/-o"
|
|
|
|
|
#define CHANNEL_MODES "none"
|
|
|
|
|
#define CHANNEL_MODES_WITH_PARAMS "None"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -43,21 +44,21 @@ inline std::string RPL_WELCOME(Client* client) {
|
|
|
|
|
|
|
|
|
|
inline std::string RPL_YOURHOST(Client* client) {
|
|
|
|
|
std::ostringstream oss;
|
|
|
|
|
oss << ":" << SERVER_NAME << " 002 " << CLIENT_FD(client)
|
|
|
|
|
oss << ":" << SERVER_NAME << " 002 " << CLIENT_NICK(client)
|
|
|
|
|
<< " :Your host is " << SERVER_NAME << ", running version " << SERVER_VERSION << "\r\n";
|
|
|
|
|
return oss.str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline std::string RPL_CREATED(Client* client) {
|
|
|
|
|
std::ostringstream oss;
|
|
|
|
|
oss << ":" << SERVER_NAME << " 003 " << CLIENT_FD(client)
|
|
|
|
|
oss << ":" << SERVER_NAME << " 003 " << CLIENT_NICK(client)
|
|
|
|
|
<< " :This server was created " << __DATE__ << "\r\n";
|
|
|
|
|
return oss.str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline std::string RPL_MYINFO(Client* client) {
|
|
|
|
|
std::ostringstream oss;
|
|
|
|
|
oss << ":" << SERVER_NAME << " 004 " << CLIENT_FD(client) << " "
|
|
|
|
|
oss << ":" << SERVER_NAME << " 004 " << CLIENT_NICK(client) << " "
|
|
|
|
|
<< SERVER_NAME << " " << SERVER_VERSION << " "
|
|
|
|
|
<< USER_MODES << " " << CHANNEL_MODES << " "
|
|
|
|
|
<< CHANNEL_MODES_WITH_PARAMS << "\r\n";
|
|
|
|
|
@@ -66,111 +67,110 @@ inline std::string RPL_MYINFO(Client* client) {
|
|
|
|
|
|
|
|
|
|
inline std::string RPL_ISUPPORT(Client* client, const std::string& tokens) {
|
|
|
|
|
std::ostringstream oss;
|
|
|
|
|
oss << ":" << SERVER_NAME << " 005 " << CLIENT_FD(client)
|
|
|
|
|
oss << ":" << SERVER_NAME << " 005 " << CLIENT_NICK(client)
|
|
|
|
|
<< " " << tokens << " :are supported by this server\r\n";
|
|
|
|
|
return oss.str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline std::string RPL_UMODEIS(int clientFd, const std::string& modes) {
|
|
|
|
|
inline std::string RPL_UMODEIS(Client* client, const std::string& modes) {
|
|
|
|
|
std::ostringstream oss;
|
|
|
|
|
oss << ":" << SERVER_NAME << " 221 " << clientFd << " :" << modes << "\r\n";
|
|
|
|
|
oss << ":" << SERVER_NAME << " 221 " << CLIENT_NICK(client) << " :" << modes << "\r\n";
|
|
|
|
|
return oss.str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline std::string RPL_AWAY(int clientFd, const std::string& target, const std::string& message) {
|
|
|
|
|
inline std::string RPL_AWAY(Client *client, const std::string& target, const std::string& message) {
|
|
|
|
|
std::ostringstream oss;
|
|
|
|
|
oss << ":" << SERVER_NAME << " 301 " << clientFd << " " << target << " :" << message << "\r\n";
|
|
|
|
|
oss << ":" << SERVER_NAME << " 301 " << CLIENT_NICK(client) << " " << target << " :" << message << "\r\n";
|
|
|
|
|
return oss.str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// WHOIS Command RPLs
|
|
|
|
|
inline std::string RPL_WHOISUSER(int clientFd, Client* target)
|
|
|
|
|
inline std::string RPL_WHOISUSER(Client *client, Client* target)
|
|
|
|
|
{
|
|
|
|
|
std::ostringstream oss;
|
|
|
|
|
oss << ":" << SERVER_NAME << " 311 " << clientFd << " " << CLIENT_NICK(target) << " "
|
|
|
|
|
oss << ":" << SERVER_NAME << " 311 " << CLIENT_NICK(client) << " " << CLIENT_NICK(target) << " "
|
|
|
|
|
<< CLIENT_USER(target) << " " << CLIENT_HOST(target) << " * :" << CLIENT_REALNAME(target) << "\r\n";
|
|
|
|
|
return oss.str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline std::string RPL_WHOISSERVER(int clientFd, const std::string& targetNick, const std::string& serverInfo)
|
|
|
|
|
inline std::string RPL_WHOISSERVER(Client *client, const std::string& targetNick, const std::string& serverInfo)
|
|
|
|
|
{
|
|
|
|
|
std::ostringstream oss;
|
|
|
|
|
oss << ":" << SERVER_NAME << " 312 " << clientFd << " " << targetNick << " " << SERVER_NAME
|
|
|
|
|
oss << ":" << SERVER_NAME << " 312 " << CLIENT_NICK(client) << " " << targetNick << " " << SERVER_NAME
|
|
|
|
|
<< " :" << serverInfo << "\r\n";
|
|
|
|
|
return oss.str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline std::string RPL_ENDOFWHO(int clientFd, const std::string& channel)
|
|
|
|
|
inline std::string RPL_ENDOFWHO(Client *client, const std::string& channel)
|
|
|
|
|
{
|
|
|
|
|
std::ostringstream oss;
|
|
|
|
|
oss << ":" << SERVER_NAME << " 315 " << clientFd << " " << channel << " :End of /WHO list.\r\n";
|
|
|
|
|
oss << ":" << SERVER_NAME << " 315 " << CLIENT_NICK(client) << " " << channel << " :End of /WHO list.\r\n";
|
|
|
|
|
return oss.str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline std::string RPL_ENDOFWHOIS(int clientFd, const std::string& targetNick)
|
|
|
|
|
inline std::string RPL_ENDOFWHOIS(Client *client, const std::string& targetNick)
|
|
|
|
|
{
|
|
|
|
|
std::ostringstream oss;
|
|
|
|
|
oss << ":" << SERVER_NAME << " 318 " << clientFd << " " << targetNick << " :End of /WHOIS list.\r\n";
|
|
|
|
|
oss << ":" << SERVER_NAME << " 318 " << CLIENT_NICK(client) << " " << targetNick << " :End of /WHOIS list.\r\n";
|
|
|
|
|
return oss.str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// RPL Channel List Messages
|
|
|
|
|
inline std::string RPL_LIST(int clientFd, const std::string& channel, int numVisible, const std::string& topic)
|
|
|
|
|
inline std::string RPL_LIST(Client *client, const std::string& channel, int numVisible, const std::string& topic)
|
|
|
|
|
{
|
|
|
|
|
std::ostringstream oss;
|
|
|
|
|
oss << ":" << SERVER_NAME << " 322 " << clientFd << " " << channel << " " << numVisible << " :" << topic << "\r\n";
|
|
|
|
|
oss << ":" << SERVER_NAME << " 322 " << CLIENT_NICK(client) << " " << channel << " " << numVisible << " :" << topic << "\r\n";
|
|
|
|
|
return oss.str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline std::string RPL_LISTEND(int clientFd)
|
|
|
|
|
inline std::string RPL_LISTEND(Client *client)
|
|
|
|
|
{
|
|
|
|
|
std::ostringstream oss;
|
|
|
|
|
oss << ":" << SERVER_NAME << " 323 " << clientFd << " :End of /LIST\r\n";
|
|
|
|
|
oss << ":" << SERVER_NAME << " 323 " << CLIENT_NICK(client) << " :End of /LIST\r\n";
|
|
|
|
|
return oss.str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// RPL Mode Messages
|
|
|
|
|
inline std::string RPL_CHANNELMODEIS(int clientFd, const std::string& channel, const std::string& mode)
|
|
|
|
|
inline std::string RPL_CHANNELMODEIS(Client *client, const std::string& channel, const std::string& mode)
|
|
|
|
|
{
|
|
|
|
|
std::ostringstream oss;
|
|
|
|
|
oss << ":" << SERVER_NAME << " 324 " << clientFd << " " << channel << " " << mode << "\r\n";
|
|
|
|
|
oss << ":" << SERVER_NAME << " 324 " << CLIENT_NICK(client) << " " << channel << " " << mode << "\r\n";
|
|
|
|
|
return oss.str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline std::string RPL_CREATIONTIME(int clientFd, const std::string& channel, time_t creationTime) {
|
|
|
|
|
inline std::string RPL_CREATIONTIME(Client *client, const std::string& channel, time_t creationTime) {
|
|
|
|
|
std::ostringstream oss;
|
|
|
|
|
oss << ":" << SERVER_NAME << " 329 " << clientFd << " " << channel << " " << creationTime << "\r\n";
|
|
|
|
|
oss << ":" << SERVER_NAME << " 329 " << CLIENT_NICK(client) << " " << 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";
|
|
|
|
|
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";
|
|
|
|
|
return oss.str();
|
|
|
|
|
std::ostringstream oss;
|
|
|
|
|
oss << ":" << SERVER_NAME << " 332 " << CLIENT_NICK(client) << " " << channel << " :" << topic << "\r\n";
|
|
|
|
|
return oss.str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline std::string RPL_TOPICWHOTIME(Client* client, const std::string& channel, const std::string& setter, time_t setTime) {
|
|
|
|
|
std::ostringstream oss;
|
|
|
|
|
oss << ":" << SERVER_NAME << " 333 " << CLIENT_NICK(client) << " " << channel << " " << setter << " " << setTime << "\r\n";
|
|
|
|
|
return oss.str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline std::string RPL_INVITELIST(Client *client, const std::string& channel, const std::string& inviteMask) {
|
|
|
|
|
std::ostringstream oss;
|
|
|
|
|
oss << ":" << SERVER_NAME << " 333 " << CLIENT_NICK(client) << " " << channel << " " << setter << " " << setTime << "\r\n";
|
|
|
|
|
oss << ":" << SERVER_NAME << " 336 " << CLIENT_NICK(client) << " " << channel << " " << inviteMask << "\r\n";
|
|
|
|
|
return oss.str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline std::string RPL_INVITELIST(int clientFd, const std::string& channel, const std::string& inviteMask) {
|
|
|
|
|
inline std::string RPL_ENDOFINVITELIST(Client *client, const std::string& channel) {
|
|
|
|
|
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";
|
|
|
|
|
oss << ":" << SERVER_NAME << " 337 " << CLIENT_NICK(client) << " " << channel << " :End of channel invite list\r\n";
|
|
|
|
|
return oss.str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -181,15 +181,15 @@ inline std::string RPL_INVITING(Client* client, const std::string& channel, cons
|
|
|
|
|
return oss.str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline std::string RPL_EXCEPTLIST(int clientFd, const std::string& channel, const std::string& exceptionMask) {
|
|
|
|
|
inline std::string RPL_EXCEPTLIST(Client *client, const std::string& channel, const std::string& exceptionMask) {
|
|
|
|
|
std::ostringstream oss;
|
|
|
|
|
oss << ":" << SERVER_NAME << " 348 " << clientFd << " " << channel << " " << exceptionMask << "\r\n";
|
|
|
|
|
oss << ":" << SERVER_NAME << " 348 " << CLIENT_NICK(client) << " " << channel << " " << exceptionMask << "\r\n";
|
|
|
|
|
return oss.str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline std::string RPL_ENDOFEXCEPTLIST(int clientFd, const std::string& channel) {
|
|
|
|
|
inline std::string RPL_ENDOFEXCEPTLIST(Client *client, const std::string& channel) {
|
|
|
|
|
std::ostringstream oss;
|
|
|
|
|
oss << ":" << SERVER_NAME << " 349 " << clientFd << " " << channel << " :End of channel exception list\r\n";
|
|
|
|
|
oss << ":" << SERVER_NAME << " 349 " << CLIENT_NICK(client) << " " << channel << " :End of channel exception list\r\n";
|
|
|
|
|
return oss.str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -214,56 +214,56 @@ 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) {
|
|
|
|
|
inline std::string RPL_BANLIST(Client *client, const std::string& channel, const std::string& banMask) {
|
|
|
|
|
std::ostringstream oss;
|
|
|
|
|
oss << ":" << SERVER_NAME << " 367 " << clientFd << " " << channel << " " << banMask << "\r\n";
|
|
|
|
|
oss << ":" << SERVER_NAME << " 367 " << CLIENT_NICK(client) << " " << channel << " " << banMask << "\r\n";
|
|
|
|
|
return oss.str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline std::string RPL_ENDOFBANLIST(int clientFd, const std::string& channel) {
|
|
|
|
|
inline std::string RPL_ENDOFBANLIST(Client *client, const std::string& channel) {
|
|
|
|
|
std::ostringstream oss;
|
|
|
|
|
oss << ":" << SERVER_NAME << " 368 " << clientFd << " " << channel << " :End of channel ban list\r\n";
|
|
|
|
|
oss << ":" << SERVER_NAME << " 368 " << CLIENT_NICK(client) << " " << 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)
|
|
|
|
|
oss << ":" << SERVER_NAME << " 372 " << CLIENT_NICK(client)
|
|
|
|
|
<< " :- " << line << "\r\n";
|
|
|
|
|
return oss.str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline std::string RPL_MOTDSTART(Client* client) {
|
|
|
|
|
std::ostringstream oss;
|
|
|
|
|
oss << ":" << SERVER_NAME << " 375 " << CLIENT_FD(client)
|
|
|
|
|
oss << ":" << SERVER_NAME << " 375 " << CLIENT_NICK(client)
|
|
|
|
|
<< " :- " << SERVER_NAME << " Message of the day - \r\n";
|
|
|
|
|
return oss.str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline std::string RPL_ENDOFMOTD(Client* client) {
|
|
|
|
|
std::ostringstream oss;
|
|
|
|
|
oss << ":" << SERVER_NAME << " 376 " << CLIENT_FD(client)
|
|
|
|
|
oss << ":" << SERVER_NAME << " 376 " << CLIENT_NICK(client)
|
|
|
|
|
<< " :End of /MOTD command.\r\n";
|
|
|
|
|
return oss.str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline std::string ERR_NOSUCHNICK(int clientFd, const std::string& nick)
|
|
|
|
|
inline std::string ERR_NOSUCHNICK(Client *client, const std::string& nick)
|
|
|
|
|
{
|
|
|
|
|
std::ostringstream oss;
|
|
|
|
|
oss << ":" << SERVER_NAME << " 401 " << clientFd << " " << nick << " :No such nick/channel\r\n";
|
|
|
|
|
oss << ":" << SERVER_NAME << " 401 " << CLIENT_NICK(client) << " " << nick << " :No such nick/channel\r\n";
|
|
|
|
|
return oss.str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline std::string ERR_NOSUCHCHANNEL(int clientFd, const std::string& channel)
|
|
|
|
|
inline std::string ERR_NOSUCHCHANNEL(Client *client, const std::string& channel)
|
|
|
|
|
{
|
|
|
|
|
std::ostringstream oss;
|
|
|
|
|
oss << ":" << SERVER_NAME << " 403 " << clientFd << " " << channel << " :No such channel\r\n";
|
|
|
|
|
oss << ":" << SERVER_NAME << " 403 " << CLIENT_NICK(client) << " " << channel << " :No such channel\r\n";
|
|
|
|
|
return oss.str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline std::string ERR_CANNOTSENDTOCHAN(int clientFd, const std::string& channel) {
|
|
|
|
|
inline std::string ERR_CANNOTSENDTOCHAN(Client *client, const std::string& channel) {
|
|
|
|
|
std::ostringstream oss;
|
|
|
|
|
oss << ":" << SERVER_NAME << " 404 " << clientFd << " " << channel << " :Cannot send to channel\r\n";
|
|
|
|
|
oss << ":" << SERVER_NAME << " 404 " << CLIENT_NICK(client) << " " << channel << " :Cannot send to channel\r\n";
|
|
|
|
|
return oss.str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -277,19 +277,19 @@ inline std::string ERR_TOOMANYCHANNELS(Client* client, const std::string& channe
|
|
|
|
|
inline std::string ERR_NOORIGIN(Client* client)
|
|
|
|
|
{
|
|
|
|
|
std::ostringstream oss;
|
|
|
|
|
oss << ":" << SERVER_NAME << " 409 " << CLIENT_FD(client) << " :No origin specified\r\n";
|
|
|
|
|
oss << ":" << SERVER_NAME << " 409 " << CLIENT_NICK(client) << " :No origin specified\r\n";
|
|
|
|
|
return oss.str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline std::string ERR_NORECIPIENT(int clientFd, const std::string& command) {
|
|
|
|
|
inline std::string ERR_NORECIPIENT(Client *client, const std::string& command) {
|
|
|
|
|
std::ostringstream oss;
|
|
|
|
|
oss << ":" << SERVER_NAME << " 411 " << clientFd << " :No recipient given (" << command << ")\r\n";
|
|
|
|
|
oss << ":" << SERVER_NAME << " 411 " << CLIENT_NICK(client) << " :No recipient given (" << command << ")\r\n";
|
|
|
|
|
return oss.str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline std::string ERR_NOTEXTTOSEND(int clientFd) {
|
|
|
|
|
inline std::string ERR_NOTEXTTOSEND(Client *client) {
|
|
|
|
|
std::ostringstream oss;
|
|
|
|
|
oss << ":" << SERVER_NAME << " 412 " << clientFd << " :No text to send\r\n";
|
|
|
|
|
oss << ":" << SERVER_NAME << " 412 " << CLIENT_NICK(client) << " :No text to send\r\n";
|
|
|
|
|
return oss.str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -301,7 +301,7 @@ inline std::string ERR_UNKNOWNCOMMAND(Client* client, const std::string& command
|
|
|
|
|
|
|
|
|
|
inline std::string ERR_NOMOTD(Client* client) {
|
|
|
|
|
std::ostringstream oss;
|
|
|
|
|
oss << ":" << SERVER_NAME << " 422 " << CLIENT_FD(client)
|
|
|
|
|
oss << ":" << SERVER_NAME << " 422 " << CLIENT_NICK(client)
|
|
|
|
|
<< " :MOTD File is missing\r\n";
|
|
|
|
|
return oss.str();
|
|
|
|
|
}
|
|
|
|
|
@@ -309,34 +309,34 @@ inline std::string ERR_NOMOTD(Client* client) {
|
|
|
|
|
inline std::string ERR_NONICKNAMEGIVEN(Client* client)
|
|
|
|
|
{
|
|
|
|
|
std::ostringstream oss;
|
|
|
|
|
oss << ":" << SERVER_NAME << " 431 " << CLIENT_FD(client) << " :No nickname given\r\n";
|
|
|
|
|
oss << ":" << SERVER_NAME << " 431 " << CLIENT_NICK(client) << " :No nickname given\r\n";
|
|
|
|
|
return oss.str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline std::string ERR_ERRONEUSNICKNAME(Client* client, const std::string& nickname)
|
|
|
|
|
{
|
|
|
|
|
std::ostringstream oss;
|
|
|
|
|
oss << ":" << SERVER_NAME << " 432 " << CLIENT_FD(client) << " " << nickname << " :Erroneous nickname\r\n";
|
|
|
|
|
oss << ":" << SERVER_NAME << " 432 " << CLIENT_NICK(client) << " " << nickname << " :Erroneous nickname\r\n";
|
|
|
|
|
return oss.str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline std::string ERR_NICKNAMEINUSE(Client* client, const std::string& nickname)
|
|
|
|
|
{
|
|
|
|
|
std::ostringstream oss;
|
|
|
|
|
oss << ":" << SERVER_NAME << " 433 " << CLIENT_FD(client) << " " << nickname << " :Nickname is already in use\r\n";
|
|
|
|
|
oss << ":" << SERVER_NAME << " 433 " << CLIENT_NICK(client) << " " << nickname << " :Nickname is already in use\r\n";
|
|
|
|
|
return oss.str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline std::string ERR_USERNOTINCHANNEL(int clientFd, const std::string& nick, const std::string& channel) {
|
|
|
|
|
inline std::string ERR_USERNOTINCHANNEL(Client *client, const std::string& nick, const std::string& channel) {
|
|
|
|
|
std::ostringstream oss;
|
|
|
|
|
oss << ":" << SERVER_NAME << " 441 " << clientFd << " " << nick << " " << channel
|
|
|
|
|
oss << ":" << SERVER_NAME << " 441 " << CLIENT_NICK(client) << " " << nick << " " << channel
|
|
|
|
|
<< " :They aren't on that channel\r\n";
|
|
|
|
|
return oss.str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline std::string ERR_NOTONCHANNEL(int clientFd, const std::string& channel) {
|
|
|
|
|
inline std::string ERR_NOTONCHANNEL(Client *client, const std::string& channel) {
|
|
|
|
|
std::ostringstream oss;
|
|
|
|
|
oss << ":" << SERVER_NAME << " 442 " << clientFd << " " << channel << " :You're not on that channel\r\n";
|
|
|
|
|
oss << ":" << SERVER_NAME << " 442 " << CLIENT_NICK(client) << " " << channel << " :You're not on that channel\r\n";
|
|
|
|
|
return oss.str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -351,7 +351,7 @@ inline std::string ERR_USERONCHANNEL(Client* client, const std::string& nick, co
|
|
|
|
|
inline std::string ERR_NOTREGISTERED(Client* client)
|
|
|
|
|
{
|
|
|
|
|
std::ostringstream oss;
|
|
|
|
|
oss << ":" << SERVER_NAME << " 451 " << CLIENT_FD(client) << " :You have not registered\r\n";
|
|
|
|
|
oss << ":" << SERVER_NAME << " 451 " << CLIENT_NICK(client) << " :You have not registered\r\n";
|
|
|
|
|
return oss.str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -360,21 +360,21 @@ inline std::string ERR_NOTREGISTERED(Client* client)
|
|
|
|
|
inline std::string ERR_NEEDMOREPARAMS(Client* client, const std::string& command)
|
|
|
|
|
{
|
|
|
|
|
std::ostringstream oss;
|
|
|
|
|
oss << ":" << SERVER_NAME << " 461 " << CLIENT_FD(client) << " " << command << " :Not enough parameters\r\n";
|
|
|
|
|
oss << ":" << SERVER_NAME << " 461 " << CLIENT_NICK(client) << " " << command << " :Not enough parameters\r\n";
|
|
|
|
|
return oss.str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline std::string ERR_ALREADYREGISTERED(Client* client)
|
|
|
|
|
{
|
|
|
|
|
std::ostringstream oss;
|
|
|
|
|
oss << ":" << SERVER_NAME << " 462 " << CLIENT_FD(client) << " :You may not reregister\r\n";
|
|
|
|
|
oss << ":" << SERVER_NAME << " 462 " << CLIENT_NICK(client) << " :You may not reregister\r\n";
|
|
|
|
|
return oss.str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline std::string ERR_PASSWDMISMATCH(Client* client)
|
|
|
|
|
{
|
|
|
|
|
std::ostringstream oss;
|
|
|
|
|
oss << ":" << SERVER_NAME << " 464 " << CLIENT_FD(client) << " :Password incorrect\r\n";
|
|
|
|
|
oss << ":" << SERVER_NAME << " 464 " << CLIENT_NICK(client) << " :Password incorrect\r\n";
|
|
|
|
|
return oss.str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -414,29 +414,29 @@ inline std::string ERR_BADCHANMASK(Client* client, const std::string& channel) {
|
|
|
|
|
return oss.str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline std::string RPL_NOCHANMODES(int clientFd, const std::string& channel)
|
|
|
|
|
inline std::string RPL_NOCHANMODES(Client *client, const std::string& channel)
|
|
|
|
|
{
|
|
|
|
|
std::ostringstream oss;
|
|
|
|
|
oss << ":" << SERVER_NAME << " 477 " << clientFd << " " << channel << " :Channel doesn't support modes\r\n";
|
|
|
|
|
oss << ":" << SERVER_NAME << " 477 " << CLIENT_NICK(client) << " " << channel << " :Channel doesn't support modes\r\n";
|
|
|
|
|
return oss.str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline std::string ERR_CHANOPRIVSNEEDED(int clientFd, const std::string& channel)
|
|
|
|
|
inline std::string ERR_CHANOPRIVSNEEDED(Client *client, const std::string& channel)
|
|
|
|
|
{
|
|
|
|
|
std::ostringstream oss;
|
|
|
|
|
oss << ":" << SERVER_NAME << " 482 " << clientFd << " " << channel << " :You're not channel operator\r\n";
|
|
|
|
|
oss << ":" << SERVER_NAME << " 482 " << CLIENT_NICK(client) << " " << channel << " :You're not channel operator\r\n";
|
|
|
|
|
return oss.str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline std::string ERR_UMODEUNKNOWNFLAG(int clientFd) {
|
|
|
|
|
inline std::string ERR_UMODEUNKNOWNFLAG(Client *client) {
|
|
|
|
|
std::ostringstream oss;
|
|
|
|
|
oss << ":" << SERVER_NAME << " 501 " << clientFd << " :Unknown MODE flag\r\n";
|
|
|
|
|
oss << ":" << SERVER_NAME << " 501 " << CLIENT_NICK(client) << " :Unknown MODE flag\r\n";
|
|
|
|
|
return oss.str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline std::string ERR_USERSDONTMATCH(int clientFd) {
|
|
|
|
|
inline std::string ERR_USERSDONTMATCH(Client *client) {
|
|
|
|
|
std::ostringstream oss;
|
|
|
|
|
oss << ":" << SERVER_NAME << " 502 " << clientFd << " :Cannot change mode for other users\r\n";
|
|
|
|
|
oss << ":" << SERVER_NAME << " 502 " << CLIENT_NICK(client) << " :Cannot change mode for other users\r\n";
|
|
|
|
|
return oss.str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -449,26 +449,26 @@ inline std::string RPL_PONG(const std::string& token)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// CAP Command RPLs
|
|
|
|
|
inline std::string RPL_CAP(int clientFd, const std::string& subcommand, const std::string& capabilities)
|
|
|
|
|
inline std::string RPL_CAP(Client *client, const std::string& subcommand, const std::string& capabilities)
|
|
|
|
|
{
|
|
|
|
|
std::ostringstream oss;
|
|
|
|
|
oss << ":" << SERVER_NAME << " CAP " << clientFd << " " << subcommand << " :" << capabilities << "\r\n";
|
|
|
|
|
oss << ":" << SERVER_NAME << " CAP " << CLIENT_NICK(client) << " " << subcommand << " :" << capabilities << "\r\n";
|
|
|
|
|
return oss.str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline std::string RPL_PASSACCEPTED(Client* client)
|
|
|
|
|
{
|
|
|
|
|
std::ostringstream oss;
|
|
|
|
|
oss << ":" << SERVER_NAME << " NOTICE " << CLIENT_FD(client)
|
|
|
|
|
oss << ":" << SERVER_NAME << " NOTICE " << CLIENT_NICK(client)
|
|
|
|
|
<< " :Password accepted!\r\n";
|
|
|
|
|
return oss.str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Add this function to handle the CAP END response
|
|
|
|
|
inline std::string RPL_CAPEND(int clientFd)
|
|
|
|
|
inline std::string RPL_CAPEND(Client *client)
|
|
|
|
|
{
|
|
|
|
|
std::ostringstream oss;
|
|
|
|
|
oss << ":" << SERVER_NAME << " CAP " << clientFd << " END\r\n";
|
|
|
|
|
oss << ":" << SERVER_NAME << " CAP " << CLIENT_NICK(client) << " END\r\n";
|
|
|
|
|
return oss.str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|