1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2007 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, false, 0)
25 this->source = "m_sapart.so";
26 syntax = "<nick> <channel>";
27 TRANSLATE3(TR_NICK, TR_TEXT, TR_END);
30 CmdResult Handle (const char** parameters, int pcnt, User *user)
32 User* dest = ServerInstance->FindNick(parameters[0]);
33 Channel* channel = ServerInstance->FindChan(parameters[1]);
36 if (ServerInstance->ULine(dest->server))
38 user->WriteServ("990 %s :Cannot use an SA command on a u-lined client",user->nick);
42 /* For local clients, directly part them generating a PART message. For remote clients,
43 * just return CMD_SUCCESS knowing the protocol module will route the SAPART to the users
44 * local server and that will generate the PART instead
48 if (!channel->PartUser(dest, dest->nick))
50 Channel* n = ServerInstance->FindChan(parameters[1]);
53 ServerInstance->WriteOpers("*** "+std::string(user->nick)+" used SAPART to make "+dest->nick+" part "+parameters[1]);
58 if (!n->HasUser(dest))
60 ServerInstance->WriteOpers("*** "+std::string(user->nick)+" used SAPART to make "+dest->nick+" part "+parameters[1]);
65 user->WriteServ("NOTICE %s :*** Unable to make %s part %s",user->nick, dest->nick, parameters[1]);
72 ServerInstance->WriteOpers("*** "+std::string(user->nick)+" sent remote SAPART to make "+dest->nick+" part "+parameters[1]);
79 user->WriteServ("NOTICE %s :*** Invalid nickname or channel", user->nick);
87 class ModuleSapart : public Module
89 CommandSapart* mycommand;
91 ModuleSapart(InspIRCd* Me)
95 mycommand = new CommandSapart(ServerInstance);
96 ServerInstance->AddCommand(mycommand);
100 virtual ~ModuleSapart()
104 virtual Version GetVersion()
106 return Version(1, 1, 0, 1, VF_COMMON | VF_VENDOR, API_VERSION);
111 MODULE_INIT(ModuleSapart)