1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2008 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> [reason]";
27 TRANSLATE4(TR_NICK, TR_TEXT, TR_TEXT, TR_END);
30 CmdResult Handle (const char* const* parameters, int pcnt, User *user)
32 User* dest = ServerInstance->FindNick(parameters[0]);
33 Channel* channel = ServerInstance->FindChan(parameters[1]);
38 ServerInstance->Logs->Log("m_sapart",DEBUG, "SAPART: pcnt is %d", pcnt);
40 reason = parameters[2];
44 if (ServerInstance->ULine(dest->server))
46 user->WriteServ("990 %s :Cannot use an SA command on a u-lined client",user->nick);
50 /* For local clients, directly part them generating a PART message. For remote clients,
51 * just return CMD_SUCCESS knowing the protocol module will route the SAPART to the users
52 * local server and that will generate the PART instead
56 if (!channel->PartUser(dest, reason.c_str()))
58 Channel* n = ServerInstance->FindChan(parameters[1]);
61 ServerInstance->SNO->WriteToSnoMask('A', std::string(user->nick)+" used SAPART to make "+dest->nick+" part "+parameters[1]);
66 if (!n->HasUser(dest))
68 ServerInstance->SNO->WriteToSnoMask('A', std::string(user->nick)+" used SAPART to make "+dest->nick+" part "+parameters[1]);
73 user->WriteServ("NOTICE %s :*** Unable to make %s part %s",user->nick, dest->nick, parameters[1]);
80 ServerInstance->SNO->WriteToSnoMask('A', std::string(user->nick)+" sent remote SAPART to make "+dest->nick+" part "+parameters[1]);
87 user->WriteServ("NOTICE %s :*** Invalid nickname or channel", user->nick);
95 class ModuleSapart : public Module
97 CommandSapart* mycommand;
99 ModuleSapart(InspIRCd* Me)
103 mycommand = new CommandSapart(ServerInstance);
104 ServerInstance->AddCommand(mycommand);
108 virtual ~ModuleSapart()
112 virtual Version GetVersion()
114 return Version(1, 1, 0, 1, VF_COMMON | VF_VENDOR, API_VERSION);
119 MODULE_INIT(ModuleSapart)