prout
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
/* By: vvaas <vvaas@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/01/21 10:33:17 by maldavid #+# #+# */
|
||||
/* Updated: 2024/01/29 21:16:38 by vvaas ### ########.fr */
|
||||
/* Updated: 2024/01/29 22:57:10 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
#include <irc.hpp>
|
||||
#include <string>
|
||||
#include <set>
|
||||
|
||||
namespace irc
|
||||
{
|
||||
@@ -57,9 +58,13 @@ namespace irc
|
||||
void sendModular(std::string message, ...);
|
||||
void sendCodeInChannel(const std::string& code, const class Channel &chan, const std::string& msg);
|
||||
|
||||
inline void inviteToChannel(const std::string& channel) { _invites.insert(channel); }
|
||||
inline bool hasBeenInvitedTo(const std::string& channel) { return _invites.erase(channel); }
|
||||
|
||||
~Client();
|
||||
|
||||
private:
|
||||
std::set<std::string> _invites;
|
||||
std::string _nickname;
|
||||
std::string _username;
|
||||
std::string _realname;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: vvaas <vvaas@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/01/21 10:35:52 by maldavid #+# #+# */
|
||||
/* Updated: 2024/01/29 23:10:37 by vvaas ### ########.fr */
|
||||
/* Updated: 2024/01/29 23:27:33 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace irc
|
||||
|
||||
void Client::sendCode(const std::string& code, const std::string& msg0, const std::string& msg1)
|
||||
{
|
||||
const std::string command = code + " " + msg0 + " :" + msg1 + "\r\n";
|
||||
const std::string command = ":yipirc " + code + " " + msg0 + " :" + msg1 + "\r\n";
|
||||
#ifdef DEBUG
|
||||
logs::report(log_message, "sending '%s'", command.c_str());
|
||||
#endif
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: vvaas <vvaas@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/01/21 09:31:17 by maldavid #+# #+# */
|
||||
/* Updated: 2024/01/29 23:09:30 by vvaas ### ########.fr */
|
||||
/* Updated: 2024/01/29 23:27:51 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
|
||||
@@ -150,7 +150,7 @@ namespace irc
|
||||
else if(msg.getCmd() == "JOIN")
|
||||
handleJoin(client, msg);
|
||||
else if(msg.getCmd() == "INVITE")
|
||||
handlePrivMsg(client, msg);
|
||||
handleInvite(client, msg);
|
||||
else if(msg.getCmd() == "PRIVMSG")
|
||||
handlePrivMsg(client, msg);
|
||||
else if(msg.getCmd() == "NOTICE")
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: vvaas <vvaas@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/01/22 17:31:06 by maldavid #+# #+# */
|
||||
/* Updated: 2024/01/29 23:26:02 by vvaas ### ########.fr */
|
||||
/* Updated: 2024/01/29 23:27:39 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
|
||||
@@ -174,13 +174,12 @@ namespace irc
|
||||
client->sendCode(ERR_BADCHANNELKEY, "Invalid password");
|
||||
else if(it->getChannelSize() != -1 && it->getChannelSize() >= static_cast<int>(it->getNumberOfClients()))
|
||||
client->sendCode(ERR_CHANNELISFULL, "Channel is full");
|
||||
else if(it->isInviteOnly() && !client->hasBeenInvitedTo(it->getName()))
|
||||
client->sendCode(ERR_INVITEONLYCHAN, "channel is invite only and you have not been invited u looser");
|
||||
else if(it->getPassword().size() == 0)
|
||||
it->addClient(client);
|
||||
else if(it->getPassword().size() > 0 && msg.getTokens()[2] == it->getPassword())
|
||||
it->addClient(client);
|
||||
|
||||
// client->printUserHeader();
|
||||
// std::cout << "joining new channel, " << msg.getTokens()[1] << std::endl;
|
||||
}
|
||||
|
||||
void Server::handlePrivMsg(unstd::SharedPtr<class Client> client, const Message& msg)
|
||||
@@ -336,6 +335,10 @@ namespace irc
|
||||
client->sendCode(ERR_CHANOPRIVSNEEDED, msg.getArgs()[1], "you're not channel operator");
|
||||
return;
|
||||
}
|
||||
|
||||
client_target->inviteToChannel(channel_target->getName());
|
||||
client_target->sendMsg(client->getNickName(), "INVITE " + msg.getArgs()[0] + ' ' + msg.getArgs()[1], "");
|
||||
client->sendCode(RPL_INVITING, msg.getArgs()[1] + ' ' + msg.getArgs()[0], "");
|
||||
}
|
||||
|
||||
void Server::handleKick(unstd::SharedPtr<class Client> client, const Message& msg)
|
||||
|
||||
Reference in New Issue
Block a user