]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_sapart.cpp
6d1086bba5d670229c04ac81eaaef34368e350f9
[user/henk/code/inspircd.git] / src / modules / m_sapart.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
6  *                     E-mail:
7  *              <brain@chatspike.net>
8  *                <Craig@chatspike.net>
9  *     
10  * Written by Craig Edwards, Craig McLure, and others.
11  * This program is free but copyrighted software; see
12  *          the file COPYING for details.
13  *
14  * ---------------------------------------------------
15  */
16
17 using namespace std;
18
19 #include <stdio.h>
20 #include <string>
21 #include "users.h"
22 #include "channels.h"
23 #include "modules.h"
24 #include "helperfuncs.h"
25
26 /* $ModDesc: Provides support for unreal-style SAPART command */
27
28 static Server *Srv;
29
30 class cmd_sapart : public command_t
31 {
32  public:
33         cmd_sapart () : command_t("SAPART", 'o', 2)
34         {
35                 this->source = "m_sapart.so";
36                 syntax = "<nick> <channel>";
37         }
38          
39         void Handle (const char** parameters, int pcnt, userrec *user)
40         {
41                 userrec* dest = Srv->FindNick(parameters[0]);
42                 chanrec* channel = Srv->FindChannel(parameters[1]);
43                 if (dest && channel)
44                 {
45                         if (Srv->IsUlined(dest->server))
46                         {
47                                 user->WriteServ("990 %s :Cannot use an SA command on a u-lined client",user->nick);
48                                 return;
49                         }
50                         Srv->SendOpers(std::string(user->nick)+" used SAPART to make "+dest->nick+" part "+parameters[1]);
51                         if (!channel->PartUser(dest, dest->nick))
52                                 delete channel;
53                 }
54         }
55 };
56
57
58 class ModuleSapart : public Module
59 {
60         cmd_sapart*     mycommand;
61  public:
62         ModuleSapart(Server* Me)
63                 : Module::Module(Me)
64         {
65                 Srv = Me;
66                 mycommand = new cmd_sapart();
67                 Srv->AddCommand(mycommand);
68         }
69         
70         virtual ~ModuleSapart()
71         {
72         }
73         
74         virtual Version GetVersion()
75         {
76                 return Version(1,0,0,1,VF_VENDOR);
77         }
78         
79 };
80
81 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
82
83 class ModuleSapartFactory : public ModuleFactory
84 {
85  public:
86         ModuleSapartFactory()
87         {
88         }
89         
90         ~ModuleSapartFactory()
91         {
92         }
93         
94         virtual Module * CreateModule(Server* Me)
95         {
96                 return new ModuleSapart(Me);
97         }
98         
99 };
100
101
102 extern "C" void * init_module( void )
103 {
104         return new ModuleSapartFactory;
105 }
106