]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_conn_lusers.cpp
Review and optimize
[user/henk/code/inspircd.git] / src / modules / m_conn_lusers.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 "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         virtual void OnUserConnect(userrec* user)
51         {
52                 // if we're using a protocol module, we cant just call
53                 // the command handler because the protocol module
54                 // has hooked it. We must call OnPreCommand in the
55                 // protocol module. Yes, at some point there will
56                 // be a way to get the current protocol module's name
57                 // from the core and probably a pointer to its class.
58                 Module* Proto = Srv->FindModule("m_spanningtree.so");
59                 if (Proto)
60                 {
61                         Proto->OnPreCommand("LUSERS", NULL, 0, user, true);
62                 }
63                 else
64                 {
65                         Srv->CallCommandHandler("LUSERS", NULL, 0, user);
66                 }
67         }
68 };
69
70
71 //
72 // The ModuleConnLUSERSFactory class inherits from ModuleFactory
73 // and creates a ModuleConnLUSERS object when requested.
74 //
75
76 class ModuleConnLUSERSFactory : public ModuleFactory
77 {
78  public:
79         ModuleConnLUSERSFactory()
80         {
81         }
82         
83         ~ModuleConnLUSERSFactory()
84         {
85         }
86         
87         virtual Module * CreateModule(Server* Me)
88         {
89                 return new ModuleConnLUSERS(Me);
90         }
91         
92 };
93
94
95 //
96 // The "C" linkage factory0() function creates the ModuleConnLUSERSFactory
97 // class for this library
98 //
99
100 extern "C" void * init_module( void )
101 {
102         return new ModuleConnLUSERSFactory;
103 }
104