]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_conn_lusers.cpp
kick_channel -> chanrec::KickUser(), server_kick_channel -> chanrec::ServerKickUser()
[user/henk/code/inspircd.git] / src / modules / m_conn_lusers.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 "users.h"
20 #include "channels.h"
21 #include "modules.h"
22
23 /* $ModDesc: Sends the /LUSERS on connect */
24
25 // This has to be the simplest module ever.
26 // The RFC doesnt specify that you should send the /LUSERS numerics
27 // on connect, but someone asked for it, so its in a module.
28
29 class ModuleConnLUSERS : public Module
30 {
31  private:
32          
33          Server *Srv;
34  public:
35         ModuleConnLUSERS(Server* Me)
36                 : Module::Module(Me)
37         {
38                 Srv = Me;
39         }
40         
41         virtual ~ModuleConnLUSERS()
42         {
43         }
44         
45         virtual Version GetVersion()
46         {
47                 return Version(1,0,0,1,VF_VENDOR);
48         }
49
50         void Implements(char* List)
51         {
52                 List[I_OnUserConnect] = 1;
53         }
54         
55         virtual void OnUserConnect(userrec* user)
56         {
57                 // if we're using a protocol module, we cant just call
58                 // the command handler because the protocol module
59                 // has hooked it. We must call OnPreCommand in the
60                 // protocol module. Yes, at some point there will
61                 // be a way to get the current protocol module's name
62                 // from the core and probably a pointer to its class.
63                 Module* Proto = Srv->FindModule("m_spanningtree.so");
64                 if (Proto)
65                 {
66                         Proto->OnPreCommand("LUSERS", NULL, 0, user, true);
67                 }
68                 else
69                 {
70                         Srv->CallCommandHandler("LUSERS", NULL, 0, user);
71                 }
72         }
73 };
74
75
76 //
77 // The ModuleConnLUSERSFactory class inherits from ModuleFactory
78 // and creates a ModuleConnLUSERS object when requested.
79 //
80
81 class ModuleConnLUSERSFactory : public ModuleFactory
82 {
83  public:
84         ModuleConnLUSERSFactory()
85         {
86         }
87         
88         ~ModuleConnLUSERSFactory()
89         {
90         }
91         
92         virtual Module * CreateModule(Server* Me)
93         {
94                 return new ModuleConnLUSERS(Me);
95         }
96         
97 };
98
99
100 //
101 // The "C" linkage factory0() function creates the ModuleConnLUSERSFactory
102 // class for this library
103 //
104
105 extern "C" void * init_module( void )
106 {
107         return new ModuleConnLUSERSFactory;
108 }
109