2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2017 B00mX0r <b00mx0r@aureus.pw>
5 * Copyright (C) 2013, 2018-2019 Sadie Powell <sadie@witchery.services>
6 * Copyright (C) 2012-2016 Attila Molnar <attilamolnar@hush.com>
7 * Copyright (C) 2012 Robby <robby@chatbelgie.be>
8 * Copyright (C) 2009-2010 Daniel De Graaf <danieldg@inspircd.org>
9 * Copyright (C) 2007-2008 Robin Burchell <robin+git@viroteck.net>
10 * Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
11 * Copyright (C) 2006, 2010 Craig Edwards <brain@inspircd.org>
13 * This file is part of InspIRCd. InspIRCd is free software: you can
14 * redistribute it and/or modify it under the terms of the GNU General Public
15 * License as published by the Free Software Foundation, version 2.
17 * This program is distributed in the hope that it will be useful, but WITHOUT
18 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
22 * You should have received a copy of the GNU General Public License
23 * along with this program. If not, see <http://www.gnu.org/licenses/>.
28 #include "modules/invite.h"
38 class CommandUninvite : public Command
42 CommandUninvite(Module* Creator)
43 : Command(Creator, "UNINVITE", 2)
46 syntax = "<nick> <channel>";
47 TRANSLATE2(TR_NICK, TR_TEXT);
50 CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE
54 u = ServerInstance->FindNickOnly(parameters[0]);
56 u = ServerInstance->FindNick(parameters[0]);
58 Channel* c = ServerInstance->FindChan(parameters[1]);
60 if ((!c) || (!u) || (u->registered != REG_ALL))
64 user->WriteNumeric(Numerics::NoSuchChannel(parameters[1]));
68 user->WriteNumeric(Numerics::NoSuchNick(parameters[0]));
76 if (c->GetPrefixValue(user) < HALFOP_VALUE)
78 user->WriteNumeric(ERR_CHANOPRIVSNEEDED, c->name, InspIRCd::Format("You must be a channel %soperator", c->GetPrefixValue(u) == HALFOP_VALUE ? "" : "half-"));
83 /* Servers remember invites only for their local users, so act
84 * only if the target is local. Otherwise the command will be
85 * passed to the target users server.
87 LocalUser* lu = IS_LOCAL(u);
90 // XXX: The source of the numeric we send must be the server of the user doing the /UNINVITE,
91 // so they don't see where the target user is connected to
92 if (!invapi->Remove(lu, c))
94 Numeric::Numeric n(505);
95 n.SetServer(user->server);
96 n.push(u->nick).push(c->name).push(InspIRCd::Format("Is not invited to channel %s", c->name.c_str()));
97 user->WriteRemoteNumeric(n);
101 Numeric::Numeric n(494);
102 n.SetServer(user->server);
103 n.push(c->name).push(u->nick).push("Uninvited");
104 user->WriteRemoteNumeric(n);
106 lu->WriteNumeric(RPL_UNINVITED, InspIRCd::Format("You were uninvited from %s by %s", c->name.c_str(), user->nick.c_str()));
107 c->WriteRemoteNotice(InspIRCd::Format("*** %s uninvited %s.", user->nick.c_str(), u->nick.c_str()));
113 RouteDescriptor GetRouting(User* user, const Params& parameters) CXX11_OVERRIDE
115 return ROUTE_OPT_UCAST(parameters[0]);
119 class ModuleUninvite : public Module
125 ModuleUninvite() : cmd(this)
129 Version GetVersion() CXX11_OVERRIDE
131 return Version("Provides the UNINVITE command which lets users un-invite other users from channels", VF_VENDOR | VF_OPTCOMMON);
135 MODULE_INIT(ModuleUninvite)