]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_operlog.cpp
Wheee, mass commit! this adds const stafety, throwing a compile error if anyone does...
[user/henk/code/inspircd.git] / src / modules / m_operlog.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 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                 Implementation eventlist[] = { I_OnPreCommand, I_On005Numeric };
27                 ServerInstance->Modules->Attach(eventlist, this, 2);
28         }
29  
30         virtual ~ModuleOperLog()
31         {
32         }
33  
34         virtual Version GetVersion()
35         {
36                 return Version(1,1,0,0,VF_VENDOR,API_VERSION);
37         }
38  
39
40         virtual int OnPreCommand(const std::string &command, const char* const* parameters, int pcnt, User *user, bool validated, const std::string &original_line)
41         {
42                 /* If the command doesnt appear to be valid, we dont want to mess with it. */
43                 if (!validated)
44                         return 0;
45  
46                 if ((IS_OPER(user)) && (IS_LOCAL(user)) && (user->HasPermission(command)))
47                 {
48                         Command* thiscommand = ServerInstance->Parser->GetHandler(command);
49                         if ((thiscommand) && (thiscommand->flags_needed == 'o'))
50                         {
51                                 std::string plist;
52                                 for (int j = 0; j < pcnt; j++)
53                                         plist.append(std::string(" ")+std::string(parameters[j]));
54
55                                 ServerInstance->Log(DEFAULT,"OPERLOG: [%s!%s@%s] %s%s",user->nick,user->ident,user->host,command.c_str(),plist.c_str());
56                         }
57                 }
58
59                 return 0;
60         }
61
62         virtual void On005Numeric(std::string &output)
63         {
64                 output.append(" OPERLOG");
65         }
66
67 };
68  
69  
70 MODULE_INIT(ModuleOperLog)