]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_sapart.cpp
Note: FOR THE MOMENT, this is BROKEN. It wont run right until im done.
[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 #include "inspircd.h"
26
27 /* $ModDesc: Provides support for unreal-style SAPART command */
28
29 static Server *Srv;
30 extern InspIRCd* ServerInstance;
31
32 class cmd_sapart : public command_t
33 {
34  public:
35         cmd_sapart () : command_t("SAPART", 'o', 2)
36         {
37                 this->source = "m_sapart.so";
38                 syntax = "<nick> <channel>";
39         }
40          
41         void Handle (const char** parameters, int pcnt, userrec *user)
42         {
43                 userrec* dest = ServerInstance->FindNick(parameters[0]);
44                 chanrec* channel = ServerInstance->FindChan(parameters[1]);
45                 if (dest && channel)
46                 {
47                         if (Srv->IsUlined(dest->server))
48                         {
49                                 user->WriteServ("990 %s :Cannot use an SA command on a u-lined client",user->nick);
50                                 return;
51                         }
52                         ServerInstance->WriteOpers(std::string(user->nick)+" used SAPART to make "+dest->nick+" part "+parameters[1]);
53                         if (!channel->PartUser(dest, dest->nick))
54                                 delete channel;
55                 }
56         }
57 };
58
59
60 class ModuleSapart : public Module
61 {
62         cmd_sapart*     mycommand;
63  public:
64         ModuleSapart(InspIRCd* Me)
65                 : Module::Module(Me)
66         {
67                 
68                 mycommand = new cmd_sapart();
69                 Srv->AddCommand(mycommand);
70         }
71         
72         virtual ~ModuleSapart()
73         {
74         }
75         
76         virtual Version GetVersion()
77         {
78                 return Version(1,0,0,1,VF_VENDOR);
79         }
80         
81 };
82
83 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
84
85 class ModuleSapartFactory : public ModuleFactory
86 {
87  public:
88         ModuleSapartFactory()
89         {
90         }
91         
92         ~ModuleSapartFactory()
93         {
94         }
95         
96         virtual Module * CreateModule(InspIRCd* Me)
97         {
98                 return new ModuleSapart(Me);
99         }
100         
101 };
102
103
104 extern "C" void * init_module( void )
105 {
106         return new ModuleSapartFactory;
107 }
108