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