]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_foobar.cpp
New 'Implements' system
[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 using namespace std;
18
19 #include "users.h"
20 #include "channels.h"
21 #include "modules.h"
22
23 /* $ModDesc: A dummy module for testing */
24
25 // Class ModuleFoobar inherits from Module
26 // It just outputs simple debug strings to show its methods are working.
27
28 class ModuleFoobar : public Module
29 {
30  private:
31          
32          // It is recommended that your class makes use of one or more Server
33          // objects. A server object is a class which contains methods which
34          // encapsulate the exports from the core of the ircd.
35          // such methods include Debug, SendChannel, etc.
36  
37          Server *Srv;
38  public:
39         ModuleFoobar(Server* Me)
40                 : Module::Module(Me)
41         {
42                 // The constructor just makes a copy of the server class
43         
44                 Srv = Me;
45         }
46         
47         virtual ~ModuleFoobar()
48         {
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, std::string reason)
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(Server* Me)
113         {
114                 return new ModuleFoobar(Me);
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