]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_sajoin.cpp
Fix test client error cheecking on result types
[user/henk/code/inspircd.git] / src / modules / m_sajoin.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 SAJOIN command */
27
28 static Server *Srv;
29
30 class cmd_sajoin : public command_t
31 {
32  public:
33         cmd_sajoin() : command_t("SAJOIN", 'o', 2)
34         {
35                 this->source = "m_sajoin.so";
36         }
37
38         void Handle (const char** parameters, int pcnt, userrec *user)
39         {
40                 userrec* dest = Srv->FindNick(std::string(parameters[0]));
41                 if (dest)
42                 {
43                         if (Srv->IsUlined(dest->server))
44                         {
45                                 WriteServ(user->fd,"990 %s :Cannot use an SA command on a u-lined client",user->nick);
46                                 return;
47                         }
48                         if (!IsValidChannelName(parameters[1]))
49                         {
50                                 /* we didn't need to check this for each character ;) */
51                                 Srv->SendTo(NULL,user,"NOTICE "+std::string(user->nick)+" :*** Invalid characters in channel name");
52                                 return;
53                         }
54
55                         Srv->SendOpers(std::string(user->nick)+" used SAJOIN to make "+std::string(dest->nick)+" join "+parameters[1]);
56                         Srv->JoinUserToChannel(dest,std::string(parameters[1]),std::string(dest->nick));
57                 }
58         }
59 };
60
61 class ModuleSajoin : public Module
62 {
63         cmd_sajoin*     mycommand;
64  public:
65         ModuleSajoin(Server* Me)
66                 : Module::Module(Me)
67         {
68                 Srv = Me;
69                 mycommand = new cmd_sajoin();
70                 Srv->AddCommand(mycommand);
71         }
72         
73         virtual ~ModuleSajoin()
74         {
75         }
76         
77         virtual Version GetVersion()
78         {
79                 return Version(1,0,0,1,VF_VENDOR);
80         }
81         
82 };
83
84 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
85
86 class ModuleSajoinFactory : public ModuleFactory
87 {
88  public:
89         ModuleSajoinFactory()
90         {
91         }
92         
93         ~ModuleSajoinFactory()
94         {
95         }
96         
97         virtual Module * CreateModule(Server* Me)
98         {
99                 return new ModuleSajoin(Me);
100         }
101         
102 };
103
104
105 extern "C" void * init_module( void )
106 {
107         return new ModuleSajoinFactory;
108 }
109