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