]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_foobar.cpp
b2e56c94d7afb9f03eab8d81838c8cbd4bdc6ce9
[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()
40         {
41                 // The constructor just creates an instance of the server class
42         
43                 Srv = new Server;
44         }
45         
46         virtual ~ModuleFoobar()
47         {
48                 // destructor deletes the instance of the server class
49         
50                 delete Srv;
51         }
52         
53         virtual Version GetVersion()
54         {
55                 // this method instantiates a class of type Version, and returns
56                 // the modules version information using it.
57         
58                 return Version(1,0,0,1,VF_VENDOR);
59         }
60         
61         virtual void OnUserConnect(userrec* user)
62         {
63                 // method called when a user connects
64         
65                 std::string b = user->nick;
66                 Srv->Log(DEBUG,"Foobar: User connecting: " + b);
67         }
68
69         virtual void OnUserQuit(userrec* user, std::string reason)
70         {
71                 // method called when a user disconnects
72         
73                 std::string b = user->nick;
74                 Srv->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                 Srv->Log(DEBUG,"Foobar: User " + b + " joined " + c);
84         }
85
86         virtual void OnUserPart(userrec* user, chanrec* channel)
87         {
88                 // method called when a user parts a channel
89         
90                 std::string c = channel->name;
91                 std::string b = user->nick;
92                 Srv->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()
115         {
116                 return new ModuleFoobar;
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