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/>.
24 #include "modules/invite.h"
28 class CommandUninvite : public Command
32 CommandUninvite(Module* Creator)
33 : Command(Creator, "UNINVITE", 2)
36 syntax = "<nick> <channel>";
37 TRANSLATE2(TR_NICK, TR_TEXT);
40 CmdResult Handle(const std::vector<std::string>& parameters, User* user) CXX11_OVERRIDE
44 u = ServerInstance->FindNickOnly(parameters[0]);
46 u = ServerInstance->FindNick(parameters[0]);
48 Channel* c = ServerInstance->FindChan(parameters[1]);
50 if ((!c) || (!u) || (u->registered != REG_ALL))
54 user->WriteNumeric(Numerics::NoSuchNick(parameters[1]));
58 user->WriteNumeric(Numerics::NoSuchNick(parameters[0]));
66 if (c->GetPrefixValue(user) < HALFOP_VALUE)
68 user->WriteNumeric(ERR_CHANOPRIVSNEEDED, c->name, InspIRCd::Format("You must be a channel %soperator", c->GetPrefixValue(u) == HALFOP_VALUE ? "" : "half-"));
73 /* Servers remember invites only for their local users, so act
74 * only if the target is local. Otherwise the command will be
75 * passed to the target users server.
77 LocalUser* lu = IS_LOCAL(u);
80 // XXX: The source of the numeric we send must be the server of the user doing the /UNINVITE,
81 // so they don't see where the target user is connected to
82 if (!invapi->Remove(lu, c))
84 Numeric::Numeric n(505);
85 n.SetServer(user->server);
86 n.push(u->nick).push(c->name).push(InspIRCd::Format("Is not invited to channel %s", c->name.c_str()));
87 user->WriteRemoteNumeric(n);
91 Numeric::Numeric n(494);
92 n.SetServer(user->server);
93 n.push(c->name).push(u->nick).push("Uninvited");
94 user->WriteRemoteNumeric(n);
96 lu->WriteNumeric(493, InspIRCd::Format("You were uninvited from %s by %s", c->name.c_str(), user->nick.c_str()));
98 std::string msg = "*** " + user->nick + " uninvited " + u->nick + ".";
100 ServerInstance->PI->SendChannelNotice(c, 0, msg);
106 RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) CXX11_OVERRIDE
108 return ROUTE_OPT_UCAST(parameters[0]);
112 class ModuleUninvite : public Module
118 ModuleUninvite() : cmd(this)
122 Version GetVersion() CXX11_OVERRIDE
124 return Version("Provides the UNINVITE command which lets users un-invite other users from channels", VF_VENDOR | VF_OPTCOMMON);
128 MODULE_INIT(ModuleUninvite)