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