]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_sapart.cpp
7c3142cdd63dcf9c7a7b4ee74572326126f0809a
[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 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         }
37          
38         void Handle (char **parameters, int pcnt, userrec *user)
39         {
40                 userrec* dest = Srv->FindNick(std::string(parameters[0]));
41                 if (dest)
42                 {
43                         if (!IsValidChannelName(parameters[1]))
44                         {
45                                 Srv->SendTo(NULL,user,"NOTICE "+std::string(user->nick)+" :*** Invalid characters in channel name");
46                                 return;
47                         }
48
49                         Srv->SendOpers(std::string(user->nick)+" used SAPART to make "+std::string(dest->nick)+" part "+parameters[1]);
50                         Srv->PartUserFromChannel(dest,std::string(parameters[1]),std::string(dest->nick));
51                 }
52         }
53 };
54
55
56 class ModuleSapart : public Module
57 {
58         cmd_sapart*     mycommand;
59  public:
60         ModuleSapart(Server* Me)
61                 : Module::Module(Me)
62         {
63                 Srv = Me;
64                 mycommand = new cmd_sapart();
65                 Srv->AddCommand(mycommand);
66         }
67         
68         virtual ~ModuleSapart()
69         {
70         }
71         
72         virtual Version GetVersion()
73         {
74                 return Version(1,0,0,1,VF_VENDOR);
75         }
76         
77 };
78
79 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
80
81 class ModuleSapartFactory : public ModuleFactory
82 {
83  public:
84         ModuleSapartFactory()
85         {
86         }
87         
88         ~ModuleSapartFactory()
89         {
90         }
91         
92         virtual Module * CreateModule(Server* Me)
93         {
94                 return new ModuleSapart(Me);
95         }
96         
97 };
98
99
100 extern "C" void * init_module( void )
101 {
102         return new ModuleSapartFactory;
103 }
104