feat(cmd/channel): update the constructor of channel (empty topic)

This commit is contained in:
Raphael 2025-06-19 14:11:48 +02:00
parent 38317ec36b
commit d62ffb35a4
2 changed files with 7 additions and 7 deletions

View file

@ -6,7 +6,7 @@
/* By: sben-tay <sben-tay@student.42.fr> +#+ +:+ +#+ */ /* By: sben-tay <sben-tay@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/05/20 22:43:24 by rparodi #+# #+# */ /* Created: 2025/05/20 22:43:24 by rparodi #+# #+# */
/* Updated: 2025/06/19 13:46:05 by sben-tay ### ########.fr */ /* Updated: 2025/06/19 13:58:39 by rparodi ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -17,7 +17,7 @@
Channel::Channel(const std::string &name, User *owner, size_t maxUsers, bool needInvite) : _name(name), _owner(owner), _maxUsers(maxUsers), _needInvite(needInvite) { Channel::Channel(const std::string &name, User *owner, size_t maxUsers, bool needInvite) : _name(name), _owner(owner), _maxUsers(maxUsers), _needInvite(needInvite) {
this->_protectTopic = false; this->_protectTopic = false;
this->_maxUsers = ~0; this->_maxUsers = ~0;
this->_topic = "No topic is set"; this->_topic = "";
} }
/** /**

View file

@ -6,7 +6,7 @@
/* By: sben-tay <sben-tay@student.42.fr> +#+ +:+ +#+ */ /* By: sben-tay <sben-tay@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/05/24 16:11:56 by rparodi #+# #+# */ /* Created: 2025/05/24 16:11:56 by rparodi #+# #+# */
/* Updated: 2025/06/19 11:25:46 by rparodi ### ########.fr */ /* Updated: 2025/06/19 13:02:11 by rparodi ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -38,7 +38,7 @@
* @param line line send by the user * @param line line send by the user
*/ */
std::vector<std::string> cmd::split(std::string &line) { std::vector<std::string> cmd::split(std::string &line, char sep) {
std::vector<std::string> args; std::vector<std::string> args;
size_t start = 0; size_t start = 0;
size_t end; size_t end;
@ -49,7 +49,7 @@ std::vector<std::string> cmd::split(std::string &line) {
args.push_back(arg); args.push_back(arg);
break; break;
} }
end = line.find(' ', start); end = line.find(sep, start);
if (end == std::string::npos) if (end == std::string::npos)
end = line.length(); end = line.length();
std::string arg = line.substr(start, end - start); std::string arg = line.substr(start, end - start);
@ -72,7 +72,7 @@ std::vector<std::string> cmd::split(std::string &line) {
* @param line input line from the user * @param line input line from the user
*/ */
void cmd::dispatch(::User *user, Channel *channel, Server *server, std::string &line) { void cmd::dispatch(::User *user, Channel *channel, Server *server, std::string &line) {
std::vector<std::string> args = cmd::split(line); std::vector<std::string> args = cmd::split(line, ' ');
if (args.empty()) { if (args.empty()) {
DEBUG_MSG("Empty line"); DEBUG_MSG("Empty line");
return; return;
@ -163,7 +163,7 @@ void cmd::dispatch(::User *user, Channel *channel, Server *server, std::string &
cmd::ACommand::ACommand(::User *user, ::Channel *channel, ::Server *server, std::string &line) : _sender(user), _channel(channel), _server(server) { cmd::ACommand::ACommand(::User *user, ::Channel *channel, ::Server *server, std::string &line) : _sender(user), _channel(channel), _server(server) {
DEBUG_MSG("ACommand constructor called"); DEBUG_MSG("ACommand constructor called");
_args = split(line); _args = split(line, ' ');
_command = _args.at(0); _command = _args.at(0);
_channels = server->getChannelsList(); _channels = server->getChannelsList();
_users = server->getUsersList(); _users = server->getUsersList();