2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
5 * Copyright (C) 2007 Robin Burchell <robin+git@viroteck.net>
7 * This file is part of InspIRCd. InspIRCd is free software: you can
8 * redistribute it and/or modify it under the terms of the GNU General Public
9 * License as published by the Free Software Foundation, version 2.
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
23 /* $ModDesc: Provides command CYCLE, acts as a server-side HOP command to part and rejoin a channel. */
27 class CommandCycle : public Command
30 CommandCycle(Module* Creator) : Command(Creator,"CYCLE", 1)
32 Penalty = 3; syntax = "<channel> :[reason]";
33 TRANSLATE3(TR_TEXT, TR_TEXT, TR_END);
36 CmdResult Handle (const std::vector<std::string> ¶meters, User *user)
38 Channel* channel = ServerInstance->FindChan(parameters[0]);
39 std::string reason = ConvToStr("Cycling");
41 if (parameters.size() > 1)
43 /* reason provided, use it */
44 reason = reason + ": " + parameters[1];
49 user->WriteNumeric(403, "%s %s :No such channel", user->nick.c_str(), parameters[0].c_str());
53 if (channel->HasUser(user))
56 * technically, this is only ever sent locally, but pays to be safe ;p
60 if (channel->GetPrefixValue(user) < VOICE_VALUE && channel->IsBanned(user))
62 /* banned, boned. drop the message. */
63 user->WriteServ("NOTICE "+user->nick+" :*** You may not cycle, as you are banned on channel " + channel->name);
67 channel->PartUser(user, reason);
69 Channel::JoinUser(user, parameters[0], true, "", false, ServerInstance->Time());
76 user->WriteNumeric(442, "%s %s :You're not on that channel", user->nick.c_str(), channel->name.c_str());
84 class ModuleCycle : public Module
96 ServerInstance->Modules->AddService(cmd);
99 virtual Version GetVersion()
101 return Version("Provides command CYCLE, acts as a server-side HOP command to part and rejoin a channel.", VF_VENDOR);
105 MODULE_INIT(ModuleCycle)