]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_foobar.cpp
Moved a ton of functions into helperfuncs.h to speed up recompiles
[user/henk/code/inspircd.git] / src / modules / m_foobar.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 #include "users.h"
18 #include "channels.h"
19 #include "modules.h"
20
21 /* $ModDesc: A dummy module for testing */
22
23 // Class ModuleFoobar inherits from Module
24 // It just outputs simple debug strings to show its methods are working.
25
26 class ModuleFoobar : public Module
27 {
28  private:
29          
30          // It is recommended that your class makes use of one or more Server
31          // objects. A server object is a class which contains methods which
32          // encapsulate the exports from the core of the ircd.
33          // such methods include Debug, SendChannel, etc.
34  
35          Server *Srv;
36  public:
37         ModuleFoobar()
38         {
39                 // The constructor just creates an instance of the server class
40         
41                 Srv = new Server;
42         }
43         
44         virtual ~ModuleFoobar()
45         {
46                 // destructor deletes the instance of the server class
47         
48                 delete Srv;
49         }
50         
51         virtual Version GetVersion()
52         {
53                 // this method instantiates a class of type Version, and returns
54                 // the modules version information using it.
55         
56                 return Version(1,0,0,1,VF_VENDOR);
57         }
58         
59         virtual void OnUserConnect(userrec* user)
60         {
61                 // method called when a user connects
62         
63                 std::string b = user->nick;
64                 Srv->Log(DEBUG,"Foobar: User connecting: " + b);
65         }
66
67         virtual void OnUserQuit(userrec* user)
68         {
69                 // method called when a user disconnects
70         
71                 std::string b = user->nick;
72                 Srv->Log(DEBUG,"Foobar: User quitting: " + b);
73         }
74         
75         virtual void OnUserJoin(userrec* user, chanrec* channel)
76         {
77                 // method called when a user joins a channel
78         
79                 std::string c = channel->name;
80                 std::string b = user->nick;
81                 Srv->Log(DEBUG,"Foobar: User " + b + " joined " + c);
82         }
83
84         virtual void OnUserPart(userrec* user, chanrec* channel)
85         {
86                 // method called when a user parts a channel
87         
88                 std::string c = channel->name;
89                 std::string b = user->nick;
90                 Srv->Log(DEBUG,"Foobar: User " + b + " parted " + c);
91         }
92
93 };
94
95
96 //
97 // The ModuleFoobarFactory class inherits from ModuleFactory
98 // and creates a ModuleFoobar object when requested.
99 //
100
101 class ModuleFoobarFactory : public ModuleFactory
102 {
103  public:
104         ModuleFoobarFactory()
105         {
106         }
107         
108         ~ModuleFoobarFactory()
109         {
110         }
111         
112         virtual Module * CreateModule()
113         {
114                 return new ModuleFoobar;
115         }
116         
117 };
118
119
120 //
121 // The "C" linkage factory0() function creates the ModuleFoobarFactory
122 // class for this library
123 //
124
125 extern "C" void * init_module( void )
126 {
127         return new ModuleFoobarFactory;
128 }
129