]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_sapart.cpp
Annotations
[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
25 #include "inspircd.h"
26
27 /* $ModDesc: Provides support for unreal-style SAPART command */
28
29
30
31
32 class cmd_sapart : public command_t
33 {
34  public:
35         cmd_sapart (InspIRCd* Instance) : command_t(Instance,"SAPART", 'o', 2)
36         {
37                 this->source = "m_sapart.so";
38                 syntax = "<nick> <channel>";
39         }
40
41         CmdResult 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 (ServerInstance->ULine(dest->server))
48                         {
49                                 user->WriteServ("990 %s :Cannot use an SA command on a u-lined client",user->nick);
50                                 return CMD_FAILURE;
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                         return CMD_SUCCESS;
57                 }
58
59                 return CMD_FAILURE;
60         }
61 };
62
63
64 class ModuleSapart : public Module
65 {
66         cmd_sapart*     mycommand;
67  public:
68         ModuleSapart(InspIRCd* Me)
69                 : Module::Module(Me)
70         {
71                 
72                 mycommand = new cmd_sapart(ServerInstance);
73                 ServerInstance->AddCommand(mycommand);
74         }
75         
76         virtual ~ModuleSapart()
77         {
78         }
79         
80         virtual Version GetVersion()
81         {
82                 return Version(1,0,0,1,VF_VENDOR);
83         }
84         
85 };
86
87 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
88
89 class ModuleSapartFactory : public ModuleFactory
90 {
91  public:
92         ModuleSapartFactory()
93         {
94         }
95         
96         ~ModuleSapartFactory()
97         {
98         }
99         
100         virtual Module * CreateModule(InspIRCd* Me)
101         {
102                 return new ModuleSapart(Me);
103         }
104         
105 };
106
107
108 extern "C" void * init_module( void )
109 {
110         return new ModuleSapartFactory;
111 }
112