]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_foobar.cpp
Someone is getting slapped for this; the new hidesplits/hidebans behavior doesn't...
[user/henk/code/inspircd.git] / src / modules / m_foobar.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2007 InspIRCd Development Team
6  * See: http://www.inspircd.org/wiki/index.php/Credits
7  *
8  * This program is free but copyrighted software; see
9  *            the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 #include "users.h"
15 #include "channels.h"
16 #include "modules.h"
17
18 #include "inspircd.h"
19
20 /* $ModDesc: A dummy module for testing */
21
22 // Class ModuleFoobar inherits from Module
23 // It just outputs simple debug strings to show its methods are working.
24
25 class ModuleFoobar : public Module
26 {
27  private:
28          
29          // It is recommended that your class makes use of one or more Server
30          // objects. A server object is a class which contains methods which
31          // encapsulate the exports from the core of the ircd.
32          // such methods include Debug, SendChannel, etc.
33  
34          
35  public:
36         ModuleFoobar(InspIRCd* Me)
37                 : Module::Module(Me)
38         {
39                 // The constructor just makes a copy of the server class
40         
41                 
42         }
43         
44         virtual ~ModuleFoobar()
45         {
46         }
47         
48         virtual Version GetVersion()
49         {
50                 // this method instantiates a class of type Version, and returns
51                 // the modules version information using it.
52         
53                 return Version(1,1,0,1,VF_VENDOR,API_VERSION);
54         }
55
56         void Implements(char* List)
57         {
58                 List[I_OnUserConnect] = List[I_OnUserQuit] = List[I_OnUserJoin] = List[I_OnUserPart] = 1;
59         }
60         
61         virtual void OnUserConnect(userrec* user)
62         {
63                 // method called when a user connects
64         
65                 std::string b = user->nick;
66                 ServerInstance->Log(DEBUG,"Foobar: User connecting: "+b);
67         }
68
69         virtual void OnUserQuit(userrec* user, const std::string &reason)
70         {
71                 // method called when a user disconnects
72         
73                 std::string b = user->nick;
74                 ServerInstance->Log(DEBUG,"Foobar: User quitting: "+b);
75         }
76         
77         virtual void OnUserJoin(userrec* user, chanrec* channel)
78         {
79                 // method called when a user joins a channel
80         
81                 std::string c = channel->name;
82                 std::string b = user->nick;
83                 ServerInstance->Log(DEBUG,"Foobar: User "+b+" joined "+c);
84         }
85
86         virtual void OnUserPart(userrec* user, chanrec* channel, const std::string &partreason)
87         {
88                 // method called when a user parts a channel
89         
90                 std::string c = channel->name;
91                 std::string b = user->nick;
92                 ServerInstance->Log(DEBUG,"Foobar: User "+b+" parted "+c);
93         }
94
95 };
96
97
98 //
99 // The ModuleFoobarFactory class inherits from ModuleFactory
100 // and creates a ModuleFoobar object when requested.
101 //
102
103 class ModuleFoobarFactory : public ModuleFactory
104 {
105  public:
106         ModuleFoobarFactory()
107         {
108         }
109         
110         ~ModuleFoobarFactory()
111         {
112         }
113         
114         virtual Module * CreateModule(InspIRCd* Me)
115         {
116                 return new ModuleFoobar(Me);
117         }
118         
119 };
120
121
122 //
123 // The "C" linkage factory0() function creates the ModuleFoobarFactory
124 // class for this library
125 //
126
127 extern "C" void * init_module( void )
128 {
129         return new ModuleFoobarFactory;
130 }
131