]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_foobar.cpp
667a739a5bfdd51f4603ae3f17f35863cc669ebc
[user/henk/code/inspircd.git] / src / modules / m_foobar.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2008 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, I_OnUserPreJoin };
39                 ServerInstance->Modules->Attach(eventlist, this, 5);
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,2,0,1,VF_VENDOR,API_VERSION);
52         }
53
54         
55         virtual void OnUserConnect(User* user)
56         {
57                 // method called when a user connects
58         
59                 std::string b = user->nick;
60                 ServerInstance->Logs->Log("m_foobar",DEBUG,"Foobar: User connecting: "+b);
61         }
62
63         virtual void OnUserQuit(User* user, const std::string &reason, const std::string &oper_message)
64         {
65                 // method called when a user disconnects
66         
67                 std::string b = user->nick;
68                 ServerInstance->Logs->Log("m_foobar",DEBUG,"Foobar: User quitting: "+b);
69         }
70         
71         virtual void OnUserJoin(User* user, Channel* channel, bool sync, bool &silent)
72         {
73                 // method called when a user joins a channel
74
75                 std::string c = channel->name;
76                 std::string b = user->nick;
77                 ServerInstance->Logs->Log("m_foobar",DEBUG,"Foobar: User "+b+" joined "+c);
78         }
79
80         virtual void OnUserPart(User* user, Channel* channel, const std::string &partreason, bool &silent)
81         {
82                 // method called when a user parts a channel
83         
84                 std::string c = channel->name;
85                 std::string b = user->nick;
86                 ServerInstance->Logs->Log("m_foobar",DEBUG,"Foobar: User "+b+" parted "+c);
87         }
88
89         virtual int OnUserPreJoin(User* user, Channel* chan, const char* cname, std::string &privs, const std::string &keygiven)
90         {
91                 return 0;
92         }
93 };
94
95
96 MODULE_INIT(ModuleFoobar)
97