]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_sajoin.cpp
FindNick, FindChan, ChanModes, UserList, CountInvisible, PurgeEmptyChannels, GetClass...
[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 #include "inspircd.h"
26
27 /* $ModDesc: Provides support for unreal-style SAJOIN command */
28
29 static Server *Srv;
30 extern InspIRCd* ServerInstance;
31
32 class cmd_sajoin : public command_t
33 {
34  public:
35         cmd_sajoin() : command_t("SAJOIN", 'o', 2)
36         {
37                 this->source = "m_sajoin.so";
38                 syntax = "<nick> <channel>";
39         }
40
41         void Handle (const char** parameters, int pcnt, userrec *user)
42         {
43                 userrec* dest = ServerInstance->FindNick(parameters[0]);
44                 if (dest)
45                 {
46                         if (Srv->IsUlined(dest->server))
47                         {
48                                 user->WriteServ("990 %s :Cannot use an SA command on a u-lined client",user->nick);
49                                 return;
50                         }
51                         if (!IsValidChannelName(parameters[1]))
52                         {
53                                 /* we didn't need to check this for each character ;) */
54                                 user->WriteServ("NOTICE "+std::string(user->nick)+" :*** Invalid characters in channel name");
55                                 return;
56                         }
57
58                         ServerInstance->WriteOpers(std::string(user->nick)+" used SAJOIN to make "+std::string(dest->nick)+" join "+parameters[1]);
59                         chanrec::JoinUser(ServerInstance, dest, parameters[1], true);
60                 }
61         }
62 };
63
64 class ModuleSajoin : public Module
65 {
66         cmd_sajoin*     mycommand;
67  public:
68         ModuleSajoin(Server* Me)
69                 : Module::Module(Me)
70         {
71                 Srv = Me;
72                 mycommand = new cmd_sajoin();
73                 Srv->AddCommand(mycommand);
74         }
75         
76         virtual ~ModuleSajoin()
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 ModuleSajoinFactory : public ModuleFactory
90 {
91  public:
92         ModuleSajoinFactory()
93         {
94         }
95         
96         ~ModuleSajoinFactory()
97         {
98         }
99         
100         virtual Module * CreateModule(Server* Me)
101         {
102                 return new ModuleSajoin(Me);
103         }
104         
105 };
106
107
108 extern "C" void * init_module( void )
109 {
110         return new ModuleSajoinFactory;
111 }
112