/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* topic.cpp :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: aortigos > channel; getline(ss, message); if (!client.isRegistered()) return (client.send(":" SERVER_NAME " 451 " + client.getNick() + " :You have not registered\r\n")); std::map::iterator it = channels_.find(channel); if (it == channels_.end()) return (client.send(":" SERVER_NAME " 403 " + client.getNick() + " " + channel + " :No such channel\r\n")); if (!it->second.hasMember(client.getFd())) return (client.send(":" SERVER_NAME " 404 " + client.getNick() + " " + channel + " :Cannot send to channel\r\n")); if (message.empty()) { std::string res = it->second.getTopic(); if (res.empty()) return (client.send(":" SERVER_NAME " 331 " + client.getNick() + " " + channel + " :No topic is set\r\n")); client.send(":" SERVER_NAME " 332 " + client.getNick() + " " + channel + " :" + res + "\r\n"); } else { if (!message.empty() && message[0] == ' ') message = message.substr(1); if (!it->second.hasOperator(client.getFd())) return (client.send(":" SERVER_NAME " 482 " + client.getNick() + " " + channel + " :You're not channel operator\r\n")); it->second.setTopic(message); it->second.broadcast(":" + client.getNick() + "!" + client.getUsername() + "@localhost TOPIC " + channel + " :" + message + "\r\n", clients_, -1); } }