]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_sapart.cpp
Converted more stuff to 'Implements' system
[user/henk/code/inspircd.git] / src / modules / m_sapart.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  Inspire is copyright (C) 2002-2004 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
25 /* $ModDesc: Provides support for unreal-style SAPART command */
26
27 Server *Srv;
28
29 class cmd_sapart : public command_t
30 {
31  public:
32         cmd_sapart () : command_t("SAPART", 'o', 2)
33         {
34                 this->source = "m_sapart.so";
35         }
36          
37         void Handle (char **parameters, int pcnt, userrec *user)
38         {
39                 userrec* dest = Srv->FindNick(std::string(parameters[0]));
40                 if (dest)
41                 {
42                         for (unsigned int x = 0; x < strlen(parameters[1]); x++)
43                         {
44                                         if ((parameters[1][0] != '#') || (parameters[1][x] == ' ') || (parameters[1][x] == ','))
45                                         {
46                                                 Srv->SendTo(NULL,user,"NOTICE "+std::string(user->nick)+" :*** Invalid characters in channel name");
47                                                 return;
48                                         }
49                         }
50
51                         Srv->SendOpers(std::string(user->nick)+" used SAPART to make "+std::string(dest->nick)+" part "+parameters[1]);
52                         Srv->PartUserFromChannel(dest,std::string(parameters[1]),std::string(dest->nick));
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