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