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 * ---------------------------------------------------
21 /* $ModDesc: Provides support for unreal-style SAPART command */
25 class cmd_sapart : public command_t
28 cmd_sapart (InspIRCd* Instance) : command_t(Instance,"SAPART", 'o', 2)
30 this->source = "m_sapart.so";
31 syntax = "<nick> <channel>";
34 CmdResult Handle (const char** parameters, int pcnt, userrec *user)
36 userrec* dest = ServerInstance->FindNick(parameters[0]);
37 chanrec* channel = ServerInstance->FindChan(parameters[1]);
40 if (ServerInstance->ULine(dest->server))
42 user->WriteServ("990 %s :Cannot use an SA command on a u-lined client",user->nick);
46 /* For local clients, directly part them generating a PART message. For remote clients,
47 * just return CMD_SUCCESS knowing the protocol module will route the SAPART to the users
48 * local server and that will generate the PART instead
52 if (!channel->PartUser(dest, dest->nick))
54 chanrec* n = ServerInstance->FindChan(parameters[1]);
57 ServerInstance->WriteOpers("*** "+std::string(user->nick)+" used SAPART to make "+dest->nick+" part "+parameters[1]);
62 if (!n->HasUser(dest))
64 ServerInstance->WriteOpers("*** "+std::string(user->nick)+" used SAPART to make "+dest->nick+" part "+parameters[1]);
69 user->WriteServ("NOTICE %s :*** Unable to make %s part %s",user->nick, dest->nick, parameters[1]);
76 ServerInstance->WriteOpers("*** "+std::string(user->nick)+" sent remote SAPART to make "+dest->nick+" part "+parameters[1]);
83 user->WriteServ("NOTICE %s :*** Invalid nickname or channel", user->nick);
91 class ModuleSapart : public Module
93 cmd_sapart* mycommand;
95 ModuleSapart(InspIRCd* Me)
99 mycommand = new cmd_sapart(ServerInstance);
100 ServerInstance->AddCommand(mycommand);
103 virtual ~ModuleSapart()
107 virtual Version GetVersion()
109 return Version(1,1,0,1,VF_VENDOR,API_VERSION);
114 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
116 class ModuleSapartFactory : public ModuleFactory
119 ModuleSapartFactory()
123 ~ModuleSapartFactory()
127 virtual Module * CreateModule(InspIRCd* Me)
129 return new ModuleSapart(Me);
135 extern "C" void * init_module( void )
137 return new ModuleSapartFactory;