]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_operlog.cpp
09395fccb29e6eecbcdc80f76326d100da745066
[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 "inspircd.h"
15
16 /* $ModDesc: A module which logs all oper commands to the ircd log at default loglevel. */
17
18 class ModuleOperLog : public Module
19 {
20  private:
21          
22  public:
23         ModuleOperLog(InspIRCd* Me) : Module(Me)
24         {
25                 
26         }
27  
28         virtual ~ModuleOperLog()
29         {
30         }
31  
32         virtual Version GetVersion()
33         {
34                 return Version(1,1,0,0,VF_VENDOR,API_VERSION);
35         }
36  
37         void Implements(char* List)
38         {
39                 List[I_OnPreCommand] = List[I_On005Numeric] = 1;
40         }
41
42         virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated, const std::string &original_line)
43         {
44                 /* If the command doesnt appear to be valid, we dont want to mess with it. */
45                 if (!validated)
46                         return 0;
47  
48                 if ((IS_OPER(user)) && (IS_LOCAL(user)) && (user->HasPermission(command)))
49                 {
50                         Command* thiscommand = ServerInstance->Parser->GetHandler(command);
51                         if ((thiscommand) && (thiscommand->flags_needed == 'o'))
52                         {
53                                 std::string plist;
54                                 for (int j = 0; j < pcnt; j++)
55                                         plist.append(std::string(" ")+std::string(parameters[j]));
56
57                                 ServerInstance->Log(DEFAULT,"OPERLOG: [%s!%s@%s] %s%s",user->nick,user->ident,user->host,command.c_str(),plist.c_str());
58                         }
59                 }
60
61                 return 0;
62         }
63
64         virtual void On005Numeric(std::string &output)
65         {
66                 output.append(" OPERLOG");
67         }
68
69 };
70  
71  
72 MODULE_INIT(ModuleOperLog)