]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_foobar.cpp
Added support for part messages in the module API (and therefore between servers...
[user/henk/code/inspircd.git] / src / modules / m_foobar.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd is copyright (C) 2002-2006 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         void Implements(char* List)
60         {
61                 List[I_OnUserConnect] = List[I_OnUserQuit] = List[I_OnUserJoin] = List[I_OnUserPart] = 1;
62         }
63         
64         virtual void OnUserConnect(userrec* user)
65         {
66                 // method called when a user connects
67         
68                 std::string b = user->nick;
69                 Srv->Log(DEBUG,"Foobar: User connecting: " + b);
70         }
71
72         virtual void OnUserQuit(userrec* user, std::string reason)
73         {
74                 // method called when a user disconnects
75         
76                 std::string b = user->nick;
77                 Srv->Log(DEBUG,"Foobar: User quitting: " + b);
78         }
79         
80         virtual void OnUserJoin(userrec* user, chanrec* channel)
81         {
82                 // method called when a user joins a channel
83         
84                 std::string c = channel->name;
85                 std::string b = user->nick;
86                 Srv->Log(DEBUG,"Foobar: User " + b + " joined " + c);
87         }
88
89         virtual void OnUserPart(userrec* user, chanrec* channel, std::string partreason)
90         {
91                 // method called when a user parts a channel
92         
93                 std::string c = channel->name;
94                 std::string b = user->nick;
95                 Srv->Log(DEBUG,"Foobar: User " + b + " parted " + c);
96         }
97
98 };
99
100
101 //
102 // The ModuleFoobarFactory class inherits from ModuleFactory
103 // and creates a ModuleFoobar object when requested.
104 //
105
106 class ModuleFoobarFactory : public ModuleFactory
107 {
108  public:
109         ModuleFoobarFactory()
110         {
111         }
112         
113         ~ModuleFoobarFactory()
114         {
115         }
116         
117         virtual Module * CreateModule(Server* Me)
118         {
119                 return new ModuleFoobar(Me);
120         }
121         
122 };
123
124
125 //
126 // The "C" linkage factory0() function creates the ModuleFoobarFactory
127 // class for this library
128 //
129
130 extern "C" void * init_module( void )
131 {
132         return new ModuleFoobarFactory;
133 }
134