2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
5 * Copyright (C) 2007-2008 Robin Burchell <robin+git@viroteck.net>
6 * Copyright (C) 2008 Craig Edwards <craigedwards@brainbox.cc>
7 * Copyright (C) 2008 Thomas Stagner <aquanight@inspircd.org>
9 * This file is part of InspIRCd. InspIRCd is free software: you can
10 * redistribute it and/or modify it under the terms of the GNU General Public
11 * License as published by the Free Software Foundation, version 2.
13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 /** Handle /TOPIC. These command handlers can be reloaded by the core,
26 * and handle basic RFC1459 commands. Commands within modules work
27 * the same way, however, they can be fully unloaded, where these
30 class CommandTopic : public Command
33 /** Constructor for topic.
35 CommandTopic ( Module* parent) : Command(parent,"TOPIC",1, 2) { syntax = "<channel> [<topic>]"; Penalty = 2; }
37 * @param parameters The parameters to the comamnd
38 * @param pcnt The number of parameters passed to teh command
39 * @param user The user issuing the command
40 * @return A value from CmdResult to indicate command success or failure.
42 CmdResult Handle(const std::vector<std::string>& parameters, User *user);
45 CmdResult CommandTopic::Handle (const std::vector<std::string>& parameters, User *user)
49 c = ServerInstance->FindChan(parameters[0]);
52 user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick.c_str(), parameters[0].c_str());
56 if (parameters.size() == 1)
60 if ((c->IsModeSet('s')) && (!c->HasUser(user)))
62 user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick.c_str(), c->name.c_str());
66 if (c->topic.length())
68 user->WriteNumeric(332, "%s %s :%s", user->nick.c_str(), c->name.c_str(), c->topic.c_str());
69 user->WriteNumeric(333, "%s %s %s %lu", user->nick.c_str(), c->name.c_str(), c->setby.c_str(), (unsigned long)c->topicset);
73 user->WriteNumeric(RPL_NOTOPICSET, "%s %s :No topic is set.", user->nick.c_str(), c->name.c_str());
78 else if (parameters.size()>1)
80 std::string t = parameters[1]; // needed, in case a module wants to change it
88 COMMAND_INIT(CommandTopic)