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