2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
5 * Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
6 * Copyright (C) 2006-2007 Craig Edwards <craigedwards@brainbox.cc>
7 * Copyright (C) 2006 Robin Burchell <robin+git@viroteck.net>
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/>.
23 /* $ModDesc: Provides the UNINVITE command which lets users un-invite other users from channels (!) */
29 class CommandUninvite : public Command
32 CommandUninvite(Module* Creator) : Command(Creator,"UNINVITE", 2)
34 syntax = "<nick> <channel>";
35 TRANSLATE3(TR_NICK, TR_TEXT, TR_END);
38 CmdResult Handle (const std::vector<std::string> ¶meters, User *user)
40 User* u = ServerInstance->FindNick(parameters[0]);
41 Channel* c = ServerInstance->FindChan(parameters[1]);
47 user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick.c_str(), parameters[1].c_str());
51 user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick.c_str(), parameters[0].c_str());
59 if (c->GetPrefixValue(user) < HALFOP_VALUE)
61 user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s %s :You must be a channel %soperator", user->nick.c_str(), c->name.c_str(), c->GetPrefixValue(u) == HALFOP_VALUE ? "" : "half-");
66 irc::string xname(c->name.c_str());
70 // TODO send messages & such out to remote servers
71 LocalUser* lu = IS_LOCAL(u);
72 if (!lu->IsInvited(xname))
74 user->WriteNumeric(505, "%s %s %s :Is not invited to channel %s", user->nick.c_str(), u->nick.c_str(), c->name.c_str(), c->name.c_str());
77 user->WriteNumeric(494, "%s %s %s :Uninvited", user->nick.c_str(), c->name.c_str(), u->nick.c_str());
78 lu->RemoveInvite(xname);
79 lu->WriteNumeric(493, "%s :You were uninvited from %s by %s", u->nick.c_str(), c->name.c_str(), user->nick.c_str());
80 c->WriteChannelWithServ(ServerInstance->Config->ServerName, "NOTICE %s :*** %s uninvited %s.",
81 c->name.c_str(), user->nick.c_str(), u->nick.c_str());
87 RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters)
89 User* u = ServerInstance->FindNick(parameters[0]);
90 return u ? ROUTE_OPT_UCAST(u->server) : ROUTE_LOCALONLY;
94 class ModuleUninvite : public Module
100 ModuleUninvite() : cmd(this)
102 ServerInstance->AddCommand(&cmd);
105 virtual ~ModuleUninvite()
109 virtual Version GetVersion()
111 return Version("Provides the UNINVITE command which lets users un-invite other users from channels", VF_VENDOR | VF_OPTCOMMON);
115 MODULE_INIT(ModuleUninvite)