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