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);
43 RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters)
45 return (IS_LOCAL(user) ? ROUTE_LOCALONLY : ROUTE_BROADCAST);
49 CmdResult CommandTopic::Handle (const std::vector<std::string>& parameters, User *user)
53 c = ServerInstance->FindChan(parameters[0]);
56 user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick.c_str(), parameters[0].c_str());
60 if (parameters.size() == 1)
64 if ((c->IsModeSet('s')) && (!c->HasUser(user)))
66 user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick.c_str(), c->name.c_str());
70 if (c->topic.length())
72 user->WriteNumeric(332, "%s %s :%s", user->nick.c_str(), c->name.c_str(), c->topic.c_str());
73 user->WriteNumeric(333, "%s %s %s %lu", user->nick.c_str(), c->name.c_str(), c->setby.c_str(), (unsigned long)c->topicset);
77 user->WriteNumeric(RPL_NOTOPICSET, "%s %s :No topic is set.", user->nick.c_str(), c->name.c_str());
82 else if (parameters.size()>1)
84 std::string t = parameters[1]; // needed, in case a module wants to change it
92 COMMAND_INIT(CommandTopic)