]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_operlog.cpp
Oper logging module -- this still needs test compiling and test running
[user/henk/code/inspircd.git] / src / modules / m_operlog.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 #include "message.h"
24 #include <vector>
25
26 /* $ModDesc: A module which logs all oper commands to the ircd log at default loglevel. */
27
28 class ModuleOperLog : public Module
29 {
30  private:
31          Server *Srv;
32  public:
33         ModuleOperLog(Server* Me) : Module::Module(Me)
34         {
35                 Srv = Me;
36         }
37  
38         virtual ~ModuleOperLog()
39         {
40         }
41  
42         virtual Version GetVersion()
43         {
44                 return Version(1,0,0,0,VF_VENDOR);
45         }
46  
47         void Implements(char* List)
48         {
49                 List[I_OnPreCommand] = List[I_On005Numeric] = 1;
50         }
51
52         virtual int OnPreCommand(const std::string &command, char **parameters, int pcnt, userrec *user, bool validated)
53         {
54                 /* If the command doesnt appear to be valid, we dont want to mess with it. */
55                 if (!validated)
56                         return 0;
57  
58                 if (*user->oper)
59                 {
60                         std::string plist = "";
61                         for (int j = 0; j < pcnt; j++)
62                         {
63                                 plist.append(" "+parameters[j]);
64                         }
65                         log(DEFAULT,"OPERLOG: [%s!%s@%s] %s%s",user->nick,user->ident,user->host,command.c_str(),plist.c_str());
66                 }
67
68                 return 0;
69         }
70
71         virtual void On005Numeric(std::string &output)
72         {
73                 output.append(" OPERLOG");
74         }
75
76 };
77  
78  
79  
80 /******************************************************************************************************/
81  
82 class ModuleOperLogFactory : public ModuleFactory
83 {
84  public:
85         ModuleOperLogFactory()
86         {
87         }
88  
89         ~ModuleOperLogFactory()
90         {
91         }
92  
93         virtual Module * CreateModule(Server* Me)
94         {
95                 return new ModuleOperLog(Me);
96         }
97  
98 };
99  
100 extern "C" void * init_module( void )
101 {
102         return new ModuleOperLogFactory;
103 }
104