1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2009 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
16 /* $ModDesc: Provides support for unreal-style SAPART command */
20 class CommandSapart : public Command
23 CommandSapart (InspIRCd* Instance) : Command(Instance,"SAPART", "o", 2, 3, false, 0)
25 this->source = "m_sapart.so";
26 syntax = "<nick> <channel> [reason]";
27 TRANSLATE4(TR_NICK, TR_TEXT, TR_TEXT, TR_END);
30 CmdResult Handle (const std::vector<std::string>& parameters, User *user)
32 User* dest = ServerInstance->FindNick(parameters[0]);
33 Channel* channel = ServerInstance->FindChan(parameters[1]);
34 std::string reason = "";
38 if (parameters.size() > 2)
39 reason = parameters[2];
41 if (ServerInstance->ULine(dest->server))
43 user->WriteNumeric(ERR_NOPRIVILEGES, "%s :Cannot use an SA command on a u-lined client",user->nick.c_str());
47 /* For local clients, directly part them generating a PART message. For remote clients,
48 * just return CMD_SUCCESS knowing the protocol module will route the SAPART to the users
49 * local server and that will generate the PART instead
53 if (!channel->PartUser(dest, reason))
56 Channel* n = ServerInstance->FindChan(parameters[1]);
59 ServerInstance->SNO->WriteToSnoMask('A', std::string(user->nick)+" used SAPART to make "+dest->nick+" part "+parameters[1]);
64 if (!n->HasUser(dest))
66 ServerInstance->SNO->WriteToSnoMask('A', std::string(user->nick)+" used SAPART to make "+dest->nick+" part "+parameters[1]);
71 user->WriteServ("NOTICE %s :*** Unable to make %s part %s",user->nick.c_str(), dest->nick.c_str(), parameters[1].c_str());
78 ServerInstance->SNO->WriteToSnoMask('A', std::string(user->nick)+" sent remote SAPART to make "+dest->nick+" part "+parameters[1]);
85 user->WriteServ("NOTICE %s :*** Invalid nickname or channel", user->nick.c_str());
93 class ModuleSapart : public Module
95 CommandSapart* mycommand;
97 ModuleSapart(InspIRCd* Me)
101 mycommand = new CommandSapart(ServerInstance);
102 ServerInstance->AddCommand(mycommand);
106 virtual ~ModuleSapart()
110 virtual Version GetVersion()
112 return Version("$Id$", VF_COMMON | VF_VENDOR, API_VERSION);
117 MODULE_INIT(ModuleSapart)