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