]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_sapart.cpp
added m_noinvite that uses the new OnUserPreInvite method
[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 #include <stdio.h>
18 #include <string>
19 #include "users.h"
20 #include "channels.h"
21 #include "modules.h"
22
23 /* $ModDesc: Provides support for unreal-style SAPART command */
24
25 Server *Srv;
26          
27 void handle_sapart(char **parameters, int pcnt, userrec *user)
28 {
29         userrec* dest = Srv->FindNick(std::string(parameters[0]));
30         if (dest)
31         {
32                 for (int x = 0; x < strlen(parameters[1]); x++)
33                 {
34                                 if ((parameters[1][0] != '#') || (parameters[1][x] == ' ') || (parameters[1][x] == ','))
35                                 {
36                                         Srv->SendTo(NULL,user,"NOTICE "+std::string(user->nick)+" :*** Invalid characters in channel name");
37                                         return;
38                                 }
39                 }
40
41                 Srv->SendOpers(std::string(user->nick)+" used SAPART to make "+std::string(dest->nick)+" part "+parameters[1]);
42                 Srv->PartUserFromChannel(dest,std::string(parameters[1]),std::string(dest->nick));
43         }
44 }
45
46
47 class ModuleSapart : public Module
48 {
49  public:
50         ModuleSapart()
51         {
52                 Srv = new Server;
53                 Srv->AddCommand("SAPART",handle_sapart,'o',2);
54         }
55         
56         virtual ~ModuleSapart()
57         {
58                 delete Srv;
59         }
60         
61         virtual Version GetVersion()
62         {
63                 return Version(1,0,0,1);
64         }
65         
66 };
67
68 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
69
70 class ModuleSapartFactory : public ModuleFactory
71 {
72  public:
73         ModuleSapartFactory()
74         {
75         }
76         
77         ~ModuleSapartFactory()
78         {
79         }
80         
81         virtual Module * CreateModule()
82         {
83                 return new ModuleSapart;
84         }
85         
86 };
87
88
89 extern "C" void * init_module( void )
90 {
91         return new ModuleSapartFactory;
92 }
93