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>
6 * Copyright (C) 2004-2005, 2007 Craig Edwards <craigedwards@brainbox.cc>
8 * This file is part of InspIRCd. InspIRCd is free software: you can
9 * redistribute it and/or modify it under the terms of the GNU General Public
10 * License as published by the Free Software Foundation, version 2.
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 /* $ModDesc: Provides command SAJOIN to allow opers to force-join users to channels */
28 class CommandSajoin : public Command
31 CommandSajoin(Module* Creator) : Command(Creator,"SAJOIN", 2)
33 allow_empty_last_param = false;
34 flags_needed = 'o'; Penalty = 0; syntax = "<nick> <channel>";
35 TRANSLATE3(TR_NICK, TR_TEXT, TR_END);
38 CmdResult Handle (const std::vector<std::string>& parameters, User *user)
40 User* dest = ServerInstance->FindNick(parameters[0]);
41 if ((dest) && (dest->registered == REG_ALL))
43 if (ServerInstance->ULine(dest->server))
45 user->WriteNumeric(ERR_NOPRIVILEGES, "%s :Cannot use an SA command on a u-lined client",user->nick.c_str());
48 if (IS_LOCAL(user) && !ServerInstance->IsChannel(parameters[1].c_str(), ServerInstance->Config->Limits.ChanMax))
50 /* we didn't need to check this for each character ;) */
51 user->WriteServ("NOTICE "+user->nick+" :*** Invalid characters in channel name or name too long");
55 /* For local users, we send the JoinUser which may create a channel and set its TS.
56 * For non-local users, we just return CMD_SUCCESS, knowing this will propagate it where it needs to be
57 * and then that server will generate the users JOIN or FJOIN instead.
61 Channel::JoinUser(dest, parameters[1], true, "", false, ServerInstance->Time());
62 /* Fix for dotslasher and w00t - if the join didnt succeed, return CMD_FAILURE so that it doesnt propagate */
63 Channel* n = ServerInstance->FindChan(parameters[1]);
68 ServerInstance->SNO->WriteToSnoMask('a', user->nick+" used SAJOIN to make "+dest->nick+" join "+parameters[1]);
73 user->WriteServ("NOTICE "+user->nick+" :*** Could not join "+dest->nick+" to "+parameters[1]+" (User is probably banned, or blocking modes)");
79 user->WriteServ("NOTICE "+user->nick+" :*** Could not join "+dest->nick+" to "+parameters[1]);
85 ServerInstance->SNO->WriteToSnoMask('a', user->nick+" sent remote SAJOIN to make "+dest->nick+" join "+parameters[1]);
91 user->WriteServ("NOTICE "+user->nick+" :*** No such nickname "+parameters[0]);
96 RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters)
98 User* dest = ServerInstance->FindNick(parameters[0]);
100 return ROUTE_OPT_UCAST(dest->server);
101 return ROUTE_LOCALONLY;
105 class ModuleSajoin : public Module
116 ServerInstance->Modules->AddService(cmd);
119 virtual Version GetVersion()
121 return Version("Provides command SAJOIN to allow opers to force-join users to channels", VF_OPTCOMMON | VF_VENDOR);
125 MODULE_INIT(ModuleSajoin)