]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_sapart.cpp
177a77d9b1d1678215eabc98d449973bb4dee7f3
[user/henk/code/inspircd.git] / src / modules / m_sapart.cpp
1 // Sapart and +g support module by C.J.Edwards
2
3 #include <stdio.h>
4 #include <string>
5 #include "users.h"
6 #include "channels.h"
7 #include "modules.h"
8
9 /* $ModDesc: Provides support for unreal-style SAPART command */
10
11 Server *Srv;
12          
13 void handle_sapart(char **parameters, int pcnt, userrec *user)
14 {
15         userrec* dest = Srv->FindNick(std::string(parameters[0]));
16         if (dest)
17         {
18                 for (int x = 0; x < strlen(parameters[1]); x++)
19                 {
20                                 if ((parameters[1][0] != '#') || (parameters[1][x] == ' ') || (parameters[1][x] == ','))
21                                 {
22                                         Srv->SendTo(NULL,user,"NOTICE "+std::string(user->nick)+" :*** Invalid characters in channel name");
23                                         return;
24                                 }
25                 }
26
27                 Srv->SendOpers(std::string(user->nick)+" used SAPART to make "+std::string(dest->nick)+" part "+parameters[1]);
28                 Srv->PartUserFromChannel(dest,std::string(parameters[1]),std::string(dest->nick));
29         }
30 }
31
32
33 class ModuleSapart : public Module
34 {
35  public:
36         ModuleSapart()
37         {
38                 Srv = new Server;
39                 Srv->AddCommand("SAPART",handle_sapart,'o',2);
40         }
41         
42         virtual ~ModuleSapart()
43         {
44                 delete Srv;
45         }
46         
47         virtual Version GetVersion()
48         {
49                 return Version(1,0,0,1);
50         }
51         
52 };
53
54 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
55
56 class ModuleSapartFactory : public ModuleFactory
57 {
58  public:
59         ModuleSapartFactory()
60         {
61         }
62         
63         ~ModuleSapartFactory()
64         {
65         }
66         
67         virtual Module * CreateModule()
68         {
69                 return new ModuleSapart;
70         }
71         
72 };
73
74
75 extern "C" void * init_module( void )
76 {
77         return new ModuleSapartFactory;
78 }
79