]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_foobar.cpp
Some more to fix still, modules probably wont load correctly atm
[user/henk/code/inspircd.git] / src / modules / m_foobar.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2007 InspIRCd Development Team
6  * See: http://www.inspircd.org/wiki/index.php/Credits
7  *
8  * This program is free but copyrighted software; see
9  *            the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 #include "inspircd.h"
15
16 /* $ModDesc: A dummy module for testing */
17
18 // Class ModuleFoobar inherits from Module
19 // It just outputs simple debug strings to show its methods are working.
20
21 class ModuleFoobar : public Module
22 {
23  private:
24          
25          // It is recommended that your class makes use of one or more Server
26          // objects. A server object is a class which contains methods which
27          // encapsulate the exports from the core of the ircd.
28          // such methods include Debug, SendChannel, etc.
29  
30          
31  public:
32         ModuleFoobar(InspIRCd* Me)
33                 : Module(Me)
34         {
35                 // The constructor just makes a copy of the server class
36         
37                 
38                 Implementation eventlist[] = { I_OnUserConnect, I_OnUserQuit, I_OnUserJoin, I_OnUserPart };
39                 ServerInstance->Modules->Attach(eventlist, this, 4);
40         }
41         
42         virtual ~ModuleFoobar()
43         {
44         }
45         
46         virtual Version GetVersion()
47         {
48                 // this method instantiates a class of type Version, and returns
49                 // the modules version information using it.
50         
51                 return Version(1,1,0,1,VF_VENDOR,API_VERSION);
52         }
53
54         void Implements(char* List)
55         {
56                 List[I_OnUserConnect] = List[I_OnUserQuit] = List[I_OnUserJoin] = List[I_OnUserPart] = 1;
57         }
58         
59         virtual void OnUserConnect(User* user)
60         {
61                 // method called when a user connects
62         
63                 std::string b = user->nick;
64                 ServerInstance->Log(DEBUG,"Foobar: User connecting: "+b);
65         }
66
67         virtual void OnUserQuit(User* user, const std::string &reason, const std::string &oper_message)
68         {
69                 // method called when a user disconnects
70         
71                 std::string b = user->nick;
72                 ServerInstance->Log(DEBUG,"Foobar: User quitting: "+b);
73         }
74         
75         virtual void OnUserJoin(User* user, Channel* channel, bool &silent)
76         {
77                 // method called when a user joins a channel
78         
79                 std::string c = channel->name;
80                 std::string b = user->nick;
81                 ServerInstance->Log(DEBUG,"Foobar: User "+b+" joined "+c);
82         }
83
84         virtual void OnUserPart(User* user, Channel* channel, const std::string &partreason, bool &silent)
85         {
86                 // method called when a user parts a channel
87         
88                 std::string c = channel->name;
89                 std::string b = user->nick;
90                 ServerInstance->Log(DEBUG,"Foobar: User "+b+" parted "+c);
91         }
92
93 };
94
95
96 MODULE_INIT(ModuleFoobar)
97