]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_sajoin.cpp
Fixed compile problems... Move along please, nothing to see here..
[user/henk/code/inspircd.git] / src / modules / m_sajoin.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 SAJOIN command */
26
27 Server *Srv;
28
29 class cmd_sajoin : public command_t
30 {
31  public:
32         cmd_sajoin() : command_t("SAJOIN", 'o', 2)
33         {
34                 this->source = "m_sajoin.cpp";
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                         /* might be nicer to make checking valid channel names an api function sometime --w00t */
43                         if (parameters[1][0] != '#')
44                         {
45                                 /* we didn't need to check this for each character ;) */
46                                 Srv->SendTo(NULL,user,"NOTICE "+std::string(user->nick)+" :*** Invalid characters in channel name");
47                                 return;
48                         }
49
50                         for (unsigned int x = 0; x < strlen(parameters[1]); x++)
51                         {
52                                         if ((parameters[1][x] == ' ') || (parameters[1][x] == ','))
53                                         {
54                                                 Srv->SendTo(NULL,user,"NOTICE "+std::string(user->nick)+" :*** Invalid characters in channel name");
55                                                 return;
56                                         }
57                         }
58
59                         Srv->SendOpers(std::string(user->nick)+" used SAJOIN to make "+std::string(dest->nick)+" join "+parameters[1]);
60                         Srv->JoinUserToChannel(dest,std::string(parameters[1]),std::string(dest->nick));
61                 }
62         }
63 };
64
65 class ModuleSajoin : public Module
66 {
67         cmd_sajoin*     mycommand;
68  public:
69         ModuleSajoin(Server* Me)
70                 : Module::Module(Me)
71         {
72                 Srv = Me;
73                 mycommand = new cmd_sajoin();
74                 Srv->AddCommand(mycommand);
75         }
76         
77         virtual ~ModuleSajoin()
78         {
79         }
80         
81         virtual Version GetVersion()
82         {
83                 return Version(1,0,0,1,VF_VENDOR);
84         }
85         
86 };
87
88 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
89
90 class ModuleSajoinFactory : public ModuleFactory
91 {
92  public:
93         ModuleSajoinFactory()
94         {
95         }
96         
97         ~ModuleSajoinFactory()
98         {
99         }
100         
101         virtual Module * CreateModule(Server* Me)
102         {
103                 return new ModuleSajoin(Me);
104         }
105         
106 };
107
108
109 extern "C" void * init_module( void )
110 {
111         return new ModuleSajoinFactory;
112 }
113